1 diff -Nuar openssl-1.0.2d/crypto/evp/evp_pbe.c openssl-work/crypto/evp/evp_pbe.c
2 --- openssl-1.0.2d/crypto/evp/evp_pbe.c 2015-07-09 15:53:21.000000000 +0400
3 +++ openssl-work/crypto/evp/evp_pbe.c 2015-03-26 13:00:21.000000000 +0400
5 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA384, -1, NID_sha384, 0},
6 {EVP_PBE_TYPE_PRF, NID_hmacWithSHA512, -1, NID_sha512, 0},
7 {EVP_PBE_TYPE_PRF, NID_id_HMACGostR3411_94, -1, NID_id_GostR3411_94, 0},
8 + {EVP_PBE_TYPE_PRF, NID_id_tc26_hmac_gost_3411_2012_256, -1,
9 + NID_id_GostR3411_2012_256, 0},
10 + {EVP_PBE_TYPE_PRF, NID_id_tc26_hmac_gost_3411_2012_512, -1,
11 + NID_id_GostR3411_2012_512, 0},
15 diff -Nuar openssl-1.0.2d/crypto/pkcs12/p12_mutl.c openssl-work/crypto/pkcs12/p12_mutl.c
16 --- openssl-1.0.2d/crypto/pkcs12/p12_mutl.c 2015-07-09 15:53:21.000000000 +0400
17 +++ openssl-work/crypto/pkcs12/p12_mutl.c 2015-06-17 14:48:18.000000000 +0400
19 # include <openssl/rand.h>
20 # include <openssl/pkcs12.h>
22 +# define TK26_MAC_KEY_LEN 32
24 +static int PKCS12_gen_gost_mac_key(const char *pass, int passlen,
25 + const unsigned char *salt, int saltlen,
26 + int iter, const EVP_MD *digest, int keylen,
29 + unsigned char out[96];
31 + if (keylen != TK26_MAC_KEY_LEN) {
35 + if (!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter,
39 + memcpy(key, out + 64, TK26_MAC_KEY_LEN);
40 + OPENSSL_cleanse(out, 96);
45 int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
46 unsigned char *mac, unsigned int *maclen)
49 unsigned char key[EVP_MAX_MD_SIZE], *salt;
54 if (!PKCS7_type_is_data(p12->authsafes)) {
55 PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_CONTENT_TYPE_NOT_DATA);
57 md_size = EVP_MD_size(md_type);
60 - if (!PKCS12_key_gen(pass, passlen, salt, saltlen, PKCS12_MAC_ID, iter,
61 - md_size, key, md_type)) {
62 + if ((md_type->type == NID_id_GostR3411_94
63 + || md_type->type == NID_id_GostR3411_2012_256
64 + || md_type->type == NID_id_GostR3411_2012_512)
65 + && !getenv("LEGACY_GOST_PKCS12")) {
66 + md_size = TK26_MAC_KEY_LEN;
67 + if (!PKCS12_gen_gost_mac_key(pass, passlen, salt, saltlen, iter,
68 + md_type, md_size, key)) {
69 + PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_KEY_GEN_ERROR);
73 + if (!PKCS12_key_gen(pass, passlen, salt, saltlen, PKCS12_MAC_ID, iter,
74 + md_size, key, md_type)) {
75 PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_KEY_GEN_ERROR);