Extend DTLS method macros.
[openssl.git] / ssl / d1_pkt.c
index 0ad8b5f5590e4936134e28135d4dede948ac8238..b7ff9a8705f1c1cb092d2030ed390c0bad4352a9 100644 (file)
@@ -379,7 +379,7 @@ dtls1_process_record(SSL *s)
        int enc_err;
        SSL_SESSION *sess;
        SSL3_RECORD *rr;
-       unsigned int mac_size, orig_len;
+       unsigned int mac_size;
        unsigned char md[EVP_MAX_MD_SIZE];
 
        rr= &(s->s3->rrec);
@@ -410,7 +410,7 @@ dtls1_process_record(SSL *s)
 
        /* decrypt in place in 'rr->input' */
        rr->data=rr->input;
-       orig_len=rr->length;
+       rr->orig_len=rr->length;
 
        enc_err = s->method->ssl3_enc->enc(s,0);
        /* enc_err is:
@@ -447,13 +447,13 @@ printf("\n");
                 * therefore we can safely process the record in a different
                 * amount of time if it's too short to possibly contain a MAC.
                 */
-               if (orig_len < mac_size ||
+               if (rr->orig_len < mac_size ||
                    /* CBC records must have a padding length byte too. */
                    (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
-                    orig_len < mac_size+1))
+                    rr->orig_len < mac_size+1))
                        {
                        al=SSL_AD_DECODE_ERROR;
-                       SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);
+                       SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT);
                        goto f_err;
                        }
 
@@ -465,12 +465,12 @@ printf("\n");
                         * without leaking the contents of the padding bytes.
                         * */
                        mac = mac_tmp;
-                       ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len);
+                       ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);
                        rr->length -= mac_size;
                        }
                else
                        {
-                       /* In this case there's no padding, so |orig_len|
+                       /* In this case there's no padding, so |rec->orig_len|
                         * equals |rec->length| and we checked that there's
                         * enough bytes for |mac_size| above. */
                        rr->length -= mac_size;
@@ -587,6 +587,9 @@ again:
 
                p=s->packet;
 
+               if (s->msg_callback)
+                       s->msg_callback(0, 0, SSL3_RT_HEADER, p, DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);
+
                /* Pull apart the header into the DTLS1_RECORD */
                rr->type= *(p++);
                ssl_major= *(p++);
@@ -1627,6 +1630,9 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len,
        pseq+=6;
        s2n(wr->length,pseq);
 
+       if (s->msg_callback)
+               s->msg_callback(1, 0, SSL3_RT_HEADER, pseq - DTLS1_RT_HEADER_LENGTH, DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);
+
        /* we should now have
         * wr->data pointing to the encrypted data, which is
         * wr->length long */