Changeset 40

Show
Ignore:
Timestamp:
01/31/06 17:13:31 (3 years ago)
Author:
martin
Message:
  • Use opensc.conf from OpenSC to get the score configuration and get rid of OpenSCConfig
  • Find the right reader to use
  • Update to latest Tokend code (10.4.4)
Location:
trunk/opensc.tokend/Tokend-11
Files:
2 removed
4 modified

Legend:

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

    r24 r40  
    247247        return new OpenSCKeyHandle(openSCToken, metaRecord, key); 
    248248} 
    249  
    250 /* arch-tag: 8B1B6D68-124C-11D9-B5E6-000A9595DEEE */ 
  • trunk/opensc.tokend/Tokend-11/OpenSC/OpenSCToken.cpp

    r27 r40  
    2727#include "AttributeCoder.h" 
    2828 
    29 #include "opensc/opensc.h" 
    30  
     29#include <opensc/opensc.h> 
     30#include <opensc/scconf.h> 
    3131#include "OpenSCError.h" 
    3232#include "OpenSCRecord.h" 
     
    4141OpenSCToken::OpenSCToken() : mLocked(false) 
    4242{ 
    43         //otdEnableLogging(true); 
     43        otdEnableLogging(true); 
    4444        mTokenContext = this; 
    4545        mScCtx = NULL; 
     
    7676        const unsigned char *newPin, size_t newPinLength) 
    7777{ 
    78         otdLog("In OpenSCToken::changePIN()\n"); 
     78        otdLog("In OpenSCToken::changePIN(%d)\n", pinNum); 
     79        int r; 
    7980        if (pinNum != 1) 
    8081                CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); 
    81  
     82         
    8283        if (oldPinLength < 0 || oldPinLength > 14 || 
    8384                newPinLength < 0 || newPinLength > 14) 
    8485                CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); 
     86         
    8587} 
    8688 
     
    101103void OpenSCToken::verifyPIN(int pinNum, const uint8_t *pin, size_t pinLength) 
    102104{ 
    103         otdLog("In OpenSCToken::verifyPIN()\n"); 
     105        otdLog("In OpenSCToken::verifyPIN(%d)\n", pinNum); 
    104106        if (_verifyPIN(pinNum, pin, pinLength)) { 
    105107                otdLog("  About to call BEGIN()\n"); 
    106                 mLocked = true; 
     108                mLocked = false; 
    107109        } else { 
    108110                CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); 
     
    194196                CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); 
    195197         
    196         mLocked = false; 
     198        mLocked = true; 
    197199} 
    198200 
     
    204206{ 
    205207        otdLog("\nIn OpenSCToken::probe()\n"); 
    206  
     208         
    207209        uint32 score = Tokend::ISO7816Token::probe(flags, tokenUid); 
    208210 
    209         bool doDisconnect = true; /*!(flags & kSecTokendProbeKeepToken); */ 
     211        // FIXME bool doDisconnect = true; /*!(flags & kSecTokendProbeKeepToken); */ 
    210212 
    211213        // Init OpenSC 
    212         int r = sc_establish_context(&mScCtx, "default"); 
     214        int r = sc_establish_context(&mScCtx, "tokend"); 
    213215        otdLog("  tokend_establish_context(): %d\n", r); 
    214216        if (r == 0) { 
     
    217219                const SCARD_READERSTATE &readerState = *(*startupReaderInfo)(); 
    218220                for (idx = 0; idx < mScCtx->reader_count; idx++) { 
    219                         if (strcmp(readerState.szReader, mScCtx->reader[0]->name) == 0) 
     221                        if (strcmp(readerState.szReader, mScCtx->reader[idx]->name) == 0) 
    220222                                break; 
    221223                } 
     
    223225                // Connect to the card 
    224226                if (idx < mScCtx->reader_count) { 
    225                         r = sc_connect_card(mScCtx->reader[0], 0, &mScCard); 
     227                        r = sc_connect_card(mScCtx->reader[idx], 0, &mScCard); 
    226228                        otdLog("  sc_connect_card(): %d\n", r); 
    227229                        if (r < 0) { 
    228230                                sc_release_context(mScCtx); 
    229231                                mScCtx = NULL; 
    230                         } 
    231                         else { 
     232                        } else { 
    232233                                otdLog("  card: %s\n", mScCard->name); 
    233234                                r = sc_pkcs15_bind(mScCard, &mScP15Card); 
    234235                                otdLog("  sc_pkcs15_bind(): %d\n", r); 
    235236                                if (r == 0) { 
    236                                         // OK, the we can handle the card 
    237                                         doDisconnect = false; 
    238  
    239                                         // Get a score for this card 
    240                                         score = mConfig.getScore(mScP15Card); 
    241  
     237                                        // get the score 
     238                                        scconf_block *conf_block = NULL; 
     239                                        conf_block = sc_get_conf_block(mScCtx, "framework", "tokend", 1); 
     240                                        if (conf_block) { 
     241                                                score = scconf_get_int(conf_block, "score", 50); 
     242                                        } else { 
     243                                                score = 50; 
     244                                        } 
     245                                         
    242246                                        // Create a tokenUid 
    243247                                        if (mScP15Card->label != NULL) 
     
    254258                        otdLog("  err: reader \"%s\" not found by OpenSC\n", readerState.szReader); 
    255259        } 
    256  
    257         if (doDisconnect) 
    258                 disconnect(); 
    259  
     260         
    260261        return score; 
    261262} 
     
    384385                 
    385386        // Locate certificates 
    386         r = sc_pkcs15_get_objects(mScP15Card, SC_PKCS15_TYPE_CERT_X509, objs, 32); 
     387        r = sc_pkcs15_get_objects(mScP15Card, SC_PKCS15_TYPE_CERT_X509, objs, 32); //FIXME - max objects constant ? 
    387388        otdLog("  sc_pkcs15_get_objects(TYPE_CERT_X509): %d\n", r); 
    388389        if (r >= 0) { 
     
    419420                        } 
    420421                        if (it == mCertificates.end()) 
    421                                 otdLog("        no certificate found this key\n"); 
     422                                otdLog("        no certificate found for this key\n"); 
    422423                        else 
    423424                        { 
     
    450451        otdLog("  returning from OpenSCToken::populate()\n"); 
    451452} 
    452  
    453 /* arch-tag: 8A7C3BAF-124C-11D9-A606-000A9595DEEE */ 
  • trunk/opensc.tokend/Tokend-11/OpenSC/OpenSCToken.h

    r25 r40  
    3737#include "opensc/pkcs15.h" 
    3838#include "opensc/errors.h" 
    39 #include "OpenSCConfig.h" 
    4039 
    4140#include <security_utilities/pcsc++.h> 
    4241 
    4342class OpenSCSchema; 
    44 class OpenSCConfig; 
    4543 
    4644// 
     
    8886        sc_card_t *mScCard; 
    8987        sc_pkcs15_card_t *mScP15Card; 
    90         OpenSCConfig mConfig; 
    91  
     88         
    9289private: 
    93                 void populate(); 
     90        void populate(); 
    9491        // temporary ACL cache hack - to be removed 
    9592        AutoAclOwnerPrototype mAclOwner; 
  • trunk/opensc.tokend/Tokend-11/Tokend.xcodeproj/project.pbxproj

    r26 r40  
    3636                E2A907FF093B4FEF00869318 /* libscconf.2.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E2A907FE093B4FEF00869318 /* libscconf.2.0.0.dylib */; }; 
    3737                E2A90801093B501A00869318 /* libpkcs15init.2.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E2A90800093B501A00869318 /* libpkcs15init.2.0.0.dylib */; }; 
    38                 E2D0E303096AF68400B7D157 /* OpenSCConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E2D0E302096AF68400B7D157 /* OpenSCConfig.cpp */; }; 
    3938                E4C24C0608C8565400F249D8 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CA8C4D606D6D19400F1BCC8 /* CoreFoundation.framework */; }; 
    4039                E4CF7A2F08ED3DE4008D18FA /* OpenSCKeyHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4CF7A1808ED3DE3008D18FA /* OpenSCKeyHandle.cpp */; }; 
     
    146145                4C3C166D06F61D6F00FC8AAC /* KeyHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyHandle.h; sourceTree = "<group>"; }; 
    147146                4C55BAFB06DEABE500E4200A /* RecordHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RecordHandle.h; sourceTree = "<group>"; }; 
    148                 4CA858F10654413F0083DED3 /* SecurityTokend.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SecurityTokend.framework; path = /Volumes/Builds/Build8F46/BuildRoot/System/Library/PrivateFrameworks/SecurityTokend.framework; sourceTree = "<absolute>"; }; 
     147                4CA858F10654413F0083DED3 /* SecurityTokend.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SecurityTokend.framework; path = /Volumes/Builds/Build8G32/BuildRoot/System/Library/PrivateFrameworks/SecurityTokend.framework; sourceTree = "<absolute>"; }; 
    149148                4CA8C4D606D6D19400F1BCC8 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; }; 
    150149                4CBF5CBE0704E76200EEADC2 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.1.dylib; sourceTree = "<absolute>"; }; 
    151150                4CC394790731A4DD00761DEE /* SCardError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCardError.h; sourceTree = "<group>"; }; 
    152                 523F79EC06D5AC27004256A0 /* security_cdsa_client.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = security_cdsa_client.framework; path = /Volumes/Builds/Build8F46/BuildRoot/usr/local/SecurityPieces/Frameworks/security_cdsa_client.framework; sourceTree = "<absolute>"; }; 
    153                 523F79ED06D5AC27004256A0 /* security_cdsa_utilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = security_cdsa_utilities.framework; path = /Volumes/Builds/Build8F46/BuildRoot/usr/local/SecurityPieces/Frameworks/security_cdsa_utilities.framework; sourceTree = "<absolute>"; }; 
    154                 523F79EE06D5AC27004256A0 /* security_utilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = security_utilities.framework; path = /Volumes/Builds/Build8F46/BuildRoot/usr/local/SecurityPieces/Frameworks/security_utilities.framework; sourceTree = "<absolute>"; }; 
     151                523F79EC06D5AC27004256A0 /* security_cdsa_client.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = security_cdsa_client.framework; path = /Volumes/Builds/Build8G32/BuildRoot/usr/local/SecurityPieces/Frameworks/security_cdsa_client.framework; sourceTree = "<absolute>"; }; 
     152                523F79ED06D5AC27004256A0 /* security_cdsa_utilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = security_cdsa_utilities.framework; path = /Volumes/Builds/Build8G32/BuildRoot/usr/local/SecurityPieces/Frameworks/security_cdsa_utilities.framework; sourceTree = "<absolute>"; }; 
     153                523F79EE06D5AC27004256A0 /* security_utilities.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = security_utilities.framework; path = /Volumes/Builds/Build8G32/BuildRoot/usr/local/SecurityPieces/Frameworks/security_utilities.framework; sourceTree = "<absolute>"; }; 
    155154                52CA8342067E8175005A1EBA /* PCSC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PCSC.framework; path = /System/Library/Frameworks/PCSC.framework; sourceTree = "<absolute>"; }; 
    156155                52CA8343067E8175005A1EBA /* Security.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; 
    157156                52DE698106E93B870024EA03 /* PKCS11Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PKCS11Object.h; sourceTree = "<group>"; }; 
    158                 5B1662930942788B00779CE3 /* libtokend.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtokend.a; path = "/Volumes/Builds/Build8F46/BuildRoot/private/var/tmp/Tokend/Tokend-11.obj/UninstalledProducts/libtokend.a"; sourceTree = "<absolute>"; }; 
     157                5B1662930942788B00779CE3 /* libtokend.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtokend.a; path = "/Volumes/Builds/Build8G32/BuildRoot/private/var/tmp/Tokend/Tokend-25868.obj/UninstalledProducts/libtokend.a"; sourceTree = "<absolute>"; }; 
    159158                E29A5716093C8886009429AF /* OpenSCLog.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = OpenSCLog.cpp; path = OpenSC/OpenSCLog.cpp; sourceTree = SOURCE_ROOT; }; 
    160159                E29A5718093C888F009429AF /* OpenSCLog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = OpenSCLog.h; path = OpenSC/OpenSCLog.h; sourceTree = SOURCE_ROOT; }; 
     
    162161                E2A907FE093B4FEF00869318 /* libscconf.2.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libscconf.2.0.0.dylib; path = /Library/OpenSC/lib/libscconf.2.0.0.dylib; sourceTree = "<absolute>"; }; 
    163162                E2A90800093B501A00869318 /* libpkcs15init.2.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpkcs15init.2.0.0.dylib; path = /Library/OpenSC/lib/libpkcs15init.2.0.0.dylib; sourceTree = "<absolute>"; }; 
    164                 E2D0E301096AF68400B7D157 /* OpenSCConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenSCConfig.h; sourceTree = "<group>"; }; 
    165                 E2D0E302096AF68400B7D157 /* OpenSCConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OpenSCConfig.cpp; sourceTree = "<group>"; }; 
    166163                E42E576508ED7F5000932114 /* OpenSCError.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = OpenSCError.h; path = OpenSC/OpenSCError.h; sourceTree = SOURCE_ROOT; }; 
    167164                E4C24C0708C8565400F249D8 /* OpenSC.tokend */ = {isa = PBXFileReference; explicitFileType = folder; includeInIndex = 0; path = OpenSC.tokend; sourceTree = BUILT_PRODUCTS_DIR; }; 
     
    293290                                E4CF7A2308ED3DE4008D18FA /* OpenSCSchema.h */, 
    294291                                E4CF7A2408ED3DE4008D18FA /* mds */, 
    295                                 E2D0E301096AF68400B7D157 /* OpenSCConfig.h */, 
    296                                 E2D0E302096AF68400B7D157 /* OpenSCConfig.cpp */, 
    297292                        ); 
    298293                        path = OpenSC; 
     
    446441                                E4CF7A3508ED3DE4008D18FA /* OpenSCError.cpp in Sources */, 
    447442                                E29A5717093C8886009429AF /* OpenSCLog.cpp in Sources */, 
    448                                 E2D0E303096AF68400B7D157 /* OpenSCConfig.cpp in Sources */, 
    449443                        ); 
    450444                        runOnlyForDeploymentPostprocessing = 0; 
     
    502496                                        /Library/OpenSC/lib/, 
    503497                                        "$(LOCAL_LIBRARY_DIR)/OpenSC/lib", 
    504                                         "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-11.obj/UninstalledProducts", 
     498                                        "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-25868.obj/UninstalledProducts", 
    505499                                ); 
    506500                                OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates"; 
     
    553547                                        /Library/OpenSC/lib/, 
    554548                                        "$(LOCAL_LIBRARY_DIR)/OpenSC/lib", 
    555                                         "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-11.obj/UninstalledProducts", 
     549                                        "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-25868.obj/UninstalledProducts", 
    556550                                ); 
    557551                                OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates"; 
     
    604598                                        /Library/OpenSC/lib/, 
    605599                                        "$(LOCAL_LIBRARY_DIR)/OpenSC/lib", 
    606                                         "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-11.obj/UninstalledProducts", 
     600                                        "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-25868.obj/UninstalledProducts", 
    607601                                ); 
    608602                                OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates"; 
     
    660654                                        /Library/OpenSC/lib/, 
    661655                                        "$(LOCAL_LIBRARY_DIR)/OpenSC/lib", 
    662                                         "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-11.obj/UninstalledProducts", 
     656                                        "$(SRCROOT)/../../BuildRoot/private/var/tmp/Tokend/Tokend-25868.obj/UninstalledProducts", 
    663657                                ); 
    664658                                OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates";