Cryptography Reference
In-Depth Information
Next, read the whole payload into memory:
bufptr = buffer = malloc( message_len );
remaining = message_len;
bytes_read = 0;
while ( remaining )
{
if ( ( bytes_read = recv( connection, bufptr,
remaining, 0 ) ) <= 0 )
{
return -1;
}
bufptr += bytes_read;
remaining -= bytes_read;
}
Finally, parse and handle the message. If the HandshakeFinished fl ag hasn't
been set, then this message ought to be a handshake message, and the fi rst byte
should therefore be a handshake message type.
if ( !parameters->handshake_finished )
{
switch ( buffer[ 0 ] )
{
case SSL_MT_ERROR:
status = parse_server_error( parameters, buffer + 1 );
return -1;
case SSL_MT_SERVER_HELLO:
status = parse_server_hello( parameters, buffer + 1 );
if ( status == -1 )
{
send_error( connection,
SSL_PE_UNSUPPORTED_CERTIFICATE_TYPE,
parameters );
}
break;
default:
printf( “Skipping unrecognized handshake message %d\n”,
buffer[ 0 ] );
break;
}
}
The error message format is pretty simple as shown in Listing C-16: It's
a two-byte error code. SSLv2 only defi nes four error codes, so one byte
would have been more than enough, but the Netscape designers were being
forward-thinking.
Search WWH ::




Custom Search