NB! This project is outdated and unmaintained, please refer to the OpenSC MacInstaller instead!

Changeset 121


Ignore:
Timestamp:
06/19/09 12:34:59 (3 years ago)
Author:
ludovic.rousseau
Message:

Patch from Hugh Cole-Baker to support 2048-bits keys in tokend
http://www.opensc-project.org/pipermail/opensc-devel/2009-April/012052.html

"I have attached a patch to add support for different size keys in the
tokend, which should work for RSA 2048-bit keys. I removed the hardcoded
1024 values and added an attribute coder for key attributes, which
examines the key object to determine the key size. I've tested this
with my Cryptoflex card, using a 2048-bit e-mail signing cert issued by
Comodo, and a self-signed 1024- bit cert. Both seem to be working to
sign e-mail and for smartcard-based login. Take a look at the patch and
see if there's anything needing correction, or if it can be integrated
into the main source tree.

Many thanks to Martin for providing the files needed to work on and
build the Tokend, since the source code from Apple is apparently
unusable."

Location:
trunk/opensc.tokend/OpenSC
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/opensc.tokend/OpenSC/OpenSCKeyHandle.cpp

    r82 r121  
    5858        uint32 inputSize, bool encrypting) 
    5959{ 
    60         otdLog("In OpenSCKeyHandle::getKeySize()\n"); 
     60        otdLog("In OpenSCKeyHandle::geOutputSize()\n"); 
    6161        secdebug("crypto", "getOutputSize"); 
    6262        CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED); 
     
    130130        if (outputData == NULL) 
    131131                CssmError::throwMe(CSSMERR_CSP_MEMORY_ERROR); 
     132 
     133        otdLog("  Signing buffers: inlen=%d, outlen=%d\n",input.Length, keyLength); 
    132134 
    133135        // Call OpenSC to do the actual signing 
  • trunk/opensc.tokend/OpenSC/OpenSCRecord.cpp

    r44 r121  
    9696} 
    9797 
     98size_t OpenSCKeyRecord::sizeInBits() const 
     99{ 
     100  sc_pkcs15_prkey_info *prkey = (sc_pkcs15_prkey_info *)mPrKeyObj->data; 
     101  return prkey->modulus_length; 
     102} 
    98103 
    99104/************************** OpenSCKeyRecord *****************************/ 
  • trunk/opensc.tokend/OpenSC/OpenSCRecord.h

    r44 r121  
    6868    ~OpenSCKeyRecord() {} 
    6969 
    70         size_t sizeInBits() const { return 1048; } 
     70        size_t sizeInBits() const; 
    7171         
    7272        virtual void getOwner(AclOwnerPrototype &owner); 
  • trunk/opensc.tokend/OpenSC/OpenSCSchema.cpp

    r44 r121  
    4646OpenSCSchema::OpenSCSchema() : 
    4747        mKeyAlgorithmCoder(uint32(CSSM_ALGID_RSA)), 
    48         mKeySizeCoder(uint32(1024)) 
     48        mKeyAttributeCoder() 
    4949{ 
    5050} 
     
    6767        // Other key valuess 
    6868        mr.attributeCoder(kSecKeyKeyType, &mKeyAlgorithmCoder); 
    69         mr.attributeCoder(kSecKeyKeySizeInBits, &mKeySizeCoder); 
    70         mr.attributeCoder(kSecKeyEffectiveKeySize, &mKeySizeCoder); 
     69        mr.attributeCoder(kSecKeyKeySizeInBits, &mKeyAttributeCoder); 
     70        mr.attributeCoder(kSecKeyEffectiveKeySize, &mKeyAttributeCoder); 
    7171 
    7272        // Key attributes 
  • trunk/opensc.tokend/OpenSC/OpenSCSchema.h

    r44 r121  
    4141#include "Schema.h" 
    4242#include "OpenSCKeyHandle.h" 
     43#include "OpenSCAttributeCoder.h" 
    4344 
    4445namespace Tokend 
     
    6364private: 
    6465        Tokend::ConstAttributeCoder mKeyAlgorithmCoder; 
    65         Tokend::ConstAttributeCoder mKeySizeCoder; 
     66        OpenSCKeyAttributeCoder mKeyAttributeCoder; 
    6667 
    6768        OpenSCKeyHandleFactory mOpenSCKeyHandleFactory; 
  • trunk/opensc.tokend/OpenSC/OpenSCToken.cpp

    r92 r121  
    297297                                                        TOKEND_MAX_UID - strlen(tokenUid)); 
    298298 
     299                                        { 
     300                                                /* replace non ASCII chars by '?' */ 
     301                                                int i; 
     302                                                unsigned char *c = (unsigned char *)tokenUid; 
     303 
     304                                                for (i=0; tokenUid[i]; i++) 
     305                                                        if (c[i] > 127) 
     306                                                                tokenUid[i] = '?'; 
     307                                        } 
     308 
    299309                                        otdLog("    score = %d, tokenUid = \"%s\"\n", score, tokenUid); 
    300310                                } 
Note: See TracChangeset for help on using the changeset viewer.