224 assert(
isWritePtr( keyIdLen,
sizeof(
int ) ) );
225 assert(
isReadPtr( keyID, idValueLength ) );
230 iDtype == CRYPT_IKEYID_KEYID || \
231 iDtype == CRYPT_IKEYID_ISSUERID || \
232 iDtype == CRYPT_IKEYID_CERTID );
236 memset( keyID, 0,
min( 16, keyIdMaxLen ) );
247 if( idLength > keyIdMaxLen )
250 idLength = keyIdMaxLen;
252 memcpy( keyID, idValue, idLength );
261 for( i = 0; i < idLength; i++ )
264 *keyIdLen = idLength;
272 if( iDtype == CRYPT_IKEYID_KEYID )
281 idValue, idValueLength );
282 idValue = hashBuffer;
293 status = base64encode( keyID, keyIdMaxLen, keyIdLen, idValue,
303 int getKeyID(
OUT_BUFFER( keyIdMaxLen, *keyIdLen )
char *keyID,
313 assert(
isWritePtr( keyIdLen,
sizeof(
int ) ) );
318 keyIDtype == CRYPT_IATTRIBUTE_AUTHCERTID ) || \
320 keyIDtype == CRYPT_IATTRIBUTE_ISSUER || \
321 keyIDtype == CRYPT_IATTRIBUTE_SUBJECT || \
322 keyIDtype == CRYPT_IATTRIBUTE_ISSUERANDSERIALNUMBER || \
323 keyIDtype == CRYPT_IATTRIBUTE_SPKI ) );
326 memset( keyID, 0,
min( 16, keyIdMaxLen ) );
332 keyIDtype == CRYPT_IATTRIBUTE_AUTHCERTID )
338 &msgData, keyIDtype );
350 status = dynCreate( &idDB, iCryptHandle, keyIDtype );
361 return( makeKeyID( keyID, keyIdMaxLen, keyIdLen, CRYPT_IKEYID_CERTID,
368 int getCertKeyID(
OUT_BUFFER( keyIdMaxLen, *keyIdLen )
char *keyID,
376 assert(
isWritePtr( keyIdLen,
sizeof(
int ) ) );
382 memset( keyID, 0,
min( 16, keyIdMaxLen ) );
393 status = getKeyID( keyID, keyIdMaxLen, keyIdLen, iCryptCert,
404 return( getKeyID( keyID, keyIdMaxLen, keyIdLen, iCryptCert,
405 CRYPT_IATTRIBUTE_SPKI ) );
416 void *certDataBuffer,
418 const int certDataMaxLength,
424 assert(
isWritePtr( certDataBuffer, certDataMaxLength ) );
425 assert(
isWritePtr( certDataLength,
sizeof(
int ) ) );
429 formatType == CRYPT_ICERTFORMAT_DATA || \
430 formatType == CRYPT_IATTRIBUTE_CRLENTRY );
439 "Format type collision" );
442 memset( certDataBuffer, 0,
min( 16, certDataMaxLength ) );
450 case CRYPT_ICERTFORMAT_DATA:
452 &msgData, formatType );
455 case CRYPT_IATTRIBUTE_CRLENTRY:
457 &msgData, formatType );
465 *certDataLength = msgData.
length;
510 case CRYPT_IKEYID_KEYID:
513 case CRYPT_IKEYID_ISSUERID:
514 return(
"issuerID" );
516 case CRYPT_IKEYID_CERTID:
539 int updateProgress = 0,
status;
554 "CREATE TABLE certificates ("
561 "email VARCHAR(64), "
562 "validTo DATETIME NOT NULL, "
567 "certData BLOB NOT NULL)" );
572 "Couldn't create certificate database: " ) );
583 "CREATE TABLE CRLs ("
584 "expiryDate DATETIME NOT NULL, "
588 "certData BLOB NOT NULL)" );
593 "CREATE TABLE pkiUsers ("
603 "certData BLOB NOT NULL)" );
609 "CREATE TABLE certRequests ("
610 "type SMALLINT NOT NULL, "
617 "email VARCHAR(64), "
619 "certData BLOB NOT NULL)" );
625 "CREATE TABLE certLog ("
626 "action SMALLINT NOT NULL, "
627 "actionTime DATETIME NOT NULL, "
637 "CREATE TABLE CRLs ("
639 "certData BLOB NOT NULL)" );
645 if( updateProgress > 0 )
647 if( updateProgress > 1 )
649 if( updateProgress > 2 )
653 "Couldn't create certificate%s database: ",
680 "CREATE INDEX emailIdx ON certificates(email)" );
683 "CREATE INDEX nameIDIdx ON certificates(nameID)" );
686 "CREATE UNIQUE INDEX issuerIDIdx ON certificates(issuerID)" );
689 "CREATE UNIQUE INDEX keyIDIdx ON certificates(keyID)" );
692 "CREATE UNIQUE INDEX certIDIdx ON certificates(certID)" );
695 "CREATE UNIQUE INDEX crlIssuerIDIdx ON CRLs (issuerID)" );
698 "CREATE UNIQUE INDEX crlCertIDIdx ON CRLs (certID)" );
701 "CREATE UNIQUE INDEX userKeyIDIdx ON pkiUsers (keyID)" );
704 "CREATE UNIQUE INDEX userNameIDIdx ON pkiUsers (nameID)" );
707 "CREATE UNIQUE INDEX logCertIDIdx ON certLog (certID)" );
719 dummyCertID, dummyCertIDlength,
720 NULL, 0, NULL, 0, NULL, 0,
736 "Couldn't create indexes for certificate%s database: ",
794 return( ( keysetInfoPtr->keysetDBMS->
flags & \
807 DBMS_INFO *dbmsInfo = keysetInfoPtr->keysetDBMS;
819 status = dbmsParseName( &nameInfo, name, nameLen );
830 endDbxSession( keysetInfoPtr );
840 endDbxSession( keysetInfoPtr );
843 "Certificate database can only be accessed in read-only "
850 status = createDatabase( dbmsInfo,
855 NULL, 0, NULL, 0, NULL, 0, NULL, 0,
860 endDbxSession( keysetInfoPtr );
870 "SELECT certData FROM certLog WHERE action = "
887 endDbxSession( keysetInfoPtr );
890 "Certificate store can't be accessed as a normal "
891 "database except in read-only mode" ) );
908 NULL, 0, NULL, 0, NULL, 0, NULL, 0,
919 endDbxSession( keysetInfoPtr );
922 "Couldn't update certificate store log" ) );
934 endDbxSession( keysetInfoPtr );
937 "Keyset isn't a certificate store" ) );
943 resetErrorInfo( dbmsInfo );
953 DBMS_INFO *dbmsInfo = keysetInfoPtr->keysetDBMS;
963 NULL, 0, NULL, 0, NULL, 0, NULL, 0,
974 return( endDbxSession( keysetInfoPtr ) );
999 status = initDbxSession( keysetInfoPtr, type );
1004 keysetInfoPtr->initFunction = initFunction;
1005 keysetInfoPtr->shutdownFunction = shutdownFunction;
1006 status = initDBMSread( keysetInfoPtr );
1008 status = initDBMSwrite( keysetInfoPtr );
1014 status = initDBMSCA( keysetInfoPtr );
1018 keysetInfoPtr->isBusyFunction = isBusyFunction;