diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2017-09-11 10:39:26 +0100 |
---|---|---|
committer | Dimitri John Ledkov <xnox@ubuntu.com> | 2017-09-11 10:39:26 +0100 |
commit | 306f83ec518ae67cc74cb8df403ae5431725b514 (patch) | |
tree | b323301880961ef130d6f953f160f9b6326273b3 /src/s390_rsa.c | |
parent | 0ddea171d8d6a5addc7b6ce9f65d2026b7198c02 (diff) |
New upstream release LP: #1716348
Diffstat (limited to 'src/s390_rsa.c')
-rw-r--r-- | src/s390_rsa.c | 51 |
1 files changed, 3 insertions, 48 deletions
diff --git a/src/s390_rsa.c b/src/s390_rsa.c index 811d935..32664c4 100644 --- a/src/s390_rsa.c +++ b/src/s390_rsa.c @@ -19,9 +19,6 @@ #include <stdint.h> #include <openssl/crypto.h> #include <openssl/rsa.h> -#include <openssl/crypto.h> -#include <pthread.h> -#include <semaphore.h> #include <openssl/opensslconf.h> #ifdef OPENSSL_FIPS @@ -51,23 +48,9 @@ static unsigned int mod_expo_sw(int arg_length, char *arg, int exp_length, char *exp, int mod_length, char *mod, int *res_length, char *res, BN_CTX *ctx); -struct thread_data -{ - unsigned int mod_bit_length; - unsigned long *pub_exp; - RSA *rsa; -}; - -static void *__rsa_key_generate(void *ptr) +RSA* rsa_key_generate(unsigned int modulus_bit_length, + unsigned long *public_exponent) { - struct thread_data *pth_data; - unsigned int modulus_bit_length; - unsigned long *public_exponent; - - pth_data = (struct thread_data*)ptr; - modulus_bit_length = pth_data->mod_bit_length; - public_exponent = pth_data->pub_exp; - #ifdef ICA_FIPS if ((fips & ICA_FIPS_MODE) && (!FIPS_mode())) return NULL; @@ -107,41 +90,13 @@ static void *__rsa_key_generate(void *ptr) if (RSA_generate_key_ex(rsa, modulus_bit_length, exp, cb) == 0) { RSA_free(rsa); rsa = NULL; - pth_data->rsa = NULL; } BN_free(exp); #if OPENSSL_VERSION_NUMBER >= 0x10100000L BN_GENCB_free(cb); #endif /* OPENSSL_VERSION_NUMBER */ - pth_data->rsa = rsa; - return 0; -} - - -RSA* rsa_key_generate(unsigned int modulus_bit_length, - unsigned long *public_exponent) -{ - pthread_t tid; - struct thread_data th_data; - int rc; - - sem_wait(&openssl_crypto_lock_mtx); - - th_data.mod_bit_length = modulus_bit_length; - th_data.pub_exp = public_exponent; - rc = pthread_create(&(tid), NULL, (void *)&__rsa_key_generate, - (void *)(&th_data)); - if (rc) - return 0; - rc = pthread_join(tid, NULL); - - if (!rc && th_data.rsa) { - sem_post(&openssl_crypto_lock_mtx); - return th_data.rsa; - } - sem_post(&openssl_crypto_lock_mtx); - return NULL; + return rsa; } /** |