28 #ifdef CONFIG_SUITEB_TESTS
29 #define clientCertAuthRequired( sessionInfoPtr ) \
30 ( sessionInfoPtr->cryptKeyset != CRYPT_ERROR || suiteBTestClientCert )
32 #define clientCertAuthRequired( sessionInfoPtr ) \
33 ( sessionInfoPtr->cryptKeyset != CRYPT_ERROR )
50 #ifndef CONFIG_SUITEB_TESTS
61 status = readSSLCertChain( sessionInfoPtr, handshakeInfo, stream,
62 &sessionInfoPtr->iKeyexAuthContext,
TRUE );
69 #ifndef CONFIG_SUITEB_TESTS
86 "Client certificate is not trusted for authentication "
100 const int suiteBtype =
\
109 "Client Suite B certificate uses %d-bit key at "
110 "256-bit security level, should use 384-bit key",
121 "Client Suite B certificate uses %d-bit key at "
122 "128-bit security level, should use 256- or "
171 REQUIRES( rsaAvailable || ecdsaAvailable );
174 sputc( stream, ( rsaAvailable ? 1 : 0 ) + \
175 ( dsaAvailable ? 1 : 0 ) + \
176 ( ecdsaAvailable ? 1 : 0 ) );
203 writeUint16( stream, 2 );
204 if( handshakeInfo->keyexSigHashAlgoParam ==
bitsToBytes( 384 ) )
210 writeUint16( stream, ( rsaAvailable ? 2 : 0 ) + \
211 ( ecdsaAvailable ? 2 : 0 ) );
227 writeUint16( stream, 2 );
228 return( swrite( stream,
"\x30\x00", 2 ) );
243 STREAM *stream = &handshakeInfo->stream;
253 status = readHSPacketSSL( sessionInfoPtr, handshakeInfo, &length,
257 sMemConnect( stream, sessionInfoPtr->receiveBuffer, length );
258 status = processHelloSSL( sessionInfoPtr, handshakeInfo, stream,
TRUE );
259 sMemDisconnect( stream );
268 lookupScoreboardEntry( sessionInfoPtr->sessionSSL->scoreboardInfoPtr,
270 handshakeInfo->sessionIDlength,
272 #ifdef CONFIG_SUITEB_TESTS
284 CRYPT_IATTRIBUTE_RANDOM_NONCE );
292 status = attributeCopyParams( handshakeInfo->premasterSecret,
294 &handshakeInfo->premasterSecretSize,
304 &msgData, CRYPT_IATTRIBUTE_RANDOM_NONCE );
307 status = initDHcontextSSL( &handshakeInfo->dhContext, NULL, 0,
310 isEccAlgo( handshakeInfo->keyexAlgo ) ? \
346 sMemDisconnect( stream );
350 sputc( stream, sessionInfoPtr->version );
352 sputc( stream, handshakeInfo->sessionIDlength );
353 swrite( stream, handshakeInfo->sessionID,
354 handshakeInfo->sessionIDlength );
355 writeUint16( stream, handshakeInfo->cipherSuite );
356 status = sputc( stream, 0 );
357 if( handshakeInfo->hasExtensions )
358 status = writeServerExtensions( stream, handshakeInfo );
360 status = completeHSPacketStream( stream, packetOffset );
363 sMemDisconnect( stream );
372 status = completePacketStreamSSL( stream, 0 );
374 status = hashHSPacketWrite( handshakeInfo, stream, 0 );
377 sMemDisconnect( stream );
384 DEBUG_PRINT((
"Resuming session with client based on "
387 handshakeInfo->sessionIDlength );
404 status = writeSSLCertChain( sessionInfoPtr, stream );
407 sMemDisconnect( stream );
449 sMemDisconnect( stream );
459 sMemDisconnect( stream );
462 keyDataOffset = stell( stream );
463 status = exportAttributeToStream( stream, handshakeInfo->dhContext,
464 CRYPT_IATTRIBUTE_KEY_SSL );
467 if(
isEccAlgo( handshakeInfo->keyexAlgo ) )
470 swrite( stream, keyAgreeParams.publicValue,
475 status = writeInteger16U( stream, keyAgreeParams.publicValue,
481 keyDataLength = stell( stream ) - keyDataOffset;
482 status = sMemGetDataBlockAbs( stream, keyDataOffset, &keyData,
487 status = createKeyexSignature( sessionInfoPtr, handshakeInfo,
488 stream, keyData, keyDataLength );
492 status = completeHSPacketStream( stream, packetOffset );
495 sMemDisconnect( stream );
512 if( clientCertAuthRequired( sessionInfoPtr ) )
518 sMemDisconnect( stream );
521 status = writeCertRequest( sessionInfoPtr, handshakeInfo, stream );
523 status = completeHSPacketStream( stream, packetOffset );
526 sMemDisconnect( stream );
537 status = completeHSPacketStream( stream, packetOffset );
540 sMemDisconnect( stream );
547 status = sendPacketSSL( sessionInfoPtr, stream,
FALSE );
549 status = hashHSPacketWrite( handshakeInfo, stream, 0 );
550 sMemDisconnect( stream );
560 STREAM *stream = &handshakeInfo->stream;
568 status = readHSPacketSSL( sessionInfoPtr, handshakeInfo, &length,
572 sMemConnect( stream, sessionInfoPtr->receiveBuffer, length );
573 if( clientCertAuthRequired( sessionInfoPtr ) )
577 status = readCheckClientCerts( sessionInfoPtr, handshakeInfo,
581 sMemDisconnect( stream );
586 status = refreshHSStream( sessionInfoPtr, handshakeInfo );
607 status = checkHSPacketHeader( sessionInfoPtr, stream, &length,
612 sMemDisconnect( stream );
623 status = readEcdhValue( stream, keyAgreeParams.publicValue,
629 status = readInteger16UChecked( stream,
630 keyAgreeParams.publicValue,
636 sMemDisconnect( stream );
645 "Insecure key used in key exchange" ) );
650 "Invalid DH/ECDH phase 2 key agreement data" ) );
660 sMemDisconnect( stream );
663 "Invalid DH/ECDH phase 2 key agreement value" ) );
667 const int xCoordLen = ( keyAgreeParams.
wrappedKeyLen - 1 ) / 2;
682 keyAgreeParams.wrappedKey[ 0 ] == 0x04 );
683 memmove( keyAgreeParams.wrappedKey,
684 keyAgreeParams.wrappedKey + 1, xCoordLen );
689 memcpy( handshakeInfo->premasterSecret, keyAgreeParams.wrappedKey,
691 handshakeInfo->premasterSecretSize = keyAgreeParams.
wrappedKeyLen;
716 length = readUint16( stream );
720 sMemDisconnect( stream );
723 "Invalid client user ID" ) );
726 findSessionInfoEx( sessionInfoPtr->attributeList,
728 if( attributeListPtr == NULL )
730 sMemDisconnect( stream );
733 "Unknown user name '%s'",
740 sessionInfoPtr->attributeListCurrent = \
742 attributeListPtr = attributeListPtr->
next;
743 ENSURES( attributeListPtr != NULL && \
747 status = createSharedPremasterSecret( \
748 handshakeInfo->premasterSecret,
750 &handshakeInfo->premasterSecretSize,
751 attributeListPtr->value,
757 sMemDisconnect( stream );
760 "Couldn't create master secret from shared "
761 "secret/password value" ) );
789 status = readInteger16UChecked( stream, wrappedKey, &length,
795 sMemDisconnect( stream );
804 "Insecure key used in key exchange" ) );
809 "Invalid RSA encrypted key data" ) );
813 status = unwrapPremasterSecret( sessionInfoPtr, handshakeInfo,
814 wrappedKey, length );
817 sMemDisconnect( stream );
825 if( clientCertAuthRequired( sessionInfoPtr ) )
832 status = createCertVerifyHash( sessionInfoPtr, handshakeInfo );
837 status = refreshHSStream( sessionInfoPtr, handshakeInfo );
846 status = checkHSPacketHeader( sessionInfoPtr, stream, &length,
851 status = checkCertVerify( sessionInfoPtr, handshakeInfo, stream,
855 sMemDisconnect( stream );
859 sMemDisconnect( stream );
875 handshakeInfo->beginHandshake = beginServerHandshake;
876 handshakeInfo->exchangeKeys = exchangeServerKeys;