X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=engines%2Fe_4758cca.c;h=443182bd31e95c676455341841b401ac5c8a50f1;hp=7d850a854b991b64348fe634ea86c56e2266517b;hb=b9b0a177f853cb01ab48881383f81afb08058460;hpb=45d8574b93e9f1e14c62b765220b370f7c37eaa3 diff --git a/engines/e_4758cca.c b/engines/e_4758cca.c index 7d850a854b..443182bd31 100644 --- a/engines/e_4758cca.c +++ b/engines/e_4758cca.c @@ -61,7 +61,9 @@ #include #include #include +#ifndef OPENSSL_NO_RSA #include +#endif #include #ifndef OPENSSL_NO_HW @@ -90,7 +92,7 @@ static int cca_rsa_priv_dec(int flen, const unsigned char *from, static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, const RSA *rsa); static int cca_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, - unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); + const unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); /* utility functions */ /*-----------------------*/ @@ -106,11 +108,13 @@ static int getModulusAndExponent(const unsigned char *token, long *exponentLengt /* RAND number functions */ /*-----------------------*/ -static int cca_get_random_bytes(unsigned char*, int ); +static int cca_get_random_bytes(unsigned char*, int); static int cca_random_status(void); +#ifndef OPENSSL_NO_RSA static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,long argl, void *argp); +#endif /* Function pointers for CCA verbs */ /*---------------------------------*/ @@ -154,7 +158,9 @@ static const char* n_pkaDecrypt = CSNDPKD; #endif static const char* n_randomNumberGenerate = CSNBRNG; +#ifndef OPENSSL_NO_RSA static int hndidx = -1; +#endif static DSO *dso = NULL; /* openssl engine initialization structures */ @@ -221,8 +227,10 @@ static int bind_helper(ENGINE *e) !ENGINE_set_init_function(e, ibm_4758_cca_init) || !ENGINE_set_finish_function(e, ibm_4758_cca_finish) || !ENGINE_set_ctrl_function(e, ibm_4758_cca_ctrl) || +#ifndef OPENSSL_NO_RSA !ENGINE_set_load_privkey_function(e, ibm_4758_load_privkey) || !ENGINE_set_load_pubkey_function(e, ibm_4758_load_pubkey) || +#endif !ENGINE_set_cmd_defns(e, cca4758_cmd_defns)) return 0; /* Ensure the error handling is set up */ @@ -304,8 +312,10 @@ static int ibm_4758_cca_init(ENGINE *e) } #endif +#ifndef OPENSSL_NO_RSA hndidx = RSA_get_ex_new_index(0, "IBM 4758 CCA RSA key handle", NULL, NULL, cca_ex_free); +#endif return 1; err: @@ -313,13 +323,15 @@ err: DSO_free(dso); dso = NULL; +#ifndef OPENSSL_NO_RSA keyRecordRead = (F_KEYRECORDREAD)0; - randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0; digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0; digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0; publicKeyExtract = (F_PUBLICKEYEXTRACT)0; pkaEncrypt = (F_PKAENCRYPT)0; pkaDecrypt = (F_PKADECRYPT)0; +#endif + randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0; return 0; } @@ -339,6 +351,7 @@ static int ibm_4758_cca_finish(ENGINE *e) return 0; } dso = NULL; +#ifndef OPENSSL_NO_RSA keyRecordRead = (F_KEYRECORDREAD)0; randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0; digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0; @@ -346,6 +359,8 @@ static int ibm_4758_cca_finish(ENGINE *e) publicKeyExtract = (F_PUBLICKEYEXTRACT)0; pkaEncrypt = (F_PKAENCRYPT)0; pkaDecrypt = (F_PKADECRYPT)0; +#endif + randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0; return 1; } @@ -467,10 +482,6 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id, err: if (keyToken) OPENSSL_free(keyToken); - if (res) - EVP_PKEY_free(res); - if (rtmp) - RSA_free(rtmp); return NULL; } @@ -545,10 +556,6 @@ static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id, err: if (keyToken) OPENSSL_free(keyToken); - if (res) - EVP_PKEY_free(res); - if (rtmp) - RSA_free(rtmp); return NULL; } @@ -611,7 +618,7 @@ static int cca_rsa_priv_dec(int flen, const unsigned char *from, #define SSL_SIG_LEN 36 static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len, - unsigned char *sigbuf, unsigned int siglen, const RSA *rsa) + const unsigned char *sigbuf, unsigned int siglen, const RSA *rsa) { long returnCode; long reasonCode; @@ -720,7 +727,8 @@ static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len, digitalSignatureVerify(&returnCode, &reasonCode, &exitDataLength, exitData, &ruleArrayLength, ruleArray, &keyTokenLength, - keyToken, &length, hashBuffer, &lsiglen, sigbuf); + keyToken, &length, hashBuffer, &lsiglen, + (unsigned char *)sigbuf); if (type == NID_sha1 || type == NID_md5) { @@ -951,12 +959,14 @@ static int cca_get_random_bytes(unsigned char* buf, int num) return 1; } +#ifndef OPENSSL_NO_RSA static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx, long argl, void *argp) { if (item) OPENSSL_free(item); } +#endif /* Goo to handle building as a dynamic engine */ #ifndef OPENSSL_NO_DYNAMIC_ENGINE