19 #define CMS_KEYBLOCK_HEADERSIZE 4
33 const int payloadSize,
38 assert(
isWritePtr( padSize,
sizeof(
int ) ) );
56 totalSize =
roundUp( payloadSize, blockSize );
57 if( totalSize < blockSize * 2 )
58 totalSize = blockSize * 2;
59 ENSURES( !( totalSize & ( blockSize - 1 ) ) );
60 *padSize = totalSize - payloadSize;
78 BYTE *keyBlockPtr = (
BYTE * ) mechanismInfo->wrappedData;
79 BYTE dataSample[ 16 + 8 ];
86 if( mechanismInfo->wrappedData != NULL )
88 memset( mechanismInfo->wrappedData, 0,
89 mechanismInfo->wrappedDataLength );
98 status = getPadSize( mechanismInfo->wrapContext,
105 if( mechanismInfo->wrappedData == NULL )
107 mechanismInfo->wrappedDataLength = \
108 CMS_KEYBLOCK_HEADERSIZE + keySize + padSize;
111 ANALYSER_HINT( mechanismInfo->wrappedDataLength > ( 2 * 8 ) && \
116 keySize + padSize > mechanismInfo->wrappedDataLength )
127 CRYPT_IATTRIBUTE_RANDOM_NONCE );
144 status = extractKeyData( mechanismInfo->keyContext,
146 keySize,
"keydata", 7 );
150 memcpy( dataSample, keyBlockPtr, 16 );
155 mechanismInfo->wrappedData,
163 mechanismInfo->wrappedData,
179 zeroise( mechanismInfo->wrappedData,
180 mechanismInfo->wrappedDataLength );
198 BYTE *dataEndPtr = buffer + mechanismInfo->wrappedDataLength;
211 if( mechanismInfo->wrappedDataLength & ( blockSize - 1 ) )
213 if( mechanismInfo->wrappedDataLength < 2 * blockSize )
239 memcpy( buffer, mechanismInfo->wrappedData,
240 mechanismInfo->wrappedDataLength );
241 setMessageData( &msgData, dataEndPtr - ( 2 * blockSize ), blockSize );
249 dataEndPtr - blockSize, blockSize );
262 mechanismInfo->wrappedDataLength - blockSize );
279 mechanismInfo->wrappedDataLength );
308 ( buffer[ 0 ] > mechanismInfo->wrappedDataLength - \
309 CMS_KEYBLOCK_HEADERSIZE );