Deleted Added
sdiff udiff text old ( 206046 ) new ( 215697 )
full compact
1/* crypto/engine/e_chil.c -*- mode: C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe
3 * (geoff@geoffthorpe.net) and Dr Stephen N Henson (steve@openssl.org)
4 * for the OpenSSL project 2000.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
8 *

--- 97 unchanged lines hidden (view full) ---

106
107/* BIGNUM stuff */
108static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
109 const BIGNUM *m, BN_CTX *ctx);
110
111#ifndef OPENSSL_NO_RSA
112/* RSA stuff */
113static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
114#endif
115#ifndef OPENSSL_NO_RSA
116/* This function is aliased to mod_exp (with the mont stuff dropped). */
117static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
118 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
119#endif
120
121#ifndef OPENSSL_NO_DH
122/* DH stuff */
123/* This function is alised to mod_exp (with the DH and mont dropped). */
124static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
125 const BIGNUM *a, const BIGNUM *p,
126 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
127#endif
128
129/* RAND stuff */
130static int hwcrhk_rand_bytes(unsigned char *buf, int num);
131static int hwcrhk_rand_status(void);
132
133/* KM stuff */
134static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
135 UI_METHOD *ui_method, void *callback_data);
136static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
137 UI_METHOD *ui_method, void *callback_data);
138#ifndef OPENSSL_NO_RSA
139static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
140 int ind,long argl, void *argp);
141#endif
142
143/* Interaction stuff */
144static int hwcrhk_insert_card(const char *prompt_info,
145 const char *wrong_info,
146 HWCryptoHook_PassphraseContext *ppctx,
147 HWCryptoHook_CallerContext *cactx);
148static int hwcrhk_get_pass(const char *prompt_info,
149 int *len_io, char *buf,

--- 38 unchanged lines hidden (view full) ---

188 "CHIL RSA method",
189 NULL,
190 NULL,
191 NULL,
192 NULL,
193 hwcrhk_rsa_mod_exp,
194 hwcrhk_mod_exp_mont,
195 NULL,
196 NULL,
197 0,
198 NULL,
199 NULL,
200 NULL,
201 NULL
202 };
203#endif
204

--- 393 unchanged lines hidden (view full) ---

598 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_UNIT_FAILURE);
599 goto err;
600 }
601 /* Everything's fine. */
602#ifndef OPENSSL_NO_RSA
603 if (hndidx_rsa == -1)
604 hndidx_rsa = RSA_get_ex_new_index(0,
605 "nFast HWCryptoHook RSA key handle",
606 NULL, NULL, hwcrhk_ex_free);
607#endif
608 return 1;
609err:
610 if(hwcrhk_dso)
611 DSO_free(hwcrhk_dso);
612 hwcrhk_dso = NULL;
613 p_hwcrhk_Init = NULL;
614 p_hwcrhk_Finish = NULL;

--- 461 unchanged lines hidden (view full) ---

1076
1077#ifndef OPENSSL_NO_RSA
1078/* This function is aliased to mod_exp (with the mont stuff dropped). */
1079static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1080 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1081 {
1082 return hwcrhk_mod_exp(r, a, p, m, ctx);
1083 }
1084#endif
1085
1086#ifndef OPENSSL_NO_DH
1087/* This function is aliased to mod_exp (with the dh and mont dropped). */
1088static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
1089 const BIGNUM *a, const BIGNUM *p,
1090 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1091 {

--- 42 unchanged lines hidden (view full) ---

1134 return to_return;
1135 }
1136
1137static int hwcrhk_rand_status(void)
1138 {
1139 return 1;
1140 }
1141
1142/* This cleans up an RSA KM key, called when ex_data is freed */
1143#ifndef OPENSSL_NO_RSA
1144static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
1145 int ind,long argl, void *argp)
1146{
1147 char tempbuf[1024];
1148 HWCryptoHook_ErrMsgBuf rmsg;
1149#ifndef OPENSSL_NO_RSA
1150 HWCryptoHook_RSAKeyHandle *hptr;
1151#endif
1152#if !defined(OPENSSL_NO_RSA)
1153 int ret;
1154#endif
1155
1156 rmsg.buf = tempbuf;
1157 rmsg.size = sizeof(tempbuf);
1158
1159#ifndef OPENSSL_NO_RSA
1160 hptr = (HWCryptoHook_RSAKeyHandle *) item;
1161 if(hptr)
1162 {
1163 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
1164 OPENSSL_free(hptr);
1165 }
1166#endif
1167}
1168#endif
1169
1170/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
1171 * these just wrap the POSIX functions and add some logging.
1172 */
1173
1174static int hwcrhk_mutex_init(HWCryptoHook_Mutex* mt,
1175 HWCryptoHook_CallerContext *cactx)
1176 {
1177 mt->lockid = CRYPTO_get_new_dynlockid();

--- 133 unchanged lines hidden (view full) ---

1311 char answer;
1312 char buf[BUFSIZ];
1313 /* Despite what the documentation says wrong_info can be
1314 * an empty string.
1315 */
1316 if (wrong_info && *wrong_info)
1317 BIO_snprintf(buf, sizeof(buf)-1,
1318 "Current card: \"%s\"\n", wrong_info);
1319 ok = UI_dup_info_string(ui, buf);
1320 if (ok >= 0 && prompt_info)
1321 {
1322 BIO_snprintf(buf, sizeof(buf)-1,
1323 "Insert card \"%s\"", prompt_info);
1324 ok = UI_dup_input_boolean(ui, buf,
1325 "\n then hit <enter> or C<enter> to cancel\n",
1326 "\r\n", "Cc", UI_INPUT_FLAG_ECHO, &answer);

--- 49 unchanged lines hidden ---