diff options
Diffstat (limited to 'src/lib/libcrypto/engine/hw_cswift.c')
-rw-r--r-- | src/lib/libcrypto/engine/hw_cswift.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c index f128ee5a68..f5c897bdbb 100644 --- a/src/lib/libcrypto/engine/hw_cswift.c +++ b/src/lib/libcrypto/engine/hw_cswift.c | |||
@@ -121,10 +121,6 @@ static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r, | |||
121 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | 121 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
122 | #endif | 122 | #endif |
123 | 123 | ||
124 | /* RAND stuff */ | ||
125 | static int cswift_rand_bytes(unsigned char *buf, int num); | ||
126 | static int cswift_rand_status(void); | ||
127 | |||
128 | /* The definitions for control commands specific to this engine */ | 124 | /* The definitions for control commands specific to this engine */ |
129 | #define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE | 125 | #define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE |
130 | static const ENGINE_CMD_DEFN cswift_cmd_defns[] = { | 126 | static const ENGINE_CMD_DEFN cswift_cmd_defns[] = { |
@@ -187,18 +183,6 @@ static DH_METHOD cswift_dh = | |||
187 | }; | 183 | }; |
188 | #endif | 184 | #endif |
189 | 185 | ||
190 | static RAND_METHOD cswift_random = | ||
191 | { | ||
192 | /* "CryptoSwift RAND method", */ | ||
193 | NULL, | ||
194 | cswift_rand_bytes, | ||
195 | NULL, | ||
196 | NULL, | ||
197 | cswift_rand_bytes, | ||
198 | cswift_rand_status, | ||
199 | }; | ||
200 | |||
201 | |||
202 | /* Constants used when creating the ENGINE */ | 186 | /* Constants used when creating the ENGINE */ |
203 | static const char *engine_cswift_id = "cswift"; | 187 | static const char *engine_cswift_id = "cswift"; |
204 | static const char *engine_cswift_name = "CryptoSwift hardware engine support"; | 188 | static const char *engine_cswift_name = "CryptoSwift hardware engine support"; |
@@ -224,7 +208,6 @@ static int bind_helper(ENGINE *e) | |||
224 | #ifndef OPENSSL_NO_DH | 208 | #ifndef OPENSSL_NO_DH |
225 | !ENGINE_set_DH(e, &cswift_dh) || | 209 | !ENGINE_set_DH(e, &cswift_dh) || |
226 | #endif | 210 | #endif |
227 | !ENGINE_set_RAND(e, &cswift_random) || | ||
228 | !ENGINE_set_destroy_function(e, cswift_destroy) || | 211 | !ENGINE_set_destroy_function(e, cswift_destroy) || |
229 | !ENGINE_set_init_function(e, cswift_init) || | 212 | !ENGINE_set_init_function(e, cswift_init) || |
230 | !ENGINE_set_finish_function(e, cswift_finish) || | 213 | !ENGINE_set_finish_function(e, cswift_finish) || |
@@ -259,7 +242,6 @@ static int bind_helper(ENGINE *e) | |||
259 | return 1; | 242 | return 1; |
260 | } | 243 | } |
261 | 244 | ||
262 | #ifndef ENGINE_DYNAMIC_SUPPORT | ||
263 | static ENGINE *engine_cswift(void) | 245 | static ENGINE *engine_cswift(void) |
264 | { | 246 | { |
265 | ENGINE *ret = ENGINE_new(); | 247 | ENGINE *ret = ENGINE_new(); |
@@ -282,7 +264,6 @@ void ENGINE_load_cswift(void) | |||
282 | ENGINE_free(toadd); | 264 | ENGINE_free(toadd); |
283 | ERR_clear_error(); | 265 | ERR_clear_error(); |
284 | } | 266 | } |
285 | #endif | ||
286 | 267 | ||
287 | /* This is a process-global DSO handle used for loading and unloading | 268 | /* This is a process-global DSO handle used for loading and unloading |
288 | * the CryptoSwift library. NB: This is only set (or unset) during an | 269 | * the CryptoSwift library. NB: This is only set (or unset) during an |
@@ -924,60 +905,6 @@ static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r, | |||
924 | } | 905 | } |
925 | #endif | 906 | #endif |
926 | 907 | ||
927 | /* Random bytes are good */ | ||
928 | static int cswift_rand_bytes(unsigned char *buf, int num) | ||
929 | { | ||
930 | SW_CONTEXT_HANDLE hac; | ||
931 | SW_STATUS swrc; | ||
932 | SW_LARGENUMBER largenum; | ||
933 | size_t nbytes = 0; | ||
934 | int acquired = 0; | ||
935 | int to_return = 0; /* assume failure */ | ||
936 | |||
937 | if (!get_context(&hac)) | ||
938 | { | ||
939 | CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_UNIT_FAILURE); | ||
940 | goto err; | ||
941 | } | ||
942 | acquired = 1; | ||
943 | |||
944 | while (nbytes < (size_t)num) | ||
945 | { | ||
946 | /* tell CryptoSwift how many bytes we want and where we want it. | ||
947 | * Note: - CryptoSwift cannot do more than 4096 bytes at a time. | ||
948 | * - CryptoSwift can only do multiple of 32-bits. */ | ||
949 | largenum.value = (SW_BYTE *) buf + nbytes; | ||
950 | if (4096 > num - nbytes) | ||
951 | largenum.nbytes = num - nbytes; | ||
952 | else | ||
953 | largenum.nbytes = 4096; | ||
954 | |||
955 | swrc = p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1); | ||
956 | if (swrc != SW_OK) | ||
957 | { | ||
958 | char tmpbuf[20]; | ||
959 | CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_REQUEST_FAILED); | ||
960 | sprintf(tmpbuf, "%ld", swrc); | ||
961 | ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); | ||
962 | goto err; | ||
963 | } | ||
964 | |||
965 | nbytes += largenum.nbytes; | ||
966 | } | ||
967 | to_return = 1; /* success */ | ||
968 | |||
969 | err: | ||
970 | if (acquired) | ||
971 | release_context(hac); | ||
972 | return to_return; | ||
973 | } | ||
974 | |||
975 | static int cswift_rand_status(void) | ||
976 | { | ||
977 | return 1; | ||
978 | } | ||
979 | |||
980 | |||
981 | /* This stuff is needed if this ENGINE is being compiled into a self-contained | 908 | /* This stuff is needed if this ENGINE is being compiled into a self-contained |
982 | * shared-library. */ | 909 | * shared-library. */ |
983 | #ifdef ENGINE_DYNAMIC_SUPPORT | 910 | #ifdef ENGINE_DYNAMIC_SUPPORT |