* [including the GNU Public Licence.]
*/
+#include <string.h>
#include <stdio.h>
#include <openssl/buffer.h>
#include <openssl/rand.h>
#include <openssl/x509.h>
#include "ssl_locl.h"
-int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender,
- int slen)
+int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen)
{
unsigned char *p,*d;
int i;
i=s->method->ssl3_enc->final_finish_mac(s,
&(s->s3->finish_dgst1),
&(s->s3->finish_dgst2),
- sender,slen,p);
+ sender,slen,s->s3->tmp.finish_md);
+ s->s3->tmp.finish_md_len = i;
+ memcpy(p, s->s3->tmp.finish_md, i);
p+=i;
l=i;
unsigned char *p;
/* the mac has already been generated when we received the
- * change cipher spec message and is in s->s3->tmp.in_dgst[12]
+ * change cipher spec message and is in s->s3->tmp.peer_finish_md
*/
n=ssl3_get_message(s,
}
s->s3->change_cipher_spec=0;
- p=(unsigned char *)s->init_buf->data;
-
- i=s->method->ssl3_enc->finish_mac_length;
+ p = (unsigned char *)s->init_buf->data;
+ i = s->s3->tmp.peer_finish_md_len;
if (i != n)
{
goto f_err;
}
- if (memcmp( p, (char *)&(s->s3->tmp.finish_md[0]),i) != 0)
+ if (memcmp(p, s->s3->tmp.peer_finish_md, i) != 0)
{
al=SSL_AD_DECRYPT_ERROR;
SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED);
return(l);
}
+/* Obtain handshake message of message type 'mt' (any if mt == -1),
+ * maximum acceptable body length 'max'.
+ * The first four bytes (msg_type and length) are read in state 'st1',
+ * the body is read in state 'stn'.
+ */
long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
{
unsigned char *p;
SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE);
goto f_err;
}
+ if((mt < 0) && (*p == SSL3_MT_CLIENT_HELLO) &&
+ (st1 == SSL3_ST_SR_CERT_A) &&
+ (stn == SSL3_ST_SR_CERT_B))
+ {
+ /* At this point we have got an MS SGC second client
+ * hello. We need to restart the mac and mac the data
+ * currently received.
+ */
+ ssl3_init_finished_mac(s);
+ ssl3_finish_mac(s, p + s->init_num, i);
+ }
+
s->s3->tmp.message_type= *(p++);
n2l3(p,l);