Permalink
Commits on Apr 26, 2017
  1. Make sure it is an SPKI

    dengert committed with frankmorgner Apr 8, 2017
     On branch verify-pubkey-as-spki-2
     Changes to be committed:
    	modified:   framework-pkcs15.c
  2. Add new attribute CKA_SPKI for CKO_PUBLIC_KEY

    dengert committed with frankmorgner Apr 8, 2017
    CKA_SPKI is a vendor defined attribute to be used internally
    as input to to OpenSSL d2i_PUBKEY
    
     On branch verify-pubkey-as-spki-2
     Changes to be committed:
    	modified:   framework-pkcs15.c
    	modified:   mechanism.c
    	modified:   openssl.c
    	modified:   pkcs11-opensc.h
  3. PKCS#11 does not define a CKA_VALUE for public keys and is missused

    dengert committed with frankmorgner Mar 11, 2017
    OpenSC opennssl.c in sc_pkcs11_verify_data assumes that it can
    retieve the CKA_VALUE for a public key object, and expect it to
    be usable as RSA.
    
    But internally sc_pkcs15_pubkey can have a "raw" or "spki"
    version of the public key as defined by PKCS#15.  Card drivers
    or pkcs15-<card> routines may store either the "raw" or "spki"
    versions. A get attribute request for CKA_VALUE for a public key
    will return either the raw, spki or will derived rsa verison of the
    pubkey.
    
    This commit will test if the CKA_VALUE is a spki and use d2i_PUBKEY
    which takes a spki version and returns an EVP_KEY. If it not an spki
    the current method, d21_PublicKey(EVP_PKEY_RSA,...) is used which
    only works for RSA.
    
    The problem was found while testing pkcs11-tool -t -l  where
    the  verify tests would fail with a CKR_GENERAL_ERROR because
    the card driver stored the public key as a spki.
    
    On branch verify-pubkey-as-spki-2
     Changes to be committed:
    	modified:   src/pkcs11/openssl.c
    
    Date:      Fri Apr 07 07:50:00 2017 -0600
  4. build fix for libressl 2.5.3

    fabled committed with frankmorgner Apr 22, 2017
    X509_up_ref is implemented in libressl 2.5.3
Commits on Apr 24, 2017
  1. pkcs15: fix commit 76d5915 auth object regressions

    fabled committed with frankmorgner Apr 22, 2017
    Few conversions of SC_PKCS15_TYPE_AUTH_PIN to SC_PKCS15_TYPE_AUTH
    were missed.
Commits on Apr 22, 2017
  1. Fix bug in pkcs11-tool.c that prevented it from displaying CKA_DERIVE…

    mouse07410 committed with frankmorgner Apr 21, 2017
    … key usage for EC public keys
Commits on Apr 20, 2017
  1. Fix missing error handling of memory allocation (#1020)

    frankmorgner committed Apr 20, 2017
    * libopensc: handle allocation errors
    * handle more faults during memory allocation
    
    fixes several situations that cause segmentation fault
  2. removed obsolete comment

    frankmorgner committed Apr 13, 2017
  3. fixed more coverity issues

    frankmorgner committed Apr 13, 2017
  4. reader-pcsc: removed cardmod driver

    frankmorgner committed Nov 15, 2016
    - pcsc driver takes over all the functionality
    - no dedicated reader driver config values for cardmod, use application
      specific blocks to define a different behavior for the pcsc reader if
      needed
    - removes legacy code; requiring at least libpcsclite 1.6.5
    
    Fixes OpenSC#892
Commits on Apr 19, 2017
  1. Improved creation of key files so that the correct security attribute…

    hhonkanen committed with frankmorgner Apr 7, 2017
    …s are set and keys can be created under specific PINs. Previously keys were always created under PIN 1. Changed description of myeid_create_key function.
  2. Added a check to sc_pkcs15_verify_pin to find out if the access condi…

    hhonkanen committed with frankmorgner Apr 7, 2017
    …tion is already open on card. This check is performed only if this function is called with empty data. This change fixes a problem with pinpad readers, when PIN cache is disabled and prevents unnecessary PIN queries.
Commits on Apr 16, 2017
  1. pkcs11-tool: Set CKA_PRIVATE=false for new public keys

    Jakuje committed with frankmorgner Apr 13, 2017
    Keygen should write public keys with explicit CKA_PRIVATE=false by default (possibility to modify by --private switch)
    
    Related to 4df35b9 discussing writing separate objects years ago.
Commits on Apr 13, 2017
Commits on Apr 5, 2017
  1. Make CardOS 5.3 working with OpenSC (#1003)

    Jakuje committed with frankmorgner Apr 5, 2017
    * Set security context for CardOS 5.3 with p1=0x41 (as Coolkey does)
    
    * Do not emulate signatures in CardOS 5.3
    
    Remove the bogus SC_ALGORITHM_NEED_USAGE which prevents using the
    actual implementation in cardos_compute_signature().
    
    It might be bogus also in previous version, but I don't have a way
    to verify against these cards.
    
    * Do not advertise RSA-X-509 mechanism for CardOS 5.3 (card strips padding)
Commits on Apr 4, 2017
Commits on Apr 3, 2017
  1. pkcs11-tool: fixed RSA-X-509 corner case test

    frankmorgner committed Apr 3, 2017
    For testing RSA-X-509, we are generating random bytes for signing. It
    may happen that the modulus is smaller than the random number
    generated, which triggers an error in the card. With this change, we
    are setting the most significant byte to 0x00 to assure the random
    number is smaller than the modulus.
  2. Coverity fixes (#1012)

    frankmorgner committed Apr 3, 2017
    card-cac.c
     * CLANG_WARNING: The left operand of '<' is a garbage value
    card-coolkey.c
     * CLANG_WARNING: overwriting variable
     * CPPCHECK_WARNING: memory leak / overwrite variable
     * CLANG_WARNING: null pointer dereference
     * UNUSED_VALUE: unused return value
    card-gids.c
     * CLANG_WARNING: Branch condition evaluates to a garbage value
     * SIZEOF_MISMATCH: suspicious_sizeof
    card-myeid.c
     * RESOURCE_LEAK: Variable "buf" going out of scope leaks the storage it points to.
     * CLANG_WARNING: overwriting variable
     * (rewrite not to confuse coverity)
    pkcs15-cac.c
     * RESOURCE_LEAK: Variable "cert_out" going out of scope leaks the storage it points to.
    pkcs15-coolkey.c
     * UNUSED_VALUE: unused return value
    pkcs15-piv.c
     * RESOURCE_LEAK: Variable "cert_out" going out of scope leaks the storage it points to.
    pkcs15-sc-hsm.c
     * DEADCODE
    pkcs11/framework-pkcs15.c
     * RESOURCE_LEAK: Variable "p15_cert" going out of scope leaks the storage it points to.
    pkcs15init/pkcs15-lib.c
     * CLANG_WARNING: Assigned value is garbage or undefined
    pkcs15init/pkcs15-myeid.c
     * UNREACHABLE: Probably wrong placement of code block
    tests/p15dump.c
     * IDENTICAL_BRANCHES
    pkcs15-init.c
     * CLANG_WARNING: Potential leak of memory pointed to by 'args.der_encoded.value'
    pkcs15-tool.c
     * RESOURCE_LEAK: Variable "cert" going out of scope leaks the storage it points to.
     * MISSING_BREAK: The above case falls through to this one.
    sc-hsm-tool.c
     * CLANG_WARNING: Potential leak of memory pointed to by 'sp'
    westcos-tool.c
     * FORWARD_NULL: Passing null pointer "pin" to "unlock_pin", which dereferences it.
     * (rewrite not to confuse coverity)
    card-cac.c
    * Avoid malloc with 0 argument
    gids-tool.c
    * FORWARD_NULL -- copy&paste error
    scconf.c
    * CLANG_WARNING: Call to 'malloc' has an allocation size of 0 bytes
    
    closes #982
  3. macOS: added support for access via CryptoTokenKit

    frankmorgner committed Feb 7, 2017
    Binaries still need to be signed with the com.apple.security.smartcard
    entitlement. The command should look something like this:
    
    codesign --force --entitlements MacOSX/pcsc.entitlements --sign "Mac Developer" target/Library/OpenSC/bin/*
    codesign --force --entitlements MacOSX/pcsc.entitlements --sign "Mac Developer" target/Library/OpenSC/lib/*.dylib
    codesign --force --entitlements MacOSX/pcsc.entitlements --sign "Mac Developer" --deep target/Library/OpenSC/lib/opensc-pkcs11.bundle
    codesign --force --entitlements MacOSX/pcsc.entitlements --sign "Mac Developer" --deep target/Library/Security/tokend/OpenSC.tokend
Commits on Mar 28, 2017
  1. fixed compiler warnings

    frankmorgner committed Mar 27, 2017
Commits on Mar 27, 2017
  1. Minidriver CardReadFile() parameters are optional

    maciejsszmigiero committed with frankmorgner Mar 14, 2017
    According to minidriver specs CardReadFile() method output parameters are
    optional so don't return SCARD_E_INVALID_PARAMETER when they are NULL.
    
    Also, use this opportunity to walk through this function helpers to make
    sure they correctly return error status.
    
    Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
  2. Minidriver CardGetChallenge() parameters are output only

    maciejsszmigiero committed with frankmorgner Mar 14, 2017
    According to minidriver specs CardGetChallenge() method parameters
    are purely for output and do not have a meaning of requested challenge
    length, so remove a misleading log line.
    
    There is also no need to have a special case for pcbChallengeData being
    NULL since in this case the function would have exited early anyway with
    SCARD_E_INVALID_PARAMETER (also, it was just dereferenced in the previous
    code line).
    
    Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
  3. Fix minidriver log messages format and parameter issues flagged by GCC

    maciejsszmigiero committed with frankmorgner Mar 14, 2017
    Since last commit GCC warns us about problems with format strings and their
    arguments in minidriver, so let's fix these warnings just as we did in rest
    of the OpenSC code.
    
    Most of these warnings were about DWORDs being printed as ints, there were
    also some format directives and size_t size specifiers missing and various
    misc format / parameter disagreements.
    
    Attempt was made to keep log strings as-is, only the most obvious typos
    were fixed.
    
    Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
  4. Add GCC format checking attributes to minidriver logging function

    maciejsszmigiero committed with frankmorgner Sep 30, 2016
    Commit "Add GCC format checking attributes to log functions" added format
    and parameter checking to OpenSC log functions.
    Minidriver, however, logs most of its output via a dedicated log function,
    so this function needs such attributes, too.
    
    Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>