10 #if defined( INC_ALL )
36 OUT PKC_INFO *contextData,
39 const void *publicKeyData,
41 const int publicKeyDataLength )
47 assert(
isWritePtr( contextData,
sizeof( PKC_INFO ) ) );
49 assert(
isReadPtr( publicKeyData, publicKeyDataLength ) );
55 status = staticInitContext( staticContextInfo,
CONTEXT_PKC,
56 capabilityInfoPtr, contextData,
57 sizeof( PKC_INFO ), NULL );
64 sMemConnect( &stream, publicKeyData, publicKeyDataLength );
65 status = contextData->readPublicKeyFunction( &stream, staticContextInfo,
67 sMemDisconnect( &stream );
71 status = capabilityInfoPtr->initKeyFunction( staticContextInfo,
76 staticDestroyContext( staticContextInfo );
105 assert(
isReadPtr( keyInfo, keyInfoSize ) );
112 getHashAtomicParameters(
CRYPT_ALGO_SHA1, 0, &hashFunctionAtomic, NULL );
123 PKC_INFO staticContextData, *publicKey = contextInfoPtr->ctxPKC;
134 status = calculateFlatKeyID( publicKey->publicKeyInfo,
135 publicKey->publicKeyInfoSize,
166 status = initStaticContext( &staticContextInfo, &staticContextData,
168 publicKey->publicKeyInfo,
169 publicKey->publicKeyInfoSize );
174 status = initStaticContext( &staticContextInfo, &staticContextData,
176 publicKey->publicKeyInfo,
177 publicKey->publicKeyInfoSize );
182 status = initStaticContext( &staticContextInfo, &staticContextData,
184 publicKey->publicKeyInfo,
185 publicKey->publicKeyInfoSize );
191 status = initStaticContext( &staticContextInfo, &staticContextData,
193 publicKey->publicKeyInfo,
194 publicKey->publicKeyInfoSize );
211 contextInfoPtr->ctxPKC->keySizeBits = staticContextData.keySizeBits;
218 memcpy( publicKey->pgp2KeyID, staticContextData.pgp2KeyID,
224 memcpy( publicKey->openPgpKeyID, staticContextData.openPgpKeyID,
229 staticDestroyContext( &staticContextInfo );
242 #if defined( USE_PGP ) || defined( USE_PGPKEYS )
248 PKC_INFO *publicKey = contextInfoPtr->ctxPKC;
282 status = publicKey->writePublicKeyFunction( &stream, contextInfoPtr,
287 sMemClose( &stream );
290 length = stell( &stream );
291 packetHeader[ 0 ] = 0x99;
292 packetHeader[ 1 ] = ( length >> 8 ) & 0xFF;
293 packetHeader[ 2 ] = length & 0xFF;
301 memcpy( publicKey->openPgpKeyID, hash + hashSize -
PGP_KEYID_SIZE,
303 sMemClose( &stream );
316 const PKC_INFO *dlpKey,
319 const int parameterSize = ( int ) sizeofObject( \
323 const int componentSize =
sizeofBignum( &dlpKey->dlpParam_y );
327 assert(
isReadPtr( dlpKey,
sizeof( PKC_INFO ) ) );
334 ( int ) sizeofObject( componentSize + 1 );
335 writeSequence( stream, totalSize );
336 writeAlgoIDparam( stream, cryptAlgo, parameterSize );
338 swrite( stream,
"\x02\x01\x00", 3 );
340 writeBitStringHole( stream, componentSize,
DEFAULT_TAG );
341 return(
writeBignum( stream, &dlpKey->dlpParam_y ) );
356 PKC_INFO *publicKey = contextInfoPtr->ctxPKC;
359 const CRYPT_ALGO_TYPE cryptAlgo = contextInfoPtr->capabilityInfo->cryptAlgo;
368 if( publicKey->publicKeyInfo != NULL )
369 return( calculateKeyIDFromEncoded( contextInfoPtr, cryptAlgo ) );
382 status = writePKCS3Key( &stream, publicKey, cryptAlgo );
386 status = publicKey->writePublicKeyFunction( &stream, contextInfoPtr,
391 status = calculateFlatKeyID(
buffer, stell( &stream ),
393 sMemClose( &stream );
397 #if defined( USE_PGP ) || defined( USE_PGPKEYS )
402 const PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
406 &pkcInfo->rsaParam_n );
411 memcpy( publicKey->pgp2KeyID,
428 status = calculateOpenPGPKeyID( contextInfoPtr, cryptAlgo );
445 PKC_INFO *pkcInfo = contextInfoPtr->ctxPKC;
452 pkcInfo->calculateKeyIDFunction = calculateKeyID;