036-evp_leak.patch revision 4820
2733N/APatch developed in-house. Solaris-specific; not suitable for upstream.
2733N/A
4002N/A--- openssl-1.0.1f/crypto/evp/evp_enc.c.orig Mon Feb 11 07:26:04 2013
4002N/A+++ openssl-1.0.1f/crypto/evp/evp_enc.c Mon Feb 3 16:40:48 2014
4820N/A@@ -392,11 +392,13 @@
4002N/A
4002N/A if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
4002N/A ret = M_do_cipher(ctx, out, NULL, 0);
4002N/A- if (ret < 0)
4002N/A- return 0;
4002N/A- else
4002N/A+ if (ret < 0) {
4002N/A+ ret = 0;
4002N/A+ goto cleanup;
4002N/A+ } else
4002N/A *outl = ret;
4002N/A- return 1;
4002N/A+ ret = 1;
4002N/A+ goto cleanup;
4002N/A }
4002N/A
4002N/A b = ctx->cipher->block_size;
4820N/A@@ -403,7 +405,8 @@
4002N/A OPENSSL_assert(b <= sizeof ctx->buf);
4002N/A if (b == 1) {
4002N/A *outl = 0;
4002N/A- return 1;
4002N/A+ ret = 1;
4002N/A+ goto cleanup;
4002N/A }
4002N/A bl = ctx->buf_len;
4002N/A if (ctx->flags & EVP_CIPH_NO_PADDING) {
4820N/A@@ -410,10 +413,12 @@
4002N/A if (bl) {
4002N/A EVPerr(EVP_F_EVP_ENCRYPTFINAL_EX,
4002N/A EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH);
4002N/A- return 0;
4002N/A+ ret = 0;
4002N/A+ goto cleanup;
4002N/A }
4002N/A *outl = 0;
4002N/A- return 1;
4002N/A+ ret = 1;
4002N/A+ goto cleanup;
4002N/A }
2733N/A
4002N/A n = b - bl;
4820N/A@@ -424,6 +429,11 @@
4002N/A if (ret)
4002N/A *outl = b;
2733N/A
2733N/A+cleanup:
4002N/A+ if (ctx->cipher->cleanup) {
4002N/A+ ctx->cipher->cleanup(ctx);
4002N/A+ }
2733N/A+
4002N/A return ret;
4002N/A }
2733N/A
4820N/A@@ -491,6 +501,7 @@
4002N/A int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
4002N/A {
4002N/A int i, n;
4002N/A+ int err = 1;
4002N/A unsigned int b;
4002N/A *outl = 0;
2733N/A
4820N/A@@ -496,11 +507,13 @@
4002N/A
4002N/A if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
4002N/A i = M_do_cipher(ctx, out, NULL, 0);
4002N/A- if (i < 0)
4002N/A- return 0;
4002N/A- else
4002N/A+ if (i < 0) {
4002N/A+ err = 0;
4002N/A+ goto cleanup;
4002N/A+ } else
4002N/A *outl = i;
4002N/A- return 1;
4002N/A+ err = 1;
4002N/A+ goto cleanup;
4002N/A }
4002N/A
4002N/A b = ctx->cipher->block_size;
4820N/A@@ -508,10 +521,12 @@
4002N/A if (ctx->buf_len) {
4002N/A EVPerr(EVP_F_EVP_DECRYPTFINAL_EX,
4002N/A EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH);
4002N/A- return 0;
4002N/A+ err = 0;
4002N/A+ goto cleanup;
4002N/A }
4002N/A *outl = 0;
4002N/A- return 1;
4002N/A+ err = 1;
4002N/A+ goto cleanup;
4002N/A }
4002N/A if (b > 1) {
4002N/A if (ctx->buf_len || !ctx->final_used) {
4820N/A@@ -516,7 +531,8 @@
4002N/A if (b > 1) {
4002N/A if (ctx->buf_len || !ctx->final_used) {
4002N/A EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_WRONG_FINAL_BLOCK_LENGTH);
4002N/A- return (0);
4002N/A+ err = 0;
4002N/A+ goto cleanup;
4002N/A }
4002N/A OPENSSL_assert(b <= sizeof ctx->final);
3621N/A
4820N/A@@ -527,7 +543,8 @@
4002N/A n = ctx->final[b - 1];
4002N/A if (n == 0 || n > (int)b) {
4002N/A EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_BAD_DECRYPT);
4002N/A- return (0);
4002N/A+ err = 0;
4002N/A+ goto cleanup;
4002N/A }
4002N/A for (i = 0; i < n; i++) {
4002N/A if (ctx->final[--b] != n) {
4820N/A@@ -532,7 +549,8 @@
4002N/A for (i = 0; i < n; i++) {
4002N/A if (ctx->final[--b] != n) {
4002N/A EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_BAD_DECRYPT);
4002N/A- return (0);
4002N/A+ err = 0;
4002N/A+ goto cleanup;
4002N/A }
4002N/A }
4002N/A n = ctx->cipher->block_size - n;
4820N/A@@ -541,7 +559,12 @@
4002N/A *outl = n;
4002N/A } else
4002N/A *outl = 0;
4002N/A- return (1);
4002N/A+ err = 1;
2733N/A+cleanup:
4002N/A+ if (ctx->cipher->cleanup) {
4002N/A+ ctx->cipher->cleanup(ctx);
4002N/A+ }
4002N/A+ return err;
4002N/A }
2733N/A
2733N/A void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)