| OLD | NEW |
| 1 /* p12_crpt.c */ | 1 /* p12_crpt.c */ |
| 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 * project 1999. | 3 * project 1999. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 * This product includes cryptographic software written by Eric Young | 53 * This product includes cryptographic software written by Eric Young |
| 54 * (eay@cryptsoft.com). This product includes software written by Tim | 54 * (eay@cryptsoft.com). This product includes software written by Tim |
| 55 * Hudson (tjh@cryptsoft.com). | 55 * Hudson (tjh@cryptsoft.com). |
| 56 * | 56 * |
| 57 */ | 57 */ |
| 58 | 58 |
| 59 #include <stdio.h> | 59 #include <stdio.h> |
| 60 #include "cryptlib.h" | 60 #include "cryptlib.h" |
| 61 #include <openssl/pkcs12.h> | 61 #include <openssl/pkcs12.h> |
| 62 | 62 |
| 63 /* PKCS#12 specific PBE functions */ | 63 /* PKCS#12 PBE algorithms now in static table */ |
| 64 | 64 |
| 65 void PKCS12_PBE_add(void) | 65 void PKCS12_PBE_add(void) |
| 66 { | 66 { |
| 67 #ifndef OPENSSL_NO_RC4 | |
| 68 EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC4, EVP_rc4(), EVP_sha1(), | |
| 69 PKCS12_PBE_keyivgen); | |
| 70 EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC4, EVP_rc4_40(), EVP_sha1(), | |
| 71 PKCS12_PBE_keyivgen); | |
| 72 #endif | |
| 73 #ifndef OPENSSL_NO_DES | |
| 74 EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC, | |
| 75 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); | |
| 76 EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC, | |
| 77 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); | |
| 78 #endif | |
| 79 #ifndef OPENSSL_NO_RC2 | |
| 80 EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(), | |
| 81 EVP_sha1(), PKCS12_PBE_keyivgen); | |
| 82 EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC2_CBC, EVP_rc2_40_cbc(), | |
| 83 EVP_sha1(), PKCS12_PBE_keyivgen); | |
| 84 #endif | |
| 85 } | 67 } |
| 86 | 68 |
| 87 int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | 69 int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, |
| 88 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, in
t en_de) | 70 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, in
t en_de) |
| 89 { | 71 { |
| 90 PBEPARAM *pbe; | 72 PBEPARAM *pbe; |
| 91 int saltlen, iter, ret; | 73 int saltlen, iter, ret; |
| 92 unsigned char *salt; | 74 unsigned char *salt; |
| 93 const unsigned char *pbuf; | 75 const unsigned char *pbuf; |
| 94 unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; | 76 unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 121 PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_IV_GEN_ERROR); | 103 PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_IV_GEN_ERROR); |
| 122 PBEPARAM_free(pbe); | 104 PBEPARAM_free(pbe); |
| 123 return 0; | 105 return 0; |
| 124 } | 106 } |
| 125 PBEPARAM_free(pbe); | 107 PBEPARAM_free(pbe); |
| 126 ret = EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de); | 108 ret = EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de); |
| 127 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); | 109 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); |
| 128 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); | 110 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); |
| 129 return ret; | 111 return ret; |
| 130 } | 112 } |
| OLD | NEW |