Skip to content

Valgrind reports Conditional jump or move depends on uninitialised value when using EVP_OpenInit/Update/Final #8460

Closed

Description

@Romain-Geissler-1A

Hi,

I would like to report a problem we have both in branch 1.0.2 and 1.1.1 with the latest release. All my examples are run with release 1.1.1b but applies to other branches too.

I manage to reproduce the valgrind issue by adapting the test test/evp_extra_test.c. The test that matters is test_EVP_Enveloped. I attach here the content of the modified file:

/*
 * Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/kdf.h>
#include "testutil.h"

/*
 * kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you
 * should never use this key anywhere but in an example.
 */
static const unsigned char kExampleRSAKeyDER[] = {
    0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xf8,
    0xb8, 0x6c, 0x83, 0xb4, 0xbc, 0xd9, 0xa8, 0x57, 0xc0, 0xa5, 0xb4, 0x59,
    0x76, 0x8c, 0x54, 0x1d, 0x79, 0xeb, 0x22, 0x52, 0x04, 0x7e, 0xd3, 0x37,
    0xeb, 0x41, 0xfd, 0x83, 0xf9, 0xf0, 0xa6, 0x85, 0x15, 0x34, 0x75, 0x71,
    0x5a, 0x84, 0xa8, 0x3c, 0xd2, 0xef, 0x5a, 0x4e, 0xd3, 0xde, 0x97, 0x8a,
    0xdd, 0xff, 0xbb, 0xcf, 0x0a, 0xaa, 0x86, 0x92, 0xbe, 0xb8, 0x50, 0xe4,
    0xcd, 0x6f, 0x80, 0x33, 0x30, 0x76, 0x13, 0x8f, 0xca, 0x7b, 0xdc, 0xec,
    0x5a, 0xca, 0x63, 0xc7, 0x03, 0x25, 0xef, 0xa8, 0x8a, 0x83, 0x58, 0x76,
    0x20, 0xfa, 0x16, 0x77, 0xd7, 0x79, 0x92, 0x63, 0x01, 0x48, 0x1a, 0xd8,
    0x7b, 0x67, 0xf1, 0x52, 0x55, 0x49, 0x4e, 0xd6, 0x6e, 0x4a, 0x5c, 0xd7,
    0x7a, 0x37, 0x36, 0x0c, 0xde, 0xdd, 0x8f, 0x44, 0xe8, 0xc2, 0xa7, 0x2c,
    0x2b, 0xb5, 0xaf, 0x64, 0x4b, 0x61, 0x07, 0x02, 0x03, 0x01, 0x00, 0x01,
    0x02, 0x81, 0x80, 0x74, 0x88, 0x64, 0x3f, 0x69, 0x45, 0x3a, 0x6d, 0xc7,
    0x7f, 0xb9, 0xa3, 0xc0, 0x6e, 0xec, 0xdc, 0xd4, 0x5a, 0xb5, 0x32, 0x85,
    0x5f, 0x19, 0xd4, 0xf8, 0xd4, 0x3f, 0x3c, 0xfa, 0xc2, 0xf6, 0x5f, 0xee,
    0xe6, 0xba, 0x87, 0x74, 0x2e, 0xc7, 0x0c, 0xd4, 0x42, 0xb8, 0x66, 0x85,
    0x9c, 0x7b, 0x24, 0x61, 0xaa, 0x16, 0x11, 0xf6, 0xb5, 0xb6, 0xa4, 0x0a,
    0xc9, 0x55, 0x2e, 0x81, 0xa5, 0x47, 0x61, 0xcb, 0x25, 0x8f, 0xc2, 0x15,
    0x7b, 0x0e, 0x7c, 0x36, 0x9f, 0x3a, 0xda, 0x58, 0x86, 0x1c, 0x5b, 0x83,
    0x79, 0xe6, 0x2b, 0xcc, 0xe6, 0xfa, 0x2c, 0x61, 0xf2, 0x78, 0x80, 0x1b,
    0xe2, 0xf3, 0x9d, 0x39, 0x2b, 0x65, 0x57, 0x91, 0x3d, 0x71, 0x99, 0x73,
    0xa5, 0xc2, 0x79, 0x20, 0x8c, 0x07, 0x4f, 0xe5, 0xb4, 0x60, 0x1f, 0x99,
    0xa2, 0xb1, 0x4f, 0x0c, 0xef, 0xbc, 0x59, 0x53, 0x00, 0x7d, 0xb1, 0x02,
    0x41, 0x00, 0xfc, 0x7e, 0x23, 0x65, 0x70, 0xf8, 0xce, 0xd3, 0x40, 0x41,
    0x80, 0x6a, 0x1d, 0x01, 0xd6, 0x01, 0xff, 0xb6, 0x1b, 0x3d, 0x3d, 0x59,
    0x09, 0x33, 0x79, 0xc0, 0x4f, 0xde, 0x96, 0x27, 0x4b, 0x18, 0xc6, 0xd9,
    0x78, 0xf1, 0xf4, 0x35, 0x46, 0xe9, 0x7c, 0x42, 0x7a, 0x5d, 0x9f, 0xef,
    0x54, 0xb8, 0xf7, 0x9f, 0xc4, 0x33, 0x6c, 0xf3, 0x8c, 0x32, 0x46, 0x87,
    0x67, 0x30, 0x7b, 0xa7, 0xac, 0xe3, 0x02, 0x41, 0x00, 0xfc, 0x2c, 0xdf,
    0x0c, 0x0d, 0x88, 0xf5, 0xb1, 0x92, 0xa8, 0x93, 0x47, 0x63, 0x55, 0xf5,
    0xca, 0x58, 0x43, 0xba, 0x1c, 0xe5, 0x9e, 0xb6, 0x95, 0x05, 0xcd, 0xb5,
    0x82, 0xdf, 0xeb, 0x04, 0x53, 0x9d, 0xbd, 0xc2, 0x38, 0x16, 0xb3, 0x62,
    0xdd, 0xa1, 0x46, 0xdb, 0x6d, 0x97, 0x93, 0x9f, 0x8a, 0xc3, 0x9b, 0x64,
    0x7e, 0x42, 0xe3, 0x32, 0x57, 0x19, 0x1b, 0xd5, 0x6e, 0x85, 0xfa, 0xb8,
    0x8d, 0x02, 0x41, 0x00, 0xbc, 0x3d, 0xde, 0x6d, 0xd6, 0x97, 0xe8, 0xba,
    0x9e, 0x81, 0x37, 0x17, 0xe5, 0xa0, 0x64, 0xc9, 0x00, 0xb7, 0xe7, 0xfe,
    0xf4, 0x29, 0xd9, 0x2e, 0x43, 0x6b, 0x19, 0x20, 0xbd, 0x99, 0x75, 0xe7,
    0x76, 0xf8, 0xd3, 0xae, 0xaf, 0x7e, 0xb8, 0xeb, 0x81, 0xf4, 0x9d, 0xfe,
    0x07, 0x2b, 0x0b, 0x63, 0x0b, 0x5a, 0x55, 0x90, 0x71, 0x7d, 0xf1, 0xdb,
    0xd9, 0xb1, 0x41, 0x41, 0x68, 0x2f, 0x4e, 0x39, 0x02, 0x40, 0x5a, 0x34,
    0x66, 0xd8, 0xf5, 0xe2, 0x7f, 0x18, 0xb5, 0x00, 0x6e, 0x26, 0x84, 0x27,
    0x14, 0x93, 0xfb, 0xfc, 0xc6, 0x0f, 0x5e, 0x27, 0xe6, 0xe1, 0xe9, 0xc0,
    0x8a, 0xe4, 0x34, 0xda, 0xe9, 0xa2, 0x4b, 0x73, 0xbc, 0x8c, 0xb9, 0xba,
    0x13, 0x6c, 0x7a, 0x2b, 0x51, 0x84, 0xa3, 0x4a, 0xe0, 0x30, 0x10, 0x06,
    0x7e, 0xed, 0x17, 0x5a, 0x14, 0x00, 0xc9, 0xef, 0x85, 0xea, 0x52, 0x2c,
    0xbc, 0x65, 0x02, 0x40, 0x51, 0xe3, 0xf2, 0x83, 0x19, 0x9b, 0xc4, 0x1e,
    0x2f, 0x50, 0x3d, 0xdf, 0x5a, 0xa2, 0x18, 0xca, 0x5f, 0x2e, 0x49, 0xaf,
    0x6f, 0xcc, 0xfa, 0x65, 0x77, 0x94, 0xb5, 0xa1, 0x0a, 0xa9, 0xd1, 0x8a,
    0x39, 0x37, 0xf4, 0x0b, 0xa0, 0xd7, 0x82, 0x27, 0x5e, 0xae, 0x17, 0x17,
    0xa1, 0x1e, 0x54, 0x34, 0xbf, 0x6e, 0xc4, 0x8e, 0x99, 0x5d, 0x08, 0xf1,
    0x2d, 0x86, 0x9d, 0xa5, 0x20, 0x1b, 0xe5, 0xdf,
};

/*
 * kExampleBadRSAKeyDER is an RSA private key in ASN.1, DER format. The private
 * components are not correct.
 */
static const unsigned char kExampleBadRSAKeyDER[] = {
    0x30, 0x82, 0x04, 0x27, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
    0xa6, 0x1a, 0x1e, 0x6e, 0x7b, 0xee, 0xc6, 0x89, 0x66, 0xe7, 0x93, 0xef,
    0x54, 0x12, 0x68, 0xea, 0xbf, 0x86, 0x2f, 0xdd, 0xd2, 0x79, 0xb8, 0xa9,
    0x6e, 0x03, 0xc2, 0xa3, 0xb9, 0xa3, 0xe1, 0x4b, 0x2a, 0xb3, 0xf8, 0xb4,
    0xcd, 0xea, 0xbe, 0x24, 0xa6, 0x57, 0x5b, 0x83, 0x1f, 0x0f, 0xf2, 0xd3,
    0xb7, 0xac, 0x7e, 0xd6, 0x8e, 0x6e, 0x1e, 0xbf, 0xb8, 0x73, 0x8c, 0x05,
    0x56, 0xe6, 0x35, 0x1f, 0xe9, 0x04, 0x0b, 0x09, 0x86, 0x7d, 0xf1, 0x26,
    0x08, 0x99, 0xad, 0x7b, 0xc8, 0x4d, 0x94, 0xb0, 0x0b, 0x8b, 0x38, 0xa0,
    0x5c, 0x62, 0xa0, 0xab, 0xd3, 0x8f, 0xd4, 0x09, 0x60, 0x72, 0x1e, 0x33,
    0x50, 0x80, 0x6e, 0x22, 0xa6, 0x77, 0x57, 0x6b, 0x9a, 0x33, 0x21, 0x66,
    0x87, 0x6e, 0x21, 0x7b, 0xc7, 0x24, 0x0e, 0xd8, 0x13, 0xdf, 0x83, 0xde,
    0xcd, 0x40, 0x58, 0x1d, 0x84, 0x86, 0xeb, 0xb8, 0x12, 0x4e, 0xd2, 0xfa,
    0x80, 0x1f, 0xe4, 0xe7, 0x96, 0x29, 0xb8, 0xcc, 0xce, 0x66, 0x6d, 0x53,
    0xca, 0xb9, 0x5a, 0xd7, 0xf6, 0x84, 0x6c, 0x2d, 0x9a, 0x1a, 0x14, 0x1c,
    0x4e, 0x93, 0x39, 0xba, 0x74, 0xed, 0xed, 0x87, 0x87, 0x5e, 0x48, 0x75,
    0x36, 0xf0, 0xbc, 0x34, 0xfb, 0x29, 0xf9, 0x9f, 0x96, 0x5b, 0x0b, 0xa7,
    0x54, 0x30, 0x51, 0x29, 0x18, 0x5b, 0x7d, 0xac, 0x0f, 0xd6, 0x5f, 0x7c,
    0xf8, 0x98, 0x8c, 0xd8, 0x86, 0x62, 0xb3, 0xdc, 0xff, 0x0f, 0xff, 0x7a,
    0xaf, 0x5c, 0x4c, 0x61, 0x49, 0x2e, 0xc8, 0x95, 0x86, 0xc4, 0x0e, 0x87,
    0xfc, 0x1d, 0xcf, 0x8b, 0x7c, 0x61, 0xf6, 0xd8, 0xd0, 0x69, 0xf6, 0xcd,
    0x8a, 0x8c, 0xf6, 0x62, 0xa2, 0x56, 0xa9, 0xe3, 0xd1, 0xcf, 0x4d, 0xa0,
    0xf6, 0x2d, 0x20, 0x0a, 0x04, 0xb7, 0xa2, 0xf7, 0xb5, 0x99, 0x47, 0x18,
    0x56, 0x85, 0x87, 0xc7, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01,
    0x01, 0x00, 0x99, 0x41, 0x38, 0x1a, 0xd0, 0x96, 0x7a, 0xf0, 0x83, 0xd5,
    0xdf, 0x94, 0xce, 0x89, 0x3d, 0xec, 0x7a, 0x52, 0x21, 0x10, 0x16, 0x06,
    0xe0, 0xee, 0xd2, 0xe6, 0xfd, 0x4b, 0x7b, 0x19, 0x4d, 0xe1, 0xc0, 0xc0,
    0xd5, 0x14, 0x5d, 0x79, 0xdd, 0x7e, 0x8b, 0x4b, 0xc6, 0xcf, 0xb0, 0x75,
    0x52, 0xa3, 0x2d, 0xb1, 0x26, 0x46, 0x68, 0x9c, 0x0a, 0x1a, 0xf2, 0xe1,
    0x09, 0xac, 0x53, 0x85, 0x8c, 0x36, 0xa9, 0x14, 0x65, 0xea, 0xa0, 0x00,
    0xcb, 0xe3, 0x3f, 0xc4, 0x2b, 0x61, 0x2e, 0x6b, 0x06, 0x69, 0x77, 0xfd,
    0x38, 0x7e, 0x1d, 0x3f, 0x92, 0xe7, 0x77, 0x08, 0x19, 0xa7, 0x9d, 0x29,
    0x2d, 0xdc, 0x42, 0xc6, 0x7c, 0xd7, 0xd3, 0xa8, 0x01, 0x2c, 0xf2, 0xd5,
    0x82, 0x57, 0xcb, 0x55, 0x3d, 0xe7, 0xaa, 0xd2, 0x06, 0x30, 0x30, 0x05,
    0xe6, 0xf2, 0x47, 0x86, 0xba, 0xc6, 0x61, 0x64, 0xeb, 0x4f, 0x2a, 0x5e,
    0x07, 0x29, 0xe0, 0x96, 0xb2, 0x43, 0xff, 0x5f, 0x1a, 0x54, 0x16, 0xcf,
    0xb5, 0x56, 0x5c, 0xa0, 0x9b, 0x0c, 0xfd, 0xb3, 0xd2, 0xe3, 0x79, 0x1d,
    0x21, 0xe2, 0xd6, 0x13, 0xc4, 0x74, 0xa6, 0xf5, 0x8e, 0x8e, 0x81, 0xbb,
    0xb4, 0xad, 0x8a, 0xf0, 0x93, 0x0a, 0xd8, 0x0a, 0x42, 0x36, 0xbc, 0xe5,
    0x26, 0x2a, 0x0d, 0x5d, 0x57, 0x13, 0xc5, 0x4e, 0x2f, 0x12, 0x0e, 0xef,
    0xa7, 0x81, 0x1e, 0xc3, 0xa5, 0xdb, 0xc9, 0x24, 0xeb, 0x1a, 0xa1, 0xf9,
    0xf6, 0xa1, 0x78, 0x98, 0x93, 0x77, 0x42, 0x45, 0x03, 0xe2, 0xc9, 0xa2,
    0xfe, 0x2d, 0x77, 0xc8, 0xc6, 0xac, 0x9b, 0x98, 0x89, 0x6d, 0x9a, 0xe7,
    0x61, 0x63, 0xb7, 0xf2, 0xec, 0xd6, 0xb1, 0xa1, 0x6e, 0x0a, 0x1a, 0xff,
    0xfd, 0x43, 0x28, 0xc3, 0x0c, 0xdc, 0xf2, 0x47, 0x4f, 0x27, 0xaa, 0x99,
    0x04, 0x8e, 0xac, 0xe8, 0x7c, 0x01, 0x02, 0x04, 0x12, 0x34, 0x56, 0x78,
    0x02, 0x81, 0x81, 0x00, 0xca, 0x69, 0xe5, 0xbb, 0x3a, 0x90, 0x82, 0xcb,
    0x82, 0x50, 0x2f, 0x29, 0xe2, 0x76, 0x6a, 0x57, 0x55, 0x45, 0x4e, 0x35,
    0x18, 0x61, 0xe0, 0x12, 0x70, 0xc0, 0xab, 0xc7, 0x80, 0xa2, 0xd4, 0x46,
    0x34, 0x03, 0xa0, 0x19, 0x26, 0x23, 0x9e, 0xef, 0x1a, 0xcb, 0x75, 0xd6,
    0xba, 0x81, 0xf4, 0x7e, 0x52, 0xe5, 0x2a, 0xe8, 0xf1, 0x49, 0x6c, 0x0f,
    0x1a, 0xa0, 0xf9, 0xc6, 0xe7, 0xec, 0x60, 0xe4, 0xcb, 0x2a, 0xb5, 0x56,
    0xe9, 0x9c, 0xcd, 0x19, 0x75, 0x92, 0xb1, 0x66, 0xce, 0xc3, 0xd9, 0x3d,
    0x11, 0xcb, 0xc4, 0x09, 0xce, 0x1e, 0x30, 0xba, 0x2f, 0x60, 0x60, 0x55,
    0x8d, 0x02, 0xdc, 0x5d, 0xaf, 0xf7, 0x52, 0x31, 0x17, 0x07, 0x53, 0x20,
    0x33, 0xad, 0x8c, 0xd5, 0x2f, 0x5a, 0xd0, 0x57, 0xd7, 0xd1, 0x80, 0xd6,
    0x3a, 0x9b, 0x04, 0x4f, 0x35, 0xbf, 0xe7, 0xd5, 0xbc, 0x8f, 0xd4, 0x81,
    0x02, 0x81, 0x81, 0x00, 0xc0, 0x9f, 0xf8, 0xcd, 0xf7, 0x3f, 0x26, 0x8a,
    0x3d, 0x4d, 0x2b, 0x0c, 0x01, 0xd0, 0xa2, 0xb4, 0x18, 0xfe, 0xf7, 0x5e,
    0x2f, 0x06, 0x13, 0xcd, 0x63, 0xaa, 0x12, 0xa9, 0x24, 0x86, 0xe3, 0xf3,
    0x7b, 0xda, 0x1a, 0x3c, 0xb1, 0x38, 0x80, 0x80, 0xef, 0x64, 0x64, 0xa1,
    0x9b, 0xfe, 0x76, 0x63, 0x8e, 0x83, 0xd2, 0xd9, 0xb9, 0x86, 0xb0, 0xe6,
    0xa6, 0x0c, 0x7e, 0xa8, 0x84, 0x90, 0x98, 0x0c, 0x1e, 0xf3, 0x14, 0x77,
    0xe0, 0x5f, 0x81, 0x08, 0x11, 0x8f, 0xa6, 0x23, 0xc4, 0xba, 0xc0, 0x8a,
    0xe4, 0xc6, 0xe3, 0x5c, 0xbe, 0xc5, 0xec, 0x2c, 0xb9, 0xd8, 0x8c, 0x4d,
    0x1a, 0x9d, 0xe7, 0x7c, 0x85, 0x4c, 0x0d, 0x71, 0x4e, 0x72, 0x33, 0x1b,
    0xfe, 0xa9, 0x17, 0x72, 0x76, 0x56, 0x9d, 0x74, 0x7e, 0x52, 0x67, 0x9a,
    0x87, 0x9a, 0xdb, 0x30, 0xde, 0xe4, 0x49, 0x28, 0x3b, 0xd2, 0x67, 0xaf,
    0x02, 0x81, 0x81, 0x00, 0x89, 0x74, 0x9a, 0x8e, 0xa7, 0xb9, 0xa5, 0x28,
    0xc0, 0x68, 0xe5, 0x6e, 0x63, 0x1c, 0x99, 0x20, 0x8f, 0x86, 0x8e, 0x12,
    0x9e, 0x69, 0x30, 0xfa, 0x34, 0xd9, 0x92, 0x8d, 0xdb, 0x7c, 0x37, 0xfd,
    0x28, 0xab, 0x61, 0x98, 0x52, 0x7f, 0x14, 0x1a, 0x39, 0xae, 0xfb, 0x6a,
    0x03, 0xa3, 0xe6, 0xbd, 0xb6, 0x5b, 0x6b, 0xe5, 0x5e, 0x9d, 0xc6, 0xa5,
    0x07, 0x27, 0x54, 0x17, 0xd0, 0x3d, 0x84, 0x9b, 0x3a, 0xa0, 0xd9, 0x1e,
    0x99, 0x6c, 0x63, 0x17, 0xab, 0xf1, 0x1f, 0x49, 0xba, 0x95, 0xe3, 0x3b,
    0x86, 0x8f, 0x42, 0xa4, 0x89, 0xf5, 0x94, 0x8f, 0x8b, 0x46, 0xbe, 0x84,
    0xba, 0x4a, 0xbc, 0x0d, 0x5f, 0x46, 0xeb, 0xe8, 0xec, 0x43, 0x8c, 0x1e,
    0xad, 0x19, 0x69, 0x2f, 0x08, 0x86, 0x7a, 0x3f, 0x7d, 0x0f, 0x07, 0x97,
    0xf3, 0x9a, 0x7b, 0xb5, 0xb2, 0xc1, 0x8c, 0x95, 0x68, 0x04, 0xa0, 0x81,
    0x02, 0x81, 0x80, 0x4e, 0xbf, 0x7e, 0x1b, 0xcb, 0x13, 0x61, 0x75, 0x3b,
    0xdb, 0x59, 0x5f, 0xb1, 0xd4, 0xb8, 0xeb, 0x9e, 0x73, 0xb5, 0xe7, 0xf6,
    0x89, 0x3d, 0x1c, 0xda, 0xf0, 0x36, 0xff, 0x35, 0xbd, 0x1e, 0x0b, 0x74,
    0xe3, 0x9e, 0xf0, 0xf2, 0xf7, 0xd7, 0x82, 0xb7, 0x7b, 0x6a, 0x1b, 0x0e,
    0x30, 0x4a, 0x98, 0x0e, 0xb4, 0xf9, 0x81, 0x07, 0xe4, 0x75, 0x39, 0xe9,
    0x53, 0xca, 0xbb, 0x5c, 0xaa, 0x93, 0x07, 0x0e, 0xa8, 0x2f, 0xba, 0x98,
    0x49, 0x30, 0xa7, 0xcc, 0x1a, 0x3c, 0x68, 0x0c, 0xe1, 0xa4, 0xb1, 0x05,
    0xe6, 0xe0, 0x25, 0x78, 0x58, 0x14, 0x37, 0xf5, 0x1f, 0xe3, 0x22, 0xef,
    0xa8, 0x0e, 0x22, 0xa0, 0x94, 0x3a, 0xf6, 0xc9, 0x13, 0xe6, 0x06, 0xbf,
    0x7f, 0x99, 0xc6, 0xcc, 0xd8, 0xc6, 0xbe, 0xd9, 0x2e, 0x24, 0xc7, 0x69,
    0x8c, 0x95, 0xba, 0xf6, 0x04, 0xb3, 0x0a, 0xf4, 0xcb, 0xf0, 0xce,
};

static const unsigned char kMsg[] = { 1, 2, 3, 4 };

static const unsigned char kSignature[] = {
    0xa5, 0xf0, 0x8a, 0x47, 0x5d, 0x3c, 0xb3, 0xcc, 0xa9, 0x79, 0xaf, 0x4d,
    0x8c, 0xae, 0x4c, 0x14, 0xef, 0xc2, 0x0b, 0x34, 0x36, 0xde, 0xf4, 0x3e,
    0x3d, 0xbb, 0x4a, 0x60, 0x5c, 0xc8, 0x91, 0x28, 0xda, 0xfb, 0x7e, 0x04,
    0x96, 0x7e, 0x63, 0x13, 0x90, 0xce, 0xb9, 0xb4, 0x62, 0x7a, 0xfd, 0x09,
    0x3d, 0xc7, 0x67, 0x78, 0x54, 0x04, 0xeb, 0x52, 0x62, 0x6e, 0x24, 0x67,
    0xb4, 0x40, 0xfc, 0x57, 0x62, 0xc6, 0xf1, 0x67, 0xc1, 0x97, 0x8f, 0x6a,
    0xa8, 0xae, 0x44, 0x46, 0x5e, 0xab, 0x67, 0x17, 0x53, 0x19, 0x3a, 0xda,
    0x5a, 0xc8, 0x16, 0x3e, 0x86, 0xd5, 0xc5, 0x71, 0x2f, 0xfc, 0x23, 0x48,
    0xd9, 0x0b, 0x13, 0xdd, 0x7b, 0x5a, 0x25, 0x79, 0xef, 0xa5, 0x7b, 0x04,
    0xed, 0x44, 0xf6, 0x18, 0x55, 0xe4, 0x0a, 0xe9, 0x57, 0x79, 0x5d, 0xd7,
    0x55, 0xa7, 0xab, 0x45, 0x02, 0x97, 0x60, 0x42,
};

/*
 * kExampleRSAKeyPKCS8 is kExampleRSAKeyDER encoded in a PKCS #8
 * PrivateKeyInfo.
 */
static const unsigned char kExampleRSAKeyPKCS8[] = {
    0x30, 0x82, 0x02, 0x76, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a,
    0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
    0x02, 0x60, 0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81,
    0x00, 0xf8, 0xb8, 0x6c, 0x83, 0xb4, 0xbc, 0xd9, 0xa8, 0x57, 0xc0, 0xa5,
    0xb4, 0x59, 0x76, 0x8c, 0x54, 0x1d, 0x79, 0xeb, 0x22, 0x52, 0x04, 0x7e,
    0xd3, 0x37, 0xeb, 0x41, 0xfd, 0x83, 0xf9, 0xf0, 0xa6, 0x85, 0x15, 0x34,
    0x75, 0x71, 0x5a, 0x84, 0xa8, 0x3c, 0xd2, 0xef, 0x5a, 0x4e, 0xd3, 0xde,
    0x97, 0x8a, 0xdd, 0xff, 0xbb, 0xcf, 0x0a, 0xaa, 0x86, 0x92, 0xbe, 0xb8,
    0x50, 0xe4, 0xcd, 0x6f, 0x80, 0x33, 0x30, 0x76, 0x13, 0x8f, 0xca, 0x7b,
    0xdc, 0xec, 0x5a, 0xca, 0x63, 0xc7, 0x03, 0x25, 0xef, 0xa8, 0x8a, 0x83,
    0x58, 0x76, 0x20, 0xfa, 0x16, 0x77, 0xd7, 0x79, 0x92, 0x63, 0x01, 0x48,
    0x1a, 0xd8, 0x7b, 0x67, 0xf1, 0x52, 0x55, 0x49, 0x4e, 0xd6, 0x6e, 0x4a,
    0x5c, 0xd7, 0x7a, 0x37, 0x36, 0x0c, 0xde, 0xdd, 0x8f, 0x44, 0xe8, 0xc2,
    0xa7, 0x2c, 0x2b, 0xb5, 0xaf, 0x64, 0x4b, 0x61, 0x07, 0x02, 0x03, 0x01,
    0x00, 0x01, 0x02, 0x81, 0x80, 0x74, 0x88, 0x64, 0x3f, 0x69, 0x45, 0x3a,
    0x6d, 0xc7, 0x7f, 0xb9, 0xa3, 0xc0, 0x6e, 0xec, 0xdc, 0xd4, 0x5a, 0xb5,
    0x32, 0x85, 0x5f, 0x19, 0xd4, 0xf8, 0xd4, 0x3f, 0x3c, 0xfa, 0xc2, 0xf6,
    0x5f, 0xee, 0xe6, 0xba, 0x87, 0x74, 0x2e, 0xc7, 0x0c, 0xd4, 0x42, 0xb8,
    0x66, 0x85, 0x9c, 0x7b, 0x24, 0x61, 0xaa, 0x16, 0x11, 0xf6, 0xb5, 0xb6,
    0xa4, 0x0a, 0xc9, 0x55, 0x2e, 0x81, 0xa5, 0x47, 0x61, 0xcb, 0x25, 0x8f,
    0xc2, 0x15, 0x7b, 0x0e, 0x7c, 0x36, 0x9f, 0x3a, 0xda, 0x58, 0x86, 0x1c,
    0x5b, 0x83, 0x79, 0xe6, 0x2b, 0xcc, 0xe6, 0xfa, 0x2c, 0x61, 0xf2, 0x78,
    0x80, 0x1b, 0xe2, 0xf3, 0x9d, 0x39, 0x2b, 0x65, 0x57, 0x91, 0x3d, 0x71,
    0x99, 0x73, 0xa5, 0xc2, 0x79, 0x20, 0x8c, 0x07, 0x4f, 0xe5, 0xb4, 0x60,
    0x1f, 0x99, 0xa2, 0xb1, 0x4f, 0x0c, 0xef, 0xbc, 0x59, 0x53, 0x00, 0x7d,
    0xb1, 0x02, 0x41, 0x00, 0xfc, 0x7e, 0x23, 0x65, 0x70, 0xf8, 0xce, 0xd3,
    0x40, 0x41, 0x80, 0x6a, 0x1d, 0x01, 0xd6, 0x01, 0xff, 0xb6, 0x1b, 0x3d,
    0x3d, 0x59, 0x09, 0x33, 0x79, 0xc0, 0x4f, 0xde, 0x96, 0x27, 0x4b, 0x18,
    0xc6, 0xd9, 0x78, 0xf1, 0xf4, 0x35, 0x46, 0xe9, 0x7c, 0x42, 0x7a, 0x5d,
    0x9f, 0xef, 0x54, 0xb8, 0xf7, 0x9f, 0xc4, 0x33, 0x6c, 0xf3, 0x8c, 0x32,
    0x46, 0x87, 0x67, 0x30, 0x7b, 0xa7, 0xac, 0xe3, 0x02, 0x41, 0x00, 0xfc,
    0x2c, 0xdf, 0x0c, 0x0d, 0x88, 0xf5, 0xb1, 0x92, 0xa8, 0x93, 0x47, 0x63,
    0x55, 0xf5, 0xca, 0x58, 0x43, 0xba, 0x1c, 0xe5, 0x9e, 0xb6, 0x95, 0x05,
    0xcd, 0xb5, 0x82, 0xdf, 0xeb, 0x04, 0x53, 0x9d, 0xbd, 0xc2, 0x38, 0x16,
    0xb3, 0x62, 0xdd, 0xa1, 0x46, 0xdb, 0x6d, 0x97, 0x93, 0x9f, 0x8a, 0xc3,
    0x9b, 0x64, 0x7e, 0x42, 0xe3, 0x32, 0x57, 0x19, 0x1b, 0xd5, 0x6e, 0x85,
    0xfa, 0xb8, 0x8d, 0x02, 0x41, 0x00, 0xbc, 0x3d, 0xde, 0x6d, 0xd6, 0x97,
    0xe8, 0xba, 0x9e, 0x81, 0x37, 0x17, 0xe5, 0xa0, 0x64, 0xc9, 0x00, 0xb7,
    0xe7, 0xfe, 0xf4, 0x29, 0xd9, 0x2e, 0x43, 0x6b, 0x19, 0x20, 0xbd, 0x99,
    0x75, 0xe7, 0x76, 0xf8, 0xd3, 0xae, 0xaf, 0x7e, 0xb8, 0xeb, 0x81, 0xf4,
    0x9d, 0xfe, 0x07, 0x2b, 0x0b, 0x63, 0x0b, 0x5a, 0x55, 0x90, 0x71, 0x7d,
    0xf1, 0xdb, 0xd9, 0xb1, 0x41, 0x41, 0x68, 0x2f, 0x4e, 0x39, 0x02, 0x40,
    0x5a, 0x34, 0x66, 0xd8, 0xf5, 0xe2, 0x7f, 0x18, 0xb5, 0x00, 0x6e, 0x26,
    0x84, 0x27, 0x14, 0x93, 0xfb, 0xfc, 0xc6, 0x0f, 0x5e, 0x27, 0xe6, 0xe1,
    0xe9, 0xc0, 0x8a, 0xe4, 0x34, 0xda, 0xe9, 0xa2, 0x4b, 0x73, 0xbc, 0x8c,
    0xb9, 0xba, 0x13, 0x6c, 0x7a, 0x2b, 0x51, 0x84, 0xa3, 0x4a, 0xe0, 0x30,
    0x10, 0x06, 0x7e, 0xed, 0x17, 0x5a, 0x14, 0x00, 0xc9, 0xef, 0x85, 0xea,
    0x52, 0x2c, 0xbc, 0x65, 0x02, 0x40, 0x51, 0xe3, 0xf2, 0x83, 0x19, 0x9b,
    0xc4, 0x1e, 0x2f, 0x50, 0x3d, 0xdf, 0x5a, 0xa2, 0x18, 0xca, 0x5f, 0x2e,
    0x49, 0xaf, 0x6f, 0xcc, 0xfa, 0x65, 0x77, 0x94, 0xb5, 0xa1, 0x0a, 0xa9,
    0xd1, 0x8a, 0x39, 0x37, 0xf4, 0x0b, 0xa0, 0xd7, 0x82, 0x27, 0x5e, 0xae,
    0x17, 0x17, 0xa1, 0x1e, 0x54, 0x34, 0xbf, 0x6e, 0xc4, 0x8e, 0x99, 0x5d,
    0x08, 0xf1, 0x2d, 0x86, 0x9d, 0xa5, 0x20, 0x1b, 0xe5, 0xdf,
};

#ifndef OPENSSL_NO_EC
/*
 * kExampleECKeyDER is a sample EC private key encoded as an ECPrivateKey
 * structure.
 */
static const unsigned char kExampleECKeyDER[] = {
    0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0x07, 0x0f, 0x08, 0x72, 0x7a,
    0xd4, 0xa0, 0x4a, 0x9c, 0xdd, 0x59, 0xc9, 0x4d, 0x89, 0x68, 0x77, 0x08,
    0xb5, 0x6f, 0xc9, 0x5d, 0x30, 0x77, 0x0e, 0xe8, 0xd1, 0xc9, 0xce, 0x0a,
    0x8b, 0xb4, 0x6a, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
    0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0xe6, 0x2b, 0x69,
    0xe2, 0xbf, 0x65, 0x9f, 0x97, 0xbe, 0x2f, 0x1e, 0x0d, 0x94, 0x8a, 0x4c,
    0xd5, 0x97, 0x6b, 0xb7, 0xa9, 0x1e, 0x0d, 0x46, 0xfb, 0xdd, 0xa9, 0xa9,
    0x1e, 0x9d, 0xdc, 0xba, 0x5a, 0x01, 0xe7, 0xd6, 0x97, 0xa8, 0x0a, 0x18,
    0xf9, 0xc3, 0xc4, 0xa3, 0x1e, 0x56, 0xe2, 0x7c, 0x83, 0x48, 0xdb, 0x16,
    0x1a, 0x1c, 0xf5, 0x1d, 0x7e, 0xf1, 0x94, 0x2d, 0x4b, 0xcf, 0x72, 0x22,
    0xc1,
};

/*
 * kExampleBadECKeyDER is a sample EC private key encoded as an ECPrivateKey
 * structure. The private key is equal to the order and will fail to import
 */
static const unsigned char kExampleBadECKeyDER[] = {
    0x30, 0x66, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48,
    0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03,
    0x01, 0x07, 0x04, 0x4C, 0x30, 0x4A, 0x02, 0x01, 0x01, 0x04, 0x20, 0xFF,
    0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 0xF3,
    0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51, 0xA1, 0x23, 0x03, 0x21, 0x00,
    0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84,
    0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51
};

/* prime256v1 */
static const unsigned char kExampleECPubKeyDER[] = {
    0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
    0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
    0x42, 0x00, 0x04, 0xba, 0xeb, 0x83, 0xfb, 0x3b, 0xb2, 0xff, 0x30, 0x53,
    0xdb, 0xce, 0x32, 0xf2, 0xac, 0xae, 0x44, 0x0d, 0x3d, 0x13, 0x53, 0xb8,
    0xd1, 0x68, 0x55, 0xde, 0x44, 0x46, 0x05, 0xa6, 0xc9, 0xd2, 0x04, 0xb7,
    0xe3, 0xa2, 0x96, 0xc8, 0xb2, 0x5e, 0x22, 0x03, 0xd7, 0x03, 0x7a, 0x8b,
    0x13, 0x5c, 0x42, 0x49, 0xc2, 0xab, 0x86, 0xd6, 0xac, 0x6b, 0x93, 0x20,
    0x56, 0x6a, 0xc6, 0xc8, 0xa5, 0x0b, 0xe5
};

/*
 * kExampleBadECKeyDER is a sample EC public key with a wrong OID
 * 1.2.840.10045.2.2 instead of 1.2.840.10045.2.1 - EC Public Key
 */
static const unsigned char kExampleBadECPubKeyDER[] = {
    0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
    0x02, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
    0x42, 0x00, 0x04, 0xba, 0xeb, 0x83, 0xfb, 0x3b, 0xb2, 0xff, 0x30, 0x53,
    0xdb, 0xce, 0x32, 0xf2, 0xac, 0xae, 0x44, 0x0d, 0x3d, 0x13, 0x53, 0xb8,
    0xd1, 0x68, 0x55, 0xde, 0x44, 0x46, 0x05, 0xa6, 0xc9, 0xd2, 0x04, 0xb7,
    0xe3, 0xa2, 0x96, 0xc8, 0xb2, 0x5e, 0x22, 0x03, 0xd7, 0x03, 0x7a, 0x8b,
    0x13, 0x5c, 0x42, 0x49, 0xc2, 0xab, 0x86, 0xd6, 0xac, 0x6b, 0x93, 0x20,
    0x56, 0x6a, 0xc6, 0xc8, 0xa5, 0x0b, 0xe5
};

static const unsigned char pExampleECParamDER[] = {
    0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07
};
#endif

typedef struct APK_DATA_st {
    const unsigned char *kder;
    size_t size;
    int evptype;
    int check;
    int pub_check;
    int param_check;
    int type; /* 0 for private, 1 for public, 2 for params */
} APK_DATA;

static APK_DATA keydata[] = {
    {kExampleRSAKeyDER, sizeof(kExampleRSAKeyDER), EVP_PKEY_RSA},
    {kExampleRSAKeyPKCS8, sizeof(kExampleRSAKeyPKCS8), EVP_PKEY_RSA},
#ifndef OPENSSL_NO_EC
    {kExampleECKeyDER, sizeof(kExampleECKeyDER), EVP_PKEY_EC}
#endif
};

static APK_DATA keycheckdata[] = {
    {kExampleRSAKeyDER, sizeof(kExampleRSAKeyDER), EVP_PKEY_RSA, 1, -2, -2, 0},
    {kExampleBadRSAKeyDER, sizeof(kExampleBadRSAKeyDER), EVP_PKEY_RSA,
     0, -2, -2, 0},
#ifndef OPENSSL_NO_EC
    {kExampleECKeyDER, sizeof(kExampleECKeyDER), EVP_PKEY_EC, 1, 1, 1, 0},
    /* group is also associated in our pub key */
    {kExampleECPubKeyDER, sizeof(kExampleECPubKeyDER), EVP_PKEY_EC, 0, 1, 1, 1},
    {pExampleECParamDER, sizeof(pExampleECParamDER), EVP_PKEY_EC, 0, 0, 1, 2}
#endif
};

static EVP_PKEY *load_example_rsa_key(void)
{
    EVP_PKEY *ret = NULL;
    const unsigned char *derp = kExampleRSAKeyDER;
    EVP_PKEY *pkey = NULL;
    RSA *rsa = NULL;

    if (!TEST_true(d2i_RSAPrivateKey(&rsa, &derp, sizeof(kExampleRSAKeyDER))))
        return NULL;

    if (!TEST_ptr(pkey = EVP_PKEY_new())
            || !TEST_true(EVP_PKEY_set1_RSA(pkey, rsa)))
        goto end;

    ret = pkey;
    pkey = NULL;

end:
    EVP_PKEY_free(pkey);
    RSA_free(rsa);

    return ret;
}

int test_ptr(const char *file, int line, const char *s, const void *p)
{
    if (p != NULL)
        return 1;
    //test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
    return 0;
}

int test_true(const char *file, int line, const char *s, int b)
{
    if (b)
        return 1;
    //test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
    return 0;
}

int test_mem_eq(const char *file, int line, const char *st1, const char *st2,
                const void *s1, size_t n1, const void *s2, size_t n2)
{
    if (s1 == NULL && s2 == NULL)
        return 1;
    if (n1 != n2 || s1 == NULL || s2 == NULL || memcmp(s1, s2, n1) != 0) {
        /*
        test_fail_memory_message(NULL, file, line, "memory", st1, st2, "==",
                                 s1, n1, s2, n2);
                                 */
        return 0;
    }
    return 1;
}

static int test_EVP_Enveloped(void)
{
    int ret = 0;
    EVP_CIPHER_CTX *ctx = NULL;
    EVP_PKEY *keypair = NULL;
    unsigned char *kek = NULL;
    unsigned char iv[EVP_MAX_IV_LENGTH];
    static const unsigned char msg[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
    int len, kek_len, ciphertext_len, plaintext_len;
    unsigned char ciphertext[32], plaintext[16];
    const EVP_CIPHER *type = EVP_aes_256_cbc();

    if (!TEST_ptr(keypair = load_example_rsa_key())
            || !TEST_ptr(kek = OPENSSL_zalloc(EVP_PKEY_size(keypair)))
            || !TEST_ptr(ctx = EVP_CIPHER_CTX_new())
            || !TEST_true(EVP_SealInit(ctx, type, &kek, &kek_len, iv,
                                       &keypair, 1))
            || !TEST_true(EVP_SealUpdate(ctx, ciphertext, &ciphertext_len,
                                         msg, sizeof(msg)))
            || !TEST_true(EVP_SealFinal(ctx, ciphertext + ciphertext_len,
                                        &len)))
        goto err;

    ciphertext_len += len;

    if (!TEST_true(EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair))
            || !TEST_true(EVP_OpenUpdate(ctx, plaintext, &plaintext_len,
                                         ciphertext, ciphertext_len))
            || !TEST_true(EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)))
        goto err;

    plaintext_len += len;
    if (!TEST_mem_eq(msg, sizeof(msg), plaintext, plaintext_len))
        goto err;

    ret = 1;
err:
    OPENSSL_free(kek);
    EVP_PKEY_free(keypair);
    EVP_CIPHER_CTX_free(ctx);
    return ret;
}

int main()
{
    return !test_EVP_Enveloped();
}

When running with valgrind, I have:

/opt/1A/toolchain/x86_64-2.6.32-v4/build-pack/default/bin/valgrind --gen-suppressions=all --num-callers=30 --leak-check=full --show-reachable=yes --error-exitcode=1 --trace-children=yes -v --track-origins=yes ./reproducer && echo OK || echo failed...

Which produces:

==18888== Memcheck, a memory error detector
==18888== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18888== Using Valgrind-3.14.0-353a3587bb-20181007X and LibVEX; rerun with -h for copyright info
==18888== Command: ./reproducer
==18888== 
--18888-- Valgrind options:
--18888--    --gen-suppressions=all
--18888--    --num-callers=30
--18888--    --leak-check=full
--18888--    --show-reachable=yes
--18888--    --error-exitcode=1
--18888--    --trace-children=yes
--18888--    -v
--18888--    --track-origins=yes
--18888-- Contents of /proc/version:
--18888--   Linux version 2.6.32.59-0.7-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP 2012-07-13 15:50:56 +0200
--18888-- 
--18888-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-rdtscp-sse3
--18888-- Page sizes: currently 4096, max supported 4096
--18888-- Valgrind library directory: /opt/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind
--18888-- Reading syms from /data3/mwrep/rgeissler/ospack/openssl/SOURCES/openssl-1.1.1b/reproducer
--18888-- Reading syms from /remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.53/lib/ld-2.23.so
--18888-- Reading syms from /remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind/memcheck-amd64-linux
--18888--    object doesn't have a dynamic symbol table
--18888-- Scheduler: using generic scheduler lock implementation.
--18888-- Reading suppressions file: /opt/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind/default.supp
==18888== embedded gdbserver: reading from /gctmp/rgeissler/vgdb-pipe-from-vgdb-to-18888-by-rgeissler-on-ncegcolnx273
==18888== embedded gdbserver: writing to   /gctmp/rgeissler/vgdb-pipe-to-vgdb-from-18888-by-rgeissler-on-ncegcolnx273
==18888== embedded gdbserver: shared mem   /gctmp/rgeissler/vgdb-pipe-shared-mem-vgdb-18888-by-rgeissler-on-ncegcolnx273
==18888== 
==18888== TO CONTROL THIS PROCESS USING vgdb (which you probably
==18888== don't want to do, unless you know exactly what you're doing,
==18888== or are doing some strange experiment):
==18888==   /opt/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind/../../bin/vgdb --pid=18888 ...command...
==18888== 
==18888== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==18888==   /path/to/gdb ./reproducer
==18888== and then give GDB the following command
==18888==   target remote | /opt/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind/../../bin/vgdb --pid=18888
==18888== --pid is optional if only one valgrind process is running
==18888== 
--18888-- REDIR: 0x401b070 (ld-linux-x86-64.so.2:strlen) redirected to 0x580c1ac2 (vgPlain_amd64_linux_REDIR_FOR_strlen)
--18888-- REDIR: 0x40199c0 (ld-linux-x86-64.so.2:index) redirected to 0x580c1adc (vgPlain_amd64_linux_REDIR_FOR_index)
--18888-- Reading syms from /remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind/vgpreload_core-amd64-linux.so
--18888-- Reading syms from /remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.53/build-pack/4.0.53.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so
==18888== WARNING: new redirection conflicts with existing -- ignoring it
--18888--     old: 0x0401b070 (strlen              ) R-> (0000.0) 0x580c1ac2 vgPlain_amd64_linux_REDIR_FOR_strlen
--18888--     new: 0x0401b070 (strlen              ) R-> (2007.0) 0x04836dd0 strlen
--18888-- REDIR: 0x4019be0 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4837ee0 (strcmp)
--18888-- REDIR: 0x401bdf0 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x483b900 (mempcpy)
--18888-- Reading syms from /remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.53/lib/libpthread-2.23.so
--18888-- Reading syms from /remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.53/lib/libc-2.23.so
--18888-- REDIR: 0x48f2940 (libc.so.6:strcasecmp) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48ee390 (libc.so.6:strcspn) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f4c30 (libc.so.6:strncasecmp) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f07f0 (libc.so.6:strpbrk) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f0b40 (libc.so.6:strspn) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f2090 (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f04c0 (libc.so.6:strncpy) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48eec20 (libc.so.6:strncmp) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48ee270 (libc.so.6:strcpy) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f2790 (libc.so.6:stpcpy) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48ecb90 (libc.so.6:index) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f20f0 (libc.so.6:memset) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f1ad0 (libc.so.6:bcmp) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48ecde0 (libc.so.6:strcmp) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f7330 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48ec990 (libc.so.6:strcat) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f1550 (libc.so.6:strstr) redirected to 0x482a1a0 (_vgnU_ifunc_wrapper)
--18888-- REDIR: 0x48f0500 (libc.so.6:rindex) redirected to 0x48367e0 (rindex)
--18888-- REDIR: 0x48ee820 (libc.so.6:strlen) redirected to 0x4836cb0 (strlen)
--18888-- REDIR: 0x48e9180 (libc.so.6:malloc) redirected to 0x48336a0 (malloc)
--18888-- REDIR: 0x48f2180 (libc.so.6:__GI_memset) redirected to 0x483a830 (memset)
--18888-- REDIR: 0x48e9790 (libc.so.6:free) redirected to 0x4834990 (free)
--18888-- REDIR: 0x48fe700 (libc.so.6:__memcpy_sse2_unaligned) redirected to 0x48383a0 (memcpy@@GLIBC_2.14)
--18888-- REDIR: 0x48e9830 (libc.so.6:realloc) redirected to 0x4835d50 (realloc)
--18888-- REDIR: 0x48f73b0 (libc.so.6:__GI_memcpy) redirected to 0x4838b60 (__GI_memcpy)
--18888-- REDIR: 0x48f27d0 (libc.so.6:__GI_stpcpy) redirected to 0x483a2f0 (__GI_stpcpy)
--18888-- REDIR: 0x48f22f0 (libc.so.6:__GI_mempcpy) redirected to 0x483b630 (__GI_mempcpy)
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x407867: EVP_DecryptFinal_ex (evp_enc.c:536)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x40787B: EVP_DecryptFinal_ex (evp_enc.c:536)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x40789F: EVP_DecryptFinal_ex (evp_enc.c:540)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x407896: EVP_DecryptFinal_ex (evp_enc.c:541)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x4078A7: EVP_DecryptFinal_ex (evp_enc.c:547)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x4078DC: EVP_DecryptFinal_ex (evp_enc.c:547)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x407A65: EVP_DecryptFinal_ex (evp_enc.c:547)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x40325C: test_mem_eq (evp_extra_test.c:395)
==18888==    by 0x403563: test_EVP_Enveloped (evp_extra_test.c:437)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:test_mem_eq
   fun:test_EVP_Enveloped
   fun:main
}
--18888-- REDIR: 0x49b8430 (libc.so.6:__memcmp_sse4_1) redirected to 0x483a070 (__memcmp_sse4_1)
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x483A08F: __memcmp_sse4_1 (vg_replace_strmem.c:1111)
==18888==    by 0x403280: test_mem_eq (evp_extra_test.c:395)
==18888==    by 0x403563: test_EVP_Enveloped (evp_extra_test.c:437)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:__memcmp_sse4_1
   fun:test_mem_eq
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== HEAP SUMMARY:
==18888==     in use at exit: 0 bytes in 0 blocks
==18888==   total heap usage: 2,614 allocs, 2,614 frees, 186,046 bytes allocated
==18888== 
==18888== All heap blocks were freed -- no leaks are possible
==18888== 
==18888== ERROR SUMMARY: 29 errors from 9 contexts (suppressed: 0 from 0)
==18888== 
==18888== 1 errors in context 1 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x483A08F: __memcmp_sse4_1 (vg_replace_strmem.c:1111)
==18888==    by 0x403280: test_mem_eq (evp_extra_test.c:395)
==18888==    by 0x403563: test_EVP_Enveloped (evp_extra_test.c:437)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:__memcmp_sse4_1
   fun:test_mem_eq
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 1 errors in context 2 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x40325C: test_mem_eq (evp_extra_test.c:395)
==18888==    by 0x403563: test_EVP_Enveloped (evp_extra_test.c:437)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:test_mem_eq
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 1 errors in context 3 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x4078DC: EVP_DecryptFinal_ex (evp_enc.c:547)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 1 errors in context 4 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x4078A7: EVP_DecryptFinal_ex (evp_enc.c:547)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 1 errors in context 5 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x40787B: EVP_DecryptFinal_ex (evp_enc.c:536)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 1 errors in context 6 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x407867: EVP_DecryptFinal_ex (evp_enc.c:536)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 7 errors in context 7 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x407896: EVP_DecryptFinal_ex (evp_enc.c:541)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 8 errors in context 8 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x407A65: EVP_DecryptFinal_ex (evp_enc.c:547)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== 
==18888== 8 errors in context 9 of 9:
==18888== Conditional jump or move depends on uninitialised value(s)
==18888==    at 0x40789F: EVP_DecryptFinal_ex (evp_enc.c:540)
==18888==    by 0x40A409: EVP_OpenFinal (p_open.c:68)
==18888==    by 0x403506: test_EVP_Enveloped (evp_extra_test.c:433)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888==  Uninitialised value was created by a heap allocation
==18888==    at 0x483370F: malloc (vg_replace_malloc.c:299)
==18888==    by 0x40A352: EVP_OpenInit (p_open.c:43)
==18888==    by 0x40347A: test_EVP_Enveloped (evp_extra_test.c:430)
==18888==    by 0x4035BA: main (evp_extra_test.c:450)
==18888== 
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:EVP_DecryptFinal_ex
   fun:EVP_OpenFinal
   fun:test_EVP_Enveloped
   fun:main
}
==18888== ERROR SUMMARY: 29 errors from 9 contexts (suppressed: 0 from 0)

Earlier releases of OpenSSL 1.0.2 or 1.1.1 did not expose this issue (for OpenSSL 1.0.2, I am using the purified version of the lib so that it is compatible with valgrind). I was able to bisect the "regression" to this commit: db1b63f#diff-7809a0d7252fb57c730401a352ebf1b2

A "trivial" fix silences these valgrind errors:

--- crypto/evp/p_open.c
+++ crypto/evp/p_open.c
@@ -40,7 +40,7 @@
     }

     size = EVP_PKEY_size(priv); 
-    key = OPENSSL_malloc(size + 2);
+    key = OPENSSL_zalloc(size + 2); 
     if (key == NULL) {
         /* ERROR */
         EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE);

However I really fail to understand why zero-allocating the symetric key would have any impact in the content of ctx->final in EVP_DecryptFinal_ex, but after investigation it looks like it really does. Most likely my fix is very wrong.

Cheers,
Romain

Activity

  1. levitte commented on Mar 13, 2019

    @levitte
    Member

    I wonder why two extra bytes are allocated. If I'm not mistaken, only exactly size bytes are going to be written, at least in most cases, so that means there are two bytes that are indeed not touched, i.e. not initialized.

    Note: this is pure guessing, I haven't verified what I'm saying in any kind of way

  2. kroeckx commented on Mar 18, 2019

    @kroeckx
    Member

    The commit you've pointed too has recently been rewritten. Can you test with a current git snapshot? But I suspect that will not actually change anything related to it.

  3. bernd-edlinger commented on Mar 20, 2019

    @bernd-edlinger
    Member

    How are you using the EVP_OpenInit function ?
    It looks like a padding oracle to me.

  4. Romain-Geissler-1A commented on Mar 28, 2019

    @Romain-Geissler-1A
    ContributorAuthor

    Hi,

    Yes I am using EVP_OpenInit. It looks like this page seems to show examples: https://wiki.openssl.org/index.php/EVP_Asymmetric_Encryption_and_Decryption_of_an_Envelope

    I checked the current branch 1.1.1. Now my reproducer yields other "Conditional jump or move depends on uninitialised value" errors (quite a lot actually) which aren't fixed at all by my "patch" (workaround) posted initially. The first one looks like this:

    ==24587== Conditional jump or move depends on uninitialised value(s)
    ==24587==    at 0x5479A1: inc_128 (drbg_ctr.c:32)
    ==24587==    by 0x548622: drbg_ctr_generate (drbg_ctr.c:330)
    ==24587==    by 0x4A21A0: RAND_DRBG_generate (drbg_lib.c:638)
    ==24587==    by 0x42B076: rand_drbg_get_entropy (rand_lib.c:172)
    ==24587==    by 0x4A16C5: RAND_DRBG_instantiate (drbg_lib.c:338)
    ==24587==    by 0x4A26AC: drbg_setup (drbg_lib.c:892)
    ==24587==    by 0x4A2C0B: RAND_DRBG_get0_private (drbg_lib.c:1141)
    ==24587==    by 0x42C064: RAND_priv_bytes (rand_lib.c:823)
    ==24587==    by 0x418529: EVP_CIPHER_CTX_rand_key (evp_enc.c:638)
    ==24587==    by 0x41AC1B: EVP_SealInit (p_seal.c:33)
    ==24587==    by 0x403392: test_EVP_Enveloped (in /data3/mwrep/rgeissler/ospack/openssl/reproducer)
    ==24587==    by 0x4035BA: main (in /data3/mwrep/rgeissler/ospack/openssl/reproducer)
    ==24587==  Uninitialised value was created by a stack allocation
    ==24587==    at 0x42B1BD: rand_drbg_get_nonce (rand_lib.c:231)
    

    Cheers,
    Romain

  5. bernd-edlinger commented on Mar 28, 2019

    @bernd-edlinger
    Member

    Okay, this was introduced by b3d113e
    aka. cosmetic change in rand_drbg_get_nonce
    see #8603

  6. bernd-edlinger commented on Mar 28, 2019

    @bernd-edlinger
    Member

    But I have another question, do you transfer the sealed data over a network connection ?
    If yes do you validate that data is not tampered before you call EVP_OpenInit ?

  7. Romain-Geissler-1A commented on Mar 28, 2019

    @Romain-Geissler-1A
    ContributorAuthor

    Yes. The sender sends the sealed data, and a string id to tell who the send end is. On receiver end, from this string id we get the public key (that was uploaded beforehand), and we try to check the envelop using this public key. No other check on integrity is done. I was expecting the openssl routines to return an error in that case. Should I do something more robust ?

  8. bernd-edlinger commented on Mar 28, 2019

    @bernd-edlinger
    Member

    The problem is here:

    EVP_OpenInit uses your private key, and decrypts a cipher block which is possibly not well-formed.
    Now unfortunately it uses PKCS1 padding, and the likelihood to get a well-formed
    but completely random plain text is around 1/32000 so very high.
    If you now leak via your result code, or even via small timing differences the fact
    that the plain text was well-formed, you create a Bleichenbacher Oracle, which
    effectively gives an attacker to use your private key for private key ops.

    That is a very serious threat.

    So you either must ensure that the sealed key is authentic for instance by having
    the sender sign that with his private key, and you being able to trust the certificate
    and check the signature of the sealed key first.

    Is that possible, to do it this way?

  9. paulidale commented on Mar 28, 2019

    @paulidale
    Contributor

    I'd just noticed the uninitialised warnings from the DRBGs while checking the test drbgtest.
    I'd not begun chasing down why.

  10. levitte commented on Mar 29, 2019

    @levitte
    Member

    The fix as well as the fix of the fix are now in master, so no point keeping this issue open any more.

  11. bernd-edlinger commented on Mar 31, 2019

    @bernd-edlinger
    Member

    Additionally, to what I said above, about authentication of the sealed key,
    also the cipher text needs to be authenticated in case you use the cipher
    EVP_aes_256_cbc as in the code example given initially.

    See this comment here:

    /*
    * The following assumes that the ciphertext has been authenticated.
    * Otherwise it provides a padding oracle.
    */

  12. Romain-Geissler-1A commented on Aug 5, 2019

    @Romain-Geissler-1A
    ContributorAuthor

    Hi @bernd-edlinger,

    I have tried the code from Openssl 1.1.1c, and the initial reproducer here (taken back then from the Openssl own unit tests) still expose the same valgrind error. I have this when I try now:

    ==33623== Conditional jump or move depends on uninitialised value(s)
    ==33623==    at 0x408C8F: EVP_DecryptFinal_ex (evp_enc.c:569)   
    ==33623==    by 0x40B929: EVP_OpenFinal (p_open.c:68)
    ==33623==    by 0x404526: test_EVP_Enveloped (in /data/mwrep/rgeissler/sekhmet/openssl-test)
    ==33623==    by 0x4045DA: main (in /data/mwrep/rgeissler/sekhmet/openssl-test)
    ==33623==  Uninitialised value was created by a heap allocation 
    ==33623==    at 0x483670F: malloc (vg_replace_malloc.c:309)
    ==33623==    by 0x40B868: EVP_OpenInit (p_open.c:43)
    ==33623==    by 0x40B868: EVP_OpenInit (p_open.c:21)
    ==33623==    by 0x40449A: test_EVP_Enveloped (in /data/mwrep/rgeissler/sekhmet/openssl-test)
    ==33623==    by 0x4045DA: main (in /data/mwrep/rgeissler/sekhmet/openssl-test)
    

    Cheers,
    Romain

  13. bernd-edlinger commented on Aug 5, 2019

    @bernd-edlinger
    Member

    Can you try again with 7fab431,
    does that fix the bogus valgrind warnings?

  14. Romain-Geissler-1A commented on Aug 5, 2019

    @Romain-Geissler-1A
    ContributorAuthor

    Ah this one seems to work, thanks. I will patch our release 1.1.1c while waiting for delivery 1.1.1d ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions