ssl/*: remove SSL3_RECORD->orig_len to restore binary compatibility.
[openssl.git] / ssl / t1_enc.c
index 4b31742783d6d60308d8c52281b06bf9e5a6768b..4e23bbf77b4e26c56ccd3d3a14aad3817cc738bb 100644 (file)
@@ -849,11 +849,7 @@ int tls1_enc(SSL *s, int send)
                if (!send)
                        {
                        if (l == 0 || l%bs != 0)
-                               {
-                               SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
-                               ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
                                return 0;
-                               }
                        }
                
                i = EVP_Cipher(ds,rec->data,rec->input,l);
@@ -977,7 +973,7 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
        SSL3_RECORD *rec;
        unsigned char *seq;
        EVP_MD_CTX *hash;
-       size_t md_size;
+       size_t md_size, orig_len;
        int i;
        EVP_MD_CTX hmac, *mac_ctx;
        unsigned char header[13];
@@ -1024,6 +1020,10 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
        else
                memcpy(header, seq, 8);
 
+       /* kludge: tls1_cbc_remove_padding passes padding length in rec->type */
+       orig_len = rec->length+md_size+((unsigned int)rec->type>>8);
+       rec->type &= 0xff;
+
        header[8]=rec->type;
        header[9]=(unsigned char)(ssl->version>>8);
        header[10]=(unsigned char)(ssl->version);
@@ -1042,7 +1042,7 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
                        mac_ctx,
                        md, &md_size,
                        header, rec->input,
-                       rec->length + md_size, rec->orig_len,
+                       rec->length + md_size, orig_len,
                        ssl->s3->read_mac_secret,
                        ssl->s3->read_mac_secret_size,
                        0 /* not SSLv3 */);
@@ -1053,6 +1053,13 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
                EVP_DigestSignUpdate(mac_ctx,rec->input,rec->length);
                t=EVP_DigestSignFinal(mac_ctx,md,&md_size);
                OPENSSL_assert(t > 0);
+#ifdef OPENSSL_FIPS
+               if (!send && FIPS_mode())
+                       tls_fips_digest_extra(
+                                       ssl->enc_read_ctx,
+                                       mac_ctx, rec->input,
+                                       rec->length, orig_len);
+#endif
                }
                
        if (!stream_mac)