X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Frsa%2Frsa_meth.c;h=a2a0426ee41376d870e080967dd54c503f16d9f3;hb=dc8de3e6f1eed18617dc42d41dec6c6566c2ac0c;hp=731164c5615fbe7ff77394e7e5283d5ff212ef2a;hpb=6ef020c988bb508842dfcd517a4b41cae214f641;p=oweals%2Fopenssl.git diff --git a/crypto/rsa/rsa_meth.c b/crypto/rsa/rsa_meth.c index 731164c561..a2a0426ee4 100644 --- a/crypto/rsa/rsa_meth.c +++ b/crypto/rsa/rsa_meth.c @@ -1,56 +1,58 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * - * Licensed under the OpenSSL license (the "License"). You may not use + * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include -#include "rsa_locl.h" +#include "rsa_local.h" +#include RSA_METHOD *RSA_meth_new(const char *name, int flags) { - RSA_METHOD *meth = OPENSSL_zalloc(sizeof(RSA_METHOD)); + RSA_METHOD *meth = OPENSSL_zalloc(sizeof(*meth)); if (meth != NULL) { - meth->name = OPENSSL_strdup(name); - if (meth->name == NULL) { - OPENSSL_free(meth); - return NULL; - } meth->flags = flags; + + meth->name = OPENSSL_strdup(name); + if (meth->name != NULL) + return meth; + + OPENSSL_free(meth); } - return meth; + RSAerr(RSA_F_RSA_METH_NEW, ERR_R_MALLOC_FAILURE); + return NULL; } void RSA_meth_free(RSA_METHOD *meth) { if (meth != NULL) { - if (meth->name != NULL) - OPENSSL_free(meth->name); + OPENSSL_free(meth->name); OPENSSL_free(meth); } } RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth) { - RSA_METHOD *ret; - - ret = OPENSSL_malloc(sizeof(RSA_METHOD)); + RSA_METHOD *ret = OPENSSL_malloc(sizeof(*ret)); if (ret != NULL) { memcpy(ret, meth, sizeof(*meth)); + ret->name = OPENSSL_strdup(meth->name); - if (ret->name == NULL) { - OPENSSL_free(ret); - return NULL; - } + if (ret->name != NULL) + return ret; + + OPENSSL_free(ret); } - return ret; + RSAerr(RSA_F_RSA_METH_DUP, ERR_R_MALLOC_FAILURE); + return NULL; } const char *RSA_meth_get0_name(const RSA_METHOD *meth) @@ -60,11 +62,12 @@ const char *RSA_meth_get0_name(const RSA_METHOD *meth) int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) { - char *tmpname; + char *tmpname = OPENSSL_strdup(name); - tmpname = OPENSSL_strdup(name); - if (tmpname == NULL) + if (tmpname == NULL) { + RSAerr(RSA_F_RSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE); return 0; + } OPENSSL_free(meth->name); meth->name = tmpname; @@ -72,7 +75,7 @@ int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) return 1; } -int RSA_meth_get_flags(RSA_METHOD *meth) +int RSA_meth_get_flags(const RSA_METHOD *meth) { return meth->flags; } @@ -160,13 +163,13 @@ int RSA_meth_set_priv_dec(RSA_METHOD *meth, /* Can be null */ int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth)) - (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) + (BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx) { return meth->rsa_mod_exp; } int RSA_meth_set_mod_exp(RSA_METHOD *meth, - int (*mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, + int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx)) { meth->rsa_mod_exp = mod_exp; @@ -268,3 +271,17 @@ int RSA_meth_set_keygen(RSA_METHOD *meth, return 1; } +int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth)) + (RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb) +{ + return meth->rsa_multi_prime_keygen; +} + +int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth, + int (*keygen) (RSA *rsa, int bits, + int primes, BIGNUM *e, + BN_GENCB *cb)) +{ + meth->rsa_multi_prime_keygen = keygen; + return 1; +}