54 sMemOpen( &stream, buffer, 8 );
55 status = writeSequence( &stream, length );
92 assert(
isReadPtr( password, passwordLength ) );
133 IN_BUFFER( passwordLength )
const void *password,
145 assert(
isReadPtr( password, passwordLength ) );
151 readSequence( stream, NULL );
161 ( status, errorInfo,
"Unrecognised passwod-based MAC "
170 readSequence( stream, NULL );
186 "Invalid passwod-based MAC algorithm information" ) );
198 "Invalid passwod-based MAC iteration count %ld",
201 iterations = ( int ) value;
205 if( protocolInfo->saltSize <= 0 )
207 status = initMacInfo( protocolInfo->iMacContext, password,
208 passwordLength, salt, saltLength, iterations );
213 "Couldn't initialise passwod-based MAC "
217 memcpy( protocolInfo->salt, salt, saltLength );
220 DEBUG_PRINT((
"%s: Read initial MAC params with salt, %d iterations.\n",
221 protocolInfo->isServer ?
"SVR" :
"CLI",
222 protocolInfo->iterations ));
224 protocolInfo->salt, protocolInfo->saltSize );
234 if( protocolInfo->iterations && \
235 saltLength == protocolInfo->saltSize && \
236 !memcmp( salt, protocolInfo->salt, saltLength ) && \
237 iterations == protocolInfo->iterations )
239 DEBUG_PRINT((
"%s: Skipped repeated MAC params with salt, "
241 protocolInfo->isServer ?
"SVR" :
"CLI",
242 protocolInfo->iterations ));
244 protocolInfo->salt, protocolInfo->saltSize );
254 status = initMacInfo( createInfo.
cryptHandle, password, passwordLength,
255 salt, saltLength, iterations );
261 "Couldn't initialise passwod-based MAC information" ) );
266 protocolInfo->iMacContext = createInfo.
cryptHandle;
270 memcpy( protocolInfo->salt, salt, saltLength );
273 DEBUG_PRINT((
"%s: Read new MAC params with salt, %d iterations.\n",
274 protocolInfo->isServer ?
"SVR" :
"CLI",
275 protocolInfo->iterations ));
277 protocolInfo->salt, protocolInfo->saltSize );
302 paramSize = ( int ) sizeofObject( protocolInfo->
saltSize ) + \
304 sizeofShortInteger( protocolInfo->
iterations ) + \
309 (
int ) sizeofObject( paramSize ) );
313 DEBUG_PRINT((
"%s: Writing MAC params with salt, %d iterations.\n",
314 protocolInfo->
isServer ?
"SVR" :
"CLI",
317 protocolInfo->salt, protocolInfo->
saltSize );
318 writeSequence( stream, paramSize );
319 writeOctetString( stream, protocolInfo->salt, protocolInfo->
saltSize,
342 int macValueLength,
status;
346 assert(
isReadPtr( message, messageLength ) );
351 status = readBitStringHole( stream, &macValueLength, 16,
DEFAULT_TAG );
356 status = sread( stream, macValue, macValueLength );
362 status = hashMessageContents( protocolInfo->iMacContext, message,
377 IN_BUFFER( messageLength )
const void *message,
388 assert(
isReadPtr( message, messageLength ) );
389 assert(
isReadPtr( signature, signatureLength ) );
405 if( !protocolInfo->isCryptlib )
410 protocolInfo->senderDNlength );
430 if( protocolInfo->hashParam != 0 )
436 &protocolInfo->hashParam,
441 status = hashMessageContents( iHashContext, message, messageLength );
444 status = checkRawSignature( signature, signatureLength,
445 iAuthContext, iHashContext );
461 IN_BUFFER( messageLength )
const void *message,
470 BYTE macValue[ CRYPT_MAX_HASHSIZE + 8 ];
473 assert(
isReadPtr( message, messageLength ) );
474 assert(
isWritePtr( protInfo, protInfoMaxLength ) );
475 assert(
isWritePtr( protInfoLength,
sizeof(
int ) ) );
479 REQUIRES( protInfoMaxLength >= 16 && \
483 memset( protInfo, 0,
min( 16, protInfoMaxLength ) );
487 status = hashMessageContents( iMacContext, message, messageLength );
495 macLength = msgData.
length;
498 sMemOpen( &macStream, protInfo, protInfoMaxLength );
499 writeBitStringHole( &macStream, macLength,
DEFAULT_TAG );
500 status = swrite( &macStream, macValue, macLength );
502 *protInfoLength = stell( &macStream );
503 sMemDisconnect( &macStream );
512 IN_BUFFER( messageLength )
const void *message,
514 OUT_BUFFER( protInfoMaxLength, *protInfoLength ) \
523 assert(
isReadPtr( message, messageLength ) );
524 assert(
isWritePtr( protInfo, protInfoMaxLength ) );
525 assert(
isWritePtr( protInfoLength,
sizeof(
int ) ) );
529 REQUIRES( hashParam >= 0 && hashParam <= 999 );
531 REQUIRES( protInfoMaxLength >= 32 && \
552 status = hashMessageContents( iHashContext, message, messageLength );
560 status = createRawSignature( protInfo, protInfoMaxLength,
561 protInfoLength, iSignContext,