65 SSL_INFO *sslInfo = sessionInfoPtr->sessionSSL;
79 sputc( stream, packetType );
81 sputc( stream, sessionInfoPtr->
version );
82 status = writeUint16( stream, 0 );
93 &msgData, CRYPT_IATTRIBUTE_RANDOM_NONCE );
94 status = swrite( stream, iv, sslInfo->
ivSize );
100 int openPacketStreamSSL(
OUT STREAM *stream,
112 isWritePtr( sessionInfoPtr->sendBuffer, streamSize ) );
116 bufferSize == 0 ) || \
125 sMemOpen( stream, sessionInfoPtr->sendBuffer, streamSize );
126 return( startPacketStream( stream, sessionInfoPtr, packetType ) );
136 const int offset = stell( stream );
141 assert(
isWritePtr( packetOffset,
sizeof(
int ) ) );
150 status = startPacketStream( stream, sessionInfoPtr, packetType );
162 const int packetEndOffset = stell( stream );
172 status = writeUint16( stream, ( packetEndOffset - offset ) - \
174 sseek( stream, packetEndOffset );
190 const int offset = stell( stream );
194 assert(
isWritePtr( packetOffset,
sizeof(
int ) ) );
205 sputc( stream, packetType );
206 status = writeUint24( stream, 0 );
218 const int packetEndOffset = stell( stream );
229 sseek( stream, offset +
ID_SIZE );
230 status = writeUint24( stream, packetEndOffset - \
232 sseek( stream, packetEndOffset );
233 DEBUG_PRINT((
"Wrote %s (%d) handshake packet, length %ld.\n", \
279 SSL_INFO *sslInfo = sessionInfoPtr->sessionSSL;
282 ( offset + sessionInfoPtr->sendBufStartOfs );
283 int bufMaxLen = payloadLength + sMemDataLeft( stream );
285 BYTE *dataPtr, *headerPtr;
294 offset <= stell( stream ) - \
296 sessionInfoPtr->sendBufStartOfs ) );
298 payloadLength < sessionInfoPtr->sendBufSize - \
299 ( sessionInfoPtr->sendBufStartOfs + \
303 status = sMemGetDataBlockAbs( stream, offset, (
void ** ) &headerPtr,
316 status = createMacSSL( sessionInfoPtr, dataPtr, bufMaxLen,
317 &length, payloadLength, *headerPtr );
319 status = createMacTLS( sessionInfoPtr, dataPtr, bufMaxLen,
320 &length, payloadLength, *headerPtr );
336 if( sslInfo->
ivSize > 0 && \
341 dataPtr -= sslInfo->
ivSize;
342 length += sslInfo->
ivSize;
343 bufMaxLen += sslInfo->
ivSize;
344 ENSURES( length > 0 && length <= bufMaxLen )
346 DEBUG_PRINT((
"Wrote %s (%d) packet, length %ld.\n",
372 memcpy( iv, sslInfo->gcmWriteSalt, sslInfo->
gcmSaltSize );
385 length, *headerPtr );
392 status = encryptData( sessionInfoPtr, dataPtr, bufMaxLen, &length,
401 length += sslInfo->
ivSize;
407 sMemOpen( &lengthStream, lengthBuffer,
UINT16_SIZE );
408 status = writeUint16( &lengthStream, length );
409 sMemDisconnect( &lengthStream );
416 return( sSkip( stream, length - ( sslInfo->
ivSize + payloadLength ) ) );
425 const int length = stell( stream );
438 status = completePacketStreamSSL( stream, 0 );
444 status = sMemGetDataBlockAbs( stream, 0, &dataPtr, length );
448 status = swrite( &sessionInfoPtr->stream, dataPtr, length );
451 sNetGetErrorInfo( &sessionInfoPtr->stream,
452 &sessionInfoPtr->errorInfo );
498 status = openPacketStreamSSL( &stream, sessionInfoPtr,
502 sputc( &stream, alertLevel );
503 status = sputc( &stream, alertType );
509 status = wrapPacketSSL( sessionInfoPtr, &stream, 0 );
514 status = completePacketStreamSSL( &stream, 0 );
516 length = stell( &stream );
517 sMemDisconnect( &stream );
526 status = sendCloseNotification( sessionInfoPtr,
527 sessionInfoPtr->sendBuffer, length );
529 status = sendCloseNotification( sessionInfoPtr, NULL, 0 );
536 ( void ) readHSPacketSSL( sessionInfoPtr, NULL, &length,