| OLD | NEW |
| 1 /* crypto/engine/e_chil.c -*- mode: C; c-file-style: "eay" -*- */ | 1 /* crypto/engine/e_chil.c -*- mode: C; c-file-style: "eay" -*- */ |
| 2 /* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe | 2 /* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe |
| 3 * (geoff@geoffthorpe.net) and Dr Stephen N Henson (steve@openssl.org) | 3 * (geoff@geoffthorpe.net) and Dr Stephen N Henson (steve@openssl.org) |
| 4 * for the OpenSSL project 2000. | 4 * for the OpenSSL project 2000. |
| 5 */ | 5 */ |
| 6 /* ==================================================================== | 6 /* ==================================================================== |
| 7 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. | 7 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. |
| 8 * | 8 * |
| 9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
| 10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 hwcrhk_rand_bytes, | 220 hwcrhk_rand_bytes, |
| 221 NULL, | 221 NULL, |
| 222 NULL, | 222 NULL, |
| 223 hwcrhk_rand_bytes, | 223 hwcrhk_rand_bytes, |
| 224 hwcrhk_rand_status, | 224 hwcrhk_rand_status, |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 /* Constants used when creating the ENGINE */ | 227 /* Constants used when creating the ENGINE */ |
| 228 static const char *engine_hwcrhk_id = "chil"; | 228 static const char *engine_hwcrhk_id = "chil"; |
| 229 static const char *engine_hwcrhk_name = "CHIL hardware engine support"; | 229 static const char *engine_hwcrhk_name = "CHIL hardware engine support"; |
| 230 | |
| 231 #ifndef OPENSSL_NO_DYNAMIC_ENGINE | 230 #ifndef OPENSSL_NO_DYNAMIC_ENGINE |
| 232 /* Compatibility hack, the dynamic library uses this form in the path */ | 231 /* Compatibility hack, the dynamic library uses this form in the path */ |
| 233 static const char *engine_hwcrhk_id_alt = "ncipher"; | 232 static const char *engine_hwcrhk_id_alt = "ncipher"; |
| 234 #endif | 233 #endif |
| 235 | 234 |
| 236 /* Internal stuff for HWCryptoHook */ | 235 /* Internal stuff for HWCryptoHook */ |
| 237 | 236 |
| 238 /* Some structures needed for proper use of thread locks */ | 237 /* Some structures needed for proper use of thread locks */ |
| 239 /* hwcryptohook.h has some typedefs that turn struct HWCryptoHook_MutexValue | 238 /* hwcryptohook.h has some typedefs that turn struct HWCryptoHook_MutexValue |
| 240 into HWCryptoHook_Mutex */ | 239 into HWCryptoHook_Mutex */ |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 res = EVP_PKEY_new(); | 834 res = EVP_PKEY_new(); |
| 836 EVP_PKEY_assign_RSA(res, rtmp); | 835 EVP_PKEY_assign_RSA(res, rtmp); |
| 837 #endif | 836 #endif |
| 838 | 837 |
| 839 if (!res) | 838 if (!res) |
| 840 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY, | 839 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY, |
| 841 HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED); | 840 HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED); |
| 842 | 841 |
| 843 return res; | 842 return res; |
| 844 err: | 843 err: |
| 845 if (res) | |
| 846 EVP_PKEY_free(res); | |
| 847 #ifndef OPENSSL_NO_RSA | 844 #ifndef OPENSSL_NO_RSA |
| 848 if (rtmp) | 845 if (rtmp) |
| 849 RSA_free(rtmp); | 846 RSA_free(rtmp); |
| 850 #endif | 847 #endif |
| 851 return NULL; | 848 return NULL; |
| 852 } | 849 } |
| 853 | 850 |
| 854 static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id, | 851 static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id, |
| 855 UI_METHOD *ui_method, void *callback_data) | 852 UI_METHOD *ui_method, void *callback_data) |
| 856 { | 853 { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 /* This function is aliased to mod_exp (with the mont stuff dropped). */ | 1070 /* This function is aliased to mod_exp (with the mont stuff dropped). */ |
| 1074 static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 1071 static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
| 1075 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) | 1072 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) |
| 1076 { | 1073 { |
| 1077 return hwcrhk_mod_exp(r, a, p, m, ctx); | 1074 return hwcrhk_mod_exp(r, a, p, m, ctx); |
| 1078 } | 1075 } |
| 1079 | 1076 |
| 1080 static int hwcrhk_rsa_finish(RSA *rsa) | 1077 static int hwcrhk_rsa_finish(RSA *rsa) |
| 1081 { | 1078 { |
| 1082 HWCryptoHook_RSAKeyHandle *hptr; | 1079 HWCryptoHook_RSAKeyHandle *hptr; |
| 1083 » int ret; | 1080 |
| 1084 hptr = RSA_get_ex_data(rsa, hndidx_rsa); | 1081 hptr = RSA_get_ex_data(rsa, hndidx_rsa); |
| 1085 if (hptr) | 1082 if (hptr) |
| 1086 { | 1083 { |
| 1087 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL); | 1084 p_hwcrhk_RSAUnloadKey(*hptr, NULL); |
| 1088 OPENSSL_free(hptr); | 1085 OPENSSL_free(hptr); |
| 1089 RSA_set_ex_data(rsa, hndidx_rsa, NULL); | 1086 RSA_set_ex_data(rsa, hndidx_rsa, NULL); |
| 1090 } | 1087 } |
| 1091 return 1; | 1088 return 1; |
| 1092 } | 1089 } |
| 1093 | 1090 |
| 1094 #endif | 1091 #endif |
| 1095 | 1092 |
| 1096 #ifndef OPENSSL_NO_DH | 1093 #ifndef OPENSSL_NO_DH |
| 1097 /* This function is aliased to mod_exp (with the dh and mont dropped). */ | 1094 /* This function is aliased to mod_exp (with the dh and mont dropped). */ |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 if(!bind_helper(e)) | 1347 if(!bind_helper(e)) |
| 1351 return 0; | 1348 return 0; |
| 1352 return 1; | 1349 return 1; |
| 1353 } | 1350 } |
| 1354 IMPLEMENT_DYNAMIC_CHECK_FN() | 1351 IMPLEMENT_DYNAMIC_CHECK_FN() |
| 1355 IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) | 1352 IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) |
| 1356 #endif /* OPENSSL_NO_DYNAMIC_ENGINE */ | 1353 #endif /* OPENSSL_NO_DYNAMIC_ENGINE */ |
| 1357 | 1354 |
| 1358 #endif /* !OPENSSL_NO_HW_CHIL */ | 1355 #endif /* !OPENSSL_NO_HW_CHIL */ |
| 1359 #endif /* !OPENSSL_NO_HW */ | 1356 #endif /* !OPENSSL_NO_HW */ |
| OLD | NEW |