47 if( pkcs15infoPtr->labelLength <= 0 )
54 pkcs15infoPtr->labelLength = msgData.
length;
57 &msgData, CRYPT_IATTRIBUTE_KEYID );
60 pkcs15infoPtr->keyIDlength = msgData.
length;
62 if( pkcs15infoPtr->iDlength <= 0 && pkcs15infoPtr->keyIDlength > 0 )
64 memcpy( pkcs15infoPtr->iD, pkcs15infoPtr->keyID,
65 pkcs15infoPtr->keyIDlength );
66 pkcs15infoPtr->iDlength = pkcs15infoPtr->keyIDlength;
68 if( pkcs15infoPtr->pgp2KeyIDlength <= 0 )
72 &msgData, CRYPT_IATTRIBUTE_KEYID_PGP2 );
76 pkcs15infoPtr->pgp2KeyIDlength = msgData.
length;
79 if( pkcs15infoPtr->openPGPKeyIDlength <= 0 )
83 &msgData, CRYPT_IATTRIBUTE_KEYID_OPENPGP );
87 pkcs15infoPtr->openPGPKeyIDlength = msgData.
length;
101 memcpy( pkcs15infoPtr->keyID, sKIDbuffer, msgData.
length );
102 pkcs15infoPtr->keyIDlength = msgData.
length;
113 OUT int *trustedUsage )
120 assert(
isWritePtr( trustedUsage,
sizeof(
int ) ) );
125 *isCA = *trustedImplicit =
FALSE;
155 *trustedImplicit =
FALSE;
160 status = getValidityInfo( pkcs15infoPtr, iCryptCert );
174 if( pkcs15infoPtr->iDlength <= 0 )
176 status = getCertID( iCryptCert, CRYPT_IATTRIBUTE_SPKI,
178 &pkcs15infoPtr->iDlength );
182 if( pkcs15infoPtr->keyIDlength <= 0 )
190 pkcs15infoPtr->keyIDlength = msgData.
length;
193 memcpy( pkcs15infoPtr->keyID, pkcs15infoPtr->iD,
194 pkcs15infoPtr->iDlength );
195 pkcs15infoPtr->keyIDlength = pkcs15infoPtr->iDlength;
200 status = getCertID( iCryptCert, CRYPT_IATTRIBUTE_ISSUERANDSERIALNUMBER,
202 &pkcs15infoPtr->iAndSIDlength );
204 status = getCertID( iCryptCert, CRYPT_IATTRIBUTE_SUBJECT,
206 &pkcs15infoPtr->subjectNameIDlength );
208 status = getCertID( iCryptCert, CRYPT_IATTRIBUTE_ISSUER,
210 &pkcs15infoPtr->issuerNameIDlength );
218 IN_FLAGS( PKCS15_USAGE )
const int privKeyUsage )
235 &msgData, CRYPT_IATTRIBUTE_DEVICESTORAGEID );
332 identifierSize = ( int ) \
335 sizeofObject( pkcs15infoPtr->keyIDlength ) );
336 if( pkcs15infoPtr->iAndSIDlength > 0 )
337 identifierSize += ( int ) \
340 sizeofObject( pkcs15infoPtr->iAndSIDlength ) );
341 if( pkcs15infoPtr->issuerNameIDlength > 0 )
342 identifierSize += ( int ) \
345 sizeofObject( pkcs15infoPtr->issuerNameIDlength ) );
346 if( pkcs15infoPtr->subjectNameIDlength > 0 )
347 identifierSize += ( int ) \
350 sizeofObject( pkcs15infoPtr->subjectNameIDlength ) );
351 if( pkcs15infoPtr->pgp2KeyIDlength > 0 )
352 identifierSize += ( int ) \
355 sizeofObject( pkcs15infoPtr->pgp2KeyIDlength ) );
356 if( pkcs15infoPtr->openPGPKeyIDlength > 0 )
357 identifierSize += ( int ) \
360 sizeofObject( pkcs15infoPtr->openPGPKeyIDlength ) );
362 return( identifierSize );
379 writeConstructed( stream, length, tag );
380 writeSequence( stream,
385 status = writeOctetString( stream, pkcs15infoPtr->keyID,
389 writeSequence( stream,
394 status = writeOctetString( stream, pkcs15infoPtr->iAndSID,
400 writeSequence( stream,
404 status = writeOctetString( stream, pkcs15infoPtr->issuerNameID,
410 writeSequence( stream,
414 status = writeOctetString( stream, pkcs15infoPtr->subjectNameID,
423 status = writeOctetString( stream, pkcs15infoPtr->pgp2KeyID,
432 status = writeOctetString( stream, pkcs15infoPtr->openPGPKeyID,
443 int writeKeyAttributes(
OUT_BUFFER( privKeyAttributeMaxLen, \
447 const int privKeyAttributeMaxLen,
451 void *pubKeyAttributes,
453 const int pubKeyAttributeMaxLen,
459 int commonAttributeSize, commonKeyAttributeSize, keyUsage,
status;
461 assert(
isWritePtr( privKeyAttributes, privKeyAttributeMaxLen ) );
462 assert(
isWritePtr( privKeyAttributeSize,
sizeof(
int ) ) );
463 assert(
isWritePtr( pubKeyAttributes, pubKeyAttributeMaxLen ) );
464 assert(
isWritePtr( pubKeyAttributeSize,
sizeof(
int ) ) );
467 REQUIRES( privKeyAttributeMaxLen >= 16 && \
469 REQUIRES( pubKeyAttributeMaxLen >= 16 && \
474 memset( privKeyAttributes, 0,
min( 16, privKeyAttributeMaxLen ) );
475 memset( pubKeyAttributes, 0,
min( 16, pubKeyAttributeMaxLen ) );
476 *privKeyAttributeSize = *pubKeyAttributeSize = 0;
479 status = getKeyIDs( pkcs15infoPtr, iCryptContext );
488 ( void ) getValidityInfo( pkcs15infoPtr, iCryptContext );
498 keyUsage = getKeyUsageFlags( iCryptContext,
499 pkcs15infoPtr->privKeyUsage );
504 commonAttributeSize = ( int) sizeofObject( pkcs15infoPtr->labelLength );
505 commonKeyAttributeSize = ( int ) sizeofObject( pkcs15infoPtr->iDlength ) + \
506 sizeofBitString( keyUsage ) + \
514 sMemOpen( &stream, privKeyAttributes, privKeyAttributeMaxLen );
515 writeSequence( &stream, commonAttributeSize );
516 writeCharacterString( &stream, (
BYTE * ) pkcs15infoPtr->label,
518 writeSequence( &stream, commonKeyAttributeSize );
519 writeOctetString( &stream, pkcs15infoPtr->iD, pkcs15infoPtr->iDlength,
524 status = writeGeneralizedTime( &stream, pkcs15infoPtr->validFrom,
527 status = writeGeneralizedTime( &stream, pkcs15infoPtr->validTo,
530 *privKeyAttributeSize = stell( &stream );
531 sMemDisconnect( &stream );
533 pkcs15infoPtr->privKeyUsage = keyUsage;
537 commonKeyAttributeSize = ( int ) sizeofObject( pkcs15infoPtr->iDlength ) + \
538 sizeofBitString( keyUsage ) + \
546 sMemOpen( &stream, pubKeyAttributes, pubKeyAttributeMaxLen );
547 writeSequence( &stream, commonAttributeSize );
548 writeCharacterString( &stream, (
BYTE * ) pkcs15infoPtr->label,
550 writeSequence( &stream, commonKeyAttributeSize );
551 writeOctetString( &stream, pkcs15infoPtr->iD, pkcs15infoPtr->iDlength,
556 status = writeGeneralizedTime( &stream, pkcs15infoPtr->validFrom,
559 status = writeGeneralizedTime( &stream, pkcs15infoPtr->validTo,
562 *pubKeyAttributeSize = stell( &stream );
563 sMemDisconnect( &stream );
565 pkcs15infoPtr->pubKeyUsage = keyUsage;
580 int commonAttributeSize, commonCertAttributeSize;
581 int keyIdentifierDataSize, trustedUsageSize;
582 int isCA, trustedUsage,
status;
584 assert(
isWritePtr( certAttributes, certAttributeMaxLen ) );
585 assert(
isWritePtr( certAttributeSize,
sizeof(
int ) ) );
588 REQUIRES( certAttributeMaxLen >= 16 && \
593 memset( certAttributes, 0,
min( 16, certAttributeMaxLen ) );
594 *certAttributeSize = 0;
597 status = getCertIDs( pkcs15infoPtr, iCryptCert, &isCA,
598 &trustedImplicit, &trustedUsage );
613 keyIdentifierDataSize = sizeofObjectIDs( pkcs15infoPtr );
614 commonAttributeSize = ( pkcs15infoPtr->labelLength > 0 ) ? \
615 (
int) sizeofObject( pkcs15infoPtr->labelLength ) : 0;
616 commonCertAttributeSize = ( int ) \
617 sizeofObject( pkcs15infoPtr->iDlength ) + \
620 sizeofObject( trustedUsageSize ) : 0 ) + \
621 sizeofObject( keyIdentifierDataSize ) + \
622 ( trustedImplicit ? sizeofBoolean() : 0 ) + \
626 sMemOpen( &stream, certAttributes, certAttributeMaxLen );
627 writeSequence( &stream, commonAttributeSize );
628 if( commonAttributeSize > 0 )
629 writeCharacterString( &stream, pkcs15infoPtr->label,
631 writeSequence( &stream, commonCertAttributeSize );
632 writeOctetString( &stream, pkcs15infoPtr->iD, pkcs15infoPtr->iDlength,
639 writeBitString( &stream, trustedUsage,
DEFAULT_TAG );
641 status = writeObjectIDs( &stream, pkcs15infoPtr, keyIdentifierDataSize,
644 if( trustedImplicit )
646 writeGeneralizedTime( &stream, pkcs15infoPtr->validFrom,
DEFAULT_TAG );
647 status = writeGeneralizedTime( &stream, pkcs15infoPtr->validTo,
650 *certAttributeSize = stell( &stream );
651 sMemDisconnect( &stream );