79 sizeofObject( essCertIDSize ) ) );
88 int essCertIDSize, payloadSize,
status;
100 essCertIDSize = ( int ) sizeofObject( msgData.
length );
105 (
int ) sizeofObject( payloadSize ) );
107 writeSet( stream, payloadSize );
109 writeSequence( stream,
objSize( essCertIDSize ) );
110 writeSequence( stream, essCertIDSize );
111 return( writeOctetString( stream, certHash, msgData.
length,
124 const BOOLEAN isInitialClientMessage,
125 const BOOLEAN isClientCryptOnlyKey )
133 assert(
isWritePtr( senderNameLength,
sizeof(
int ) ) );
134 assert(
isWritePtr( recipNameLength,
sizeof(
int ) ) );
137 *senderNameObject = *recipNameObject =
CRYPT_ERROR;
138 *senderNameLength = *recipNameLength = 0;
144 *senderNameObject = sessionInfoPtr->privateKey;
145 *recipNameObject = sessionInfoPtr->iCertResponse;
149 *senderNameObject = isClientCryptOnlyKey ?
\
152 *recipNameObject = sessionInfoPtr->iAuthInContext;
158 &msgData, CRYPT_IATTRIBUTE_SUBJECT );
171 msgData.
length = ( int ) sizeofObject( 0 );
178 *senderNameObject = sessionInfoPtr->iCertResponse;
181 CRYPT_IATTRIBUTE_SUBJECT );
186 *senderNameLength = msgData.
length;
193 &msgData, CRYPT_IATTRIBUTE_SUBJECT );
205 msgData.
length = ( int ) sizeofObject( 0 );
209 *recipNameLength = msgData.
length;
253 #ifdef USE_FULL_HEADERS
293 !protocolInfo->useMACsend ) )
297 #ifndef USE_FULL_HEADERS
298 if( !protocolInfo->isCryptlib && \
300 sendFullHeader =
TRUE;
302 if( protocolInfo->useMACsend && \
303 !( protocolInfo->isCryptlib && \
306 if( ( sendFullHeader || \
308 ( protocolInfo->userIDsize > 0 ) )
311 REQUIRES( !sendFullHeader || !protocolInfo->headerRead || \
312 ( protocolInfo->userIDsize > 0 && \
314 REQUIRES( protocolInfo->transIDsize > 0 && \
331 status = initDNInfo( sessionInfoPtr, &senderNameObject,
332 &recipNameObject, &senderNameLength,
336 protocolInfo->cryptOnlyKey );
345 senderNameLength = recipNameLength = sizeofObject( 0 );
349 sMemNullOpen( &nullStream );
350 if( protocolInfo->useMACsend )
352 status = writeMacInfo( &nullStream, protocolInfo, sendMacInfo );
356 status = writeContextAlgoID( &nullStream, protocolInfo->authContext,
357 protocolInfo->hashAlgo );
360 protInfoLength = stell( &nullStream );
361 sMemClose( &nullStream );
366 attributeLength += sizeofObject( \
372 const int certIDsize = sizeofCertID( protocolInfo->authContext );
376 attributeLength += certIDsize;
379 objSize( senderNameLength ) +
objSize( recipNameLength ) + \
380 objSize( protInfoLength ) + \
381 objSize( sizeofObject( protocolInfo->transIDsize ) );
383 totalLength +=
objSize( sizeofObject( protocolInfo->userIDsize ) );
386 if( protocolInfo->senderNonceSize > 0 )
388 sizeofObject( protocolInfo->senderNonceSize ) );
389 if( protocolInfo->recipNonceSize > 0 )
391 sizeofObject( protocolInfo->recipNonceSize ) );
393 if( attributeLength > 0 )
398 if( sizeofObject( totalLength ) <= 0 || \
399 sizeofObject( totalLength ) > sMemDataLeft( stream ) )
404 writeSequence( stream, totalLength );
408 writeConstructed( stream, senderNameLength, 4 );
411 status = exportAttributeToStream( stream, senderNameObject,
412 CRYPT_IATTRIBUTE_SUBJECT );
417 writeSequence( stream, 0 );
418 writeConstructed( stream, recipNameLength, 4 );
421 status = exportAttributeToStream( stream, recipNameObject,
422 CRYPT_IATTRIBUTE_SUBJECT );
425 status = writeSequence( stream, 0 );
433 writeConstructed( stream, senderNameLength, 4 );
434 writeSequence( stream, 0 );
435 writeConstructed( stream, recipNameLength, 4 );
436 status = writeSequence( stream, 0 );
444 if( protocolInfo->useMACsend )
446 status = writeMacInfo( stream, protocolInfo, sendMacInfo );
451 status = writeContextAlgoID( stream, protocolInfo->authContext,
452 protocolInfo->hashAlgo );
460 writeConstructed( stream,
objSize( protocolInfo->userIDsize ),
462 writeOctetString( stream, protocolInfo->userID,
465 protocolInfo->isServer ?
"SVR" :
"CLI" ));
467 protocolInfo->userID, protocolInfo->userIDsize );
470 writeConstructed( stream,
objSize( protocolInfo->transIDsize ),
472 status = writeOctetString( stream, protocolInfo->transID,
478 if( protocolInfo->senderNonceSize > 0 )
484 protocolInfo->senderNonceSize );
486 &msgData, CRYPT_IATTRIBUTE_RANDOM_NONCE );
487 writeConstructed( stream,
488 objSize( protocolInfo->senderNonceSize ),
490 status = writeOctetString( stream, protocolInfo->senderNonce,
491 protocolInfo->senderNonceSize,
494 if( protocolInfo->recipNonceSize > 0 )
496 writeConstructed( stream,
497 objSize( protocolInfo->recipNonceSize ),
499 status = writeOctetString( stream, protocolInfo->recipNonce,
500 protocolInfo->recipNonceSize,
506 if( attributeLength > 0 )
508 ENSURES( sendClibID || sendCertID );
513 writeConstructed( stream,
objSize( attributeLength ),
515 writeSequence( stream, attributeLength );
522 status = writeSet( stream, 0 );
527 status = writeCertID( stream, protocolInfo->authContext );
552 WRITEMESSAGE_FUNCTION writeMessageFunction;
562 DEBUG_PRINT((
"%s: Writing message body type %d.\n",
563 protocolInfo->isServer ?
"SVR" :
"CLI", bodyType ));
566 sMemOpen( &stream, sessionInfoPtr->receiveBuffer,
567 sessionInfoPtr->receiveBufSize );
568 status = writePkiHeader( &stream, sessionInfoPtr, protocolInfo );
571 sMemClose( &stream );
578 ENSURES( writeMessageFunction != NULL );
579 status = writeMessageFunction( &stream, sessionInfoPtr, protocolInfo );
582 sMemClose( &stream );
587 if( protocolInfo->useMACsend )
589 status = writeMacProtinfo( protocolInfo->iMacContext,
590 sessionInfoPtr->receiveBuffer, stell( &stream ),
595 status = writeSignedProtinfo( protocolInfo->authContext,
596 protocolInfo->hashAlgo, protocolInfo->hashParam,
597 sessionInfoPtr->receiveBuffer, stell( &stream ),
602 sMemClose( &stream );
608 status = swrite( &stream, protInfo, protInfoSize );
610 sessionInfoPtr->receiveBufEnd = stell( &stream );
611 sMemDisconnect( &stream );
630 sMemOpen( &stream, headerBuffer, 8 );
631 status = writeSequence( &stream, sessionInfoPtr->receiveBufEnd );
633 headerSize = stell( &stream );
634 sMemDisconnect( &stream );
637 sessionInfoPtr->receiveBufSize ) );
638 memmove( sessionInfoPtr->receiveBuffer + headerSize,
639 sessionInfoPtr->receiveBuffer,
640 sessionInfoPtr->receiveBufEnd );
641 memcpy( sessionInfoPtr->receiveBuffer, headerBuffer, headerSize );
642 sessionInfoPtr->receiveBufEnd += headerSize;