56 BYTE iAndSHeader[ 64 + 8 ];
58 int hashAlgo, signAlgo, pgpHashAlgo, pgpSignAlgo;
61 assert( ( data == NULL && dataMaxLen == 0 ) || \
63 assert(
isWritePtr( dataLen,
sizeof(
int ) ) );
65 REQUIRES( ( data == NULL && dataMaxLen == 0 ) || \
92 &msgData, CRYPT_IATTRIBUTE_KEYID_OPENPGP );
107 if( iAndSlength > 0 )
111 sMemOpen( &headerStream, iAndSHeader, 64 );
112 pgpWriteLength( &headerStream, \
116 writeUint32( &headerStream, 0 );
117 writeUint16( &headerStream, 21 );
118 writeUint16( &headerStream, iAndSlength );
119 status = swrite( &headerStream,
"issuerAndSerialNumber", 21 );
121 iAndSHeaderLength = stell( &headerStream );
122 sMemDisconnect( &headerStream );
128 sMemOpenOpt( &stream, data, dataMaxLen );
130 sputc( &stream, sigType );
131 sputc( &stream, pgpSignAlgo );
132 status = sputc( &stream, pgpHashAlgo );
135 sMemClose( &stream );
153 if( iAndSlength > 0 )
154 length += iAndSHeaderLength + iAndSlength;
155 writeUint16( &stream,
length );
158 writeUint32Time( &stream, currentTime );
164 status = swrite( &stream, iAndSHeader, iAndSHeaderLength );
167 status = exportAttributeToStream( &stream, iSignContext,
168 CRYPT_IATTRIBUTE_ISSUERANDSERIALNUMBER );
173 sMemClose( &stream );
180 status = writeUint16( &stream, 0 );
182 *dataLen = stell( &stream );
183 sMemDisconnect( &stream );
210 BYTE extraTrailer[ 8 + 8 ];
211 int extraDataLength = 1024, extraTrailerLength =
DUMMY_INIT;
212 int signatureDataLength, iAndSlength = 0, totalLength =
DUMMY_INIT;
215 assert( ( signature == NULL && sigMaxLength == 0 ) || \
217 assert(
isWritePtr( signatureLength,
sizeof(
int ) ) );
219 REQUIRES( ( signature == NULL && sigMaxLength == 0 ) || \
220 ( signature != NULL && \
230 CRYPT_IATTRIBUTE_ISSUERANDSERIALNUMBER );
232 iAndSlength = msgData.
length;
236 if( signature == NULL )
238 status = writePgpSigPacketHeader( NULL, 0, &extraDataLength,
239 iSignContext, iHashContext,
240 sigType, iAndSlength );
243 status = createSignature( NULL, 0, &signatureDataLength,
249 signatureDataLength ) + \
250 extraDataLength + 2 + signatureDataLength;
260 if( iAndSlength > extraDataLength - 128 )
262 extraDataLength = 128 + iAndSlength;
263 if( ( extraDataPtr =
clDynAlloc(
"createSignaturePGP", \
264 extraDataLength ) ) == NULL )
283 status = writePgpSigPacketHeader( extraData, extraDataLength,
284 &extraDataLength, iSignContext,
285 iHashContext, sigType, iAndSlength );
303 zeroise( extraDataPtr, extraDataLength );
304 if( extraDataPtr != extraData )
305 clFree(
"createSignaturePGP", extraDataPtr );
321 sMemOpen( &stream, extraTrailer, 8 );
322 sputc( &stream, 0x04 );
323 sputc( &stream, 0xFF );
324 status = writeUint32( &stream, extraDataLength -
UINT16_SIZE );
326 extraTrailerLength = stell( &stream );
327 sMemDisconnect( &stream );
330 extraTrailer, extraTrailerLength );
341 zeroise( extraDataPtr, extraDataLength );
342 if( extraDataPtr != extraData )
343 clFree(
"createSignaturePGP", extraDataPtr );
349 &signatureDataLength, iSignContext,
354 pgpSizeofLength( extraDataLength + 2 + \
355 signatureDataLength ) + \
356 extraDataLength + 2 + signatureDataLength;
357 if( totalLength + 64 > sigMaxLength )
362 zeroise( extraDataPtr, extraDataLength );
363 if( extraDataPtr != extraData )
364 clFree(
"createSignaturePGP", extraDataPtr );
377 sMemOpen( &stream, signature, totalLength + 64 );
379 extraDataLength + 2 + signatureDataLength );
380 swrite( &stream, extraData, extraDataLength );
381 swrite( &stream, hash, 2 );
382 status = swrite( &stream, signatureData, signatureDataLength );
384 *signatureLength = stell( &stream );
385 sMemDisconnect( &stream );
386 zeroise( extraDataPtr, extraDataLength );
388 if( extraDataPtr != extraData )
389 clFree(
"createSignaturePGP", extraDataPtr );
397 int checkSignaturePGP(
IN_BUFFER( signatureLength )
const void *signature,
407 assert(
isReadPtr( signature, signatureLength ) );
414 if( readSigFunction == NULL )
419 sMemConnect( &stream, signature, signatureLength );
420 status = readSigFunction( &stream, &queryInfo );
421 sMemDisconnect( &stream );
443 sMemOpen( &stream, buffer, 8 );
444 sputc( &stream, 0x04 );
445 sputc( &stream, 0xFF );
448 length = stell( &stream );
449 sMemDisconnect( &stream );
463 return( checkSignature( signature, signatureLength, sigCheckContext,