Changeset 40
- Timestamp:
- 01/31/06 17:13:31 (3 years ago)
- Location:
- trunk/opensc.tokend/Tokend-11
- Files:
-
- 2 removed
- 4 modified
-
OpenSC/OpenSCConfig.cpp (deleted)
-
OpenSC/OpenSCConfig.h (deleted)
-
OpenSC/OpenSCKeyHandle.cpp (modified) (1 diff)
-
OpenSC/OpenSCToken.cpp (modified) (12 diffs)
-
OpenSC/OpenSCToken.h (modified) (2 diffs)
-
Tokend.xcodeproj/project.pbxproj (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/opensc.tokend/Tokend-11/OpenSC/OpenSCKeyHandle.cpp
r24 r40 247 247 return new OpenSCKeyHandle(openSCToken, metaRecord, key); 248 248 } 249 250 /* arch-tag: 8B1B6D68-124C-11D9-B5E6-000A9595DEEE */ -
trunk/opensc.tokend/Tokend-11/OpenSC/OpenSCToken.cpp
r27 r40 27 27 #include "AttributeCoder.h" 28 28 29 #include "opensc/opensc.h"30 29 #include <opensc/opensc.h> 30 #include <opensc/scconf.h> 31 31 #include "OpenSCError.h" 32 32 #include "OpenSCRecord.h" … … 41 41 OpenSCToken::OpenSCToken() : mLocked(false) 42 42 { 43 //otdEnableLogging(true);43 otdEnableLogging(true); 44 44 mTokenContext = this; 45 45 mScCtx = NULL; … … 76 76 const unsigned char *newPin, size_t newPinLength) 77 77 { 78 otdLog("In OpenSCToken::changePIN()\n"); 78 otdLog("In OpenSCToken::changePIN(%d)\n", pinNum); 79 int r; 79 80 if (pinNum != 1) 80 81 CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); 81 82 82 83 if (oldPinLength < 0 || oldPinLength > 14 || 83 84 newPinLength < 0 || newPinLength > 14) 84 85 CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); 86 85 87 } 86 88 … … 101 103 void OpenSCToken::verifyPIN(int pinNum, const uint8_t *pin, size_t pinLength) 102 104 { 103 otdLog("In OpenSCToken::verifyPIN( )\n");105 otdLog("In OpenSCToken::verifyPIN(%d)\n", pinNum); 104 106 if (_verifyPIN(pinNum, pin, pinLength)) { 105 107 otdLog(" About to call BEGIN()\n"); 106 mLocked = true;108 mLocked = false; 107 109 } else { 108 110 CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); … … 194 196 CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); 195 197 196 mLocked = false;198 mLocked = true; 197 199 } 198 200 … … 204 206 { 205 207 otdLog("\nIn OpenSCToken::probe()\n"); 206 208 207 209 uint32 score = Tokend::ISO7816Token::probe(flags, tokenUid); 208 210 209 bool doDisconnect = true; /*!(flags & kSecTokendProbeKeepToken); */211 // FIXME bool doDisconnect = true; /*!(flags & kSecTokendProbeKeepToken); */ 210 212 211 213 // Init OpenSC 212 int r = sc_establish_context(&mScCtx, " default");214 int r = sc_establish_context(&mScCtx, "tokend"); 213 215 otdLog(" tokend_establish_context(): %d\n", r); 214 216 if (r == 0) { … … 217 219 const SCARD_READERSTATE &readerState = *(*startupReaderInfo)(); 218 220 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) 220 222 break; 221 223 } … … 223 225 // Connect to the card 224 226 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); 226 228 otdLog(" sc_connect_card(): %d\n", r); 227 229 if (r < 0) { 228 230 sc_release_context(mScCtx); 229 231 mScCtx = NULL; 230 } 231 else { 232 } else { 232 233 otdLog(" card: %s\n", mScCard->name); 233 234 r = sc_pkcs15_bind(mScCard, &mScP15Card); 234 235 otdLog(" sc_pkcs15_bind(): %d\n", r); 235 236 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 242 246 // Create a tokenUid 243 247 if (mScP15Card->label != NULL) … … 254 258 otdLog(" err: reader \"%s\" not found by OpenSC\n", readerState.szReader); 255 259 } 256 257 if (doDisconnect) 258 disconnect(); 259 260 260 261 return score; 261 262 } … … 384 385 385 386 // 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 ? 387 388 otdLog(" sc_pkcs15_get_objects(TYPE_CERT_X509): %d\n", r); 388 389 if (r >= 0) { … … 419 420 } 420 421 if (it == mCertificates.end()) 421 otdLog(" no certificate found this key\n");422 otdLog(" no certificate found for this key\n"); 422 423 else 423 424 { … … 450 451 otdLog(" returning from OpenSCToken::populate()\n"); 451 452 } 452 453 /* arch-tag: 8A7C3BAF-124C-11D9-A606-000A9595DEEE */ -
trunk/opensc.tokend/Tokend-11/OpenSC/OpenSCToken.h
r25 r40 37 37 #include "opensc/pkcs15.h" 38 38 #include "opensc/errors.h" 39 #include "OpenSCConfig.h"40 39 41 40 #include <security_utilities/pcsc++.h> 42 41 43 42 class OpenSCSchema; 44 class OpenSCConfig;45 43 46 44 // … … 88 86 sc_card_t *mScCard; 89 87 sc_pkcs15_card_t *mScP15Card; 90 OpenSCConfig mConfig; 91 88 92 89 private: 93 void populate();90 void populate(); 94 91 // temporary ACL cache hack - to be removed 95 92 AutoAclOwnerPrototype mAclOwner; -
trunk/opensc.tokend/Tokend-11/Tokend.xcodeproj/project.pbxproj
r26 r40 36 36 E2A907FF093B4FEF00869318 /* libscconf.2.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E2A907FE093B4FEF00869318 /* libscconf.2.0.0.dylib */; }; 37 37 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 */; };39 38 E4C24C0608C8565400F249D8 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CA8C4D606D6D19400F1BCC8 /* CoreFoundation.framework */; }; 40 39 E4CF7A2F08ED3DE4008D18FA /* OpenSCKeyHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4CF7A1808ED3DE3008D18FA /* OpenSCKeyHandle.cpp */; }; … … 146 145 4C3C166D06F61D6F00FC8AAC /* KeyHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyHandle.h; sourceTree = "<group>"; }; 147 146 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/Build8 F46/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>"; }; 149 148 4CA8C4D606D6D19400F1BCC8 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; }; 150 149 4CBF5CBE0704E76200EEADC2 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.1.dylib; sourceTree = "<absolute>"; }; 151 150 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/Build8 F46/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/Build8 F46/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>"; }; 155 154 52CA8342067E8175005A1EBA /* PCSC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PCSC.framework; path = /System/Library/Frameworks/PCSC.framework; sourceTree = "<absolute>"; }; 156 155 52CA8343067E8175005A1EBA /* Security.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; 157 156 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/Build8 F46/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>"; }; 159 158 E29A5716093C8886009429AF /* OpenSCLog.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = OpenSCLog.cpp; path = OpenSC/OpenSCLog.cpp; sourceTree = SOURCE_ROOT; }; 160 159 E29A5718093C888F009429AF /* OpenSCLog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = OpenSCLog.h; path = OpenSC/OpenSCLog.h; sourceTree = SOURCE_ROOT; }; … … 162 161 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>"; }; 163 162 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>"; };166 163 E42E576508ED7F5000932114 /* OpenSCError.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = OpenSCError.h; path = OpenSC/OpenSCError.h; sourceTree = SOURCE_ROOT; }; 167 164 E4C24C0708C8565400F249D8 /* OpenSC.tokend */ = {isa = PBXFileReference; explicitFileType = folder; includeInIndex = 0; path = OpenSC.tokend; sourceTree = BUILT_PRODUCTS_DIR; }; … … 293 290 E4CF7A2308ED3DE4008D18FA /* OpenSCSchema.h */, 294 291 E4CF7A2408ED3DE4008D18FA /* mds */, 295 E2D0E301096AF68400B7D157 /* OpenSCConfig.h */,296 E2D0E302096AF68400B7D157 /* OpenSCConfig.cpp */,297 292 ); 298 293 path = OpenSC; … … 446 441 E4CF7A3508ED3DE4008D18FA /* OpenSCError.cpp in Sources */, 447 442 E29A5717093C8886009429AF /* OpenSCLog.cpp in Sources */, 448 E2D0E303096AF68400B7D157 /* OpenSCConfig.cpp in Sources */,449 443 ); 450 444 runOnlyForDeploymentPostprocessing = 0; … … 502 496 /Library/OpenSC/lib/, 503 497 "$(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", 505 499 ); 506 500 OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates"; … … 553 547 /Library/OpenSC/lib/, 554 548 "$(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", 556 550 ); 557 551 OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates"; … … 604 598 /Library/OpenSC/lib/, 605 599 "$(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", 607 601 ); 608 602 OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates"; … … 660 654 /Library/OpenSC/lib/, 661 655 "$(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", 663 657 ); 664 658 OPT_CPPXFLAGS = "$(OPT_CXFLAGS) -fno-enforce-eh-specs -fno-implement-inlines -fcoalesce-templates";
