diff options
-rw-r--r-- | src/_cffi_src/openssl/rsa.py | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/_cffi_src/openssl/rsa.py b/src/_cffi_src/openssl/rsa.py index 79c968bc..45e5379f 100644 --- a/src/_cffi_src/openssl/rsa.py +++ b/src/_cffi_src/openssl/rsa.py @@ -55,9 +55,11 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *, int, const unsigned char *, int RSA_set0_key(RSA *, BIGNUM *, BIGNUM *, BIGNUM *); int RSA_set0_factors(RSA *, BIGNUM *, BIGNUM *); int RSA_set0_crt_params(RSA *, BIGNUM *, BIGNUM *, BIGNUM *); -void RSA_get0_key(const RSA *, BIGNUM **, BIGNUM **, BIGNUM **); -void RSA_get0_factors(const RSA *, BIGNUM **, BIGNUM **); -void RSA_get0_crt_params(const RSA *, BIGNUM **, BIGNUM **, BIGNUM **); +void RSA_get0_key(const RSA *, const BIGNUM **, const BIGNUM **, + const BIGNUM **); +void RSA_get0_factors(const RSA *, const BIGNUM **, const BIGNUM **); +void RSA_get0_crt_params(const RSA *, const BIGNUM **, const BIGNUM **, + const BIGNUM **); """ MACROS = """ @@ -88,15 +90,12 @@ int (*EVP_PKEY_CTX_set_rsa_oaep_md)(EVP_PKEY_CTX *, EVP_MD *) = NULL; #if OPENSSL_VERSION_NUMBER < 0x10100005 || defined(LIBRESSL_VERSION_NUMBER) int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { - /* If the fields in r are NULL, the corresponding input + /* If the fields n and e in r are NULL, the corresponding input * parameters MUST be non-NULL for n and e. d may be * left NULL (in case only the public key is used). - * - * It is an error to give the results from get0 on r - * as input parameters. */ - if (n == r->n || e == r->e - || (r->d != NULL && d == r->d)) + if ((r->n == NULL && n == NULL) + || (r->e == NULL && e == NULL)) return 0; if (n != NULL) { @@ -117,13 +116,11 @@ int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) { - /* If the fields in r are NULL, the corresponding input + /* If the fields p and q in r are NULL, the corresponding input * parameters MUST be non-NULL. - * - * It is an error to give the results from get0 on r - * as input parameters. */ - if (p == r->p || q == r->q) + if ((r->p == NULL && p == NULL) + || (r->q == NULL && q == NULL)) return 0; if (p != NULL) { @@ -140,13 +137,12 @@ int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) { - /* If the fields in r are NULL, the corresponding input + /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input * parameters MUST be non-NULL. - * - * It is an error to give the results from get0 on r - * as input parameters. */ - if (dmp1 == r->dmp1 || dmq1 == r->dmq1 || iqmp == r->iqmp) + if ((r->dmp1 == NULL && dmp1 == NULL) + || (r->dmq1 == NULL && dmq1 == NULL) + || (r->iqmp == NULL && iqmp == NULL)) return 0; if (dmp1 != NULL) { @@ -165,7 +161,8 @@ int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) return 1; } -void RSA_get0_key(const RSA *r, BIGNUM **n, BIGNUM **e, BIGNUM **d) +void RSA_get0_key(const RSA *r, + const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) { if (n != NULL) *n = r->n; @@ -175,7 +172,7 @@ void RSA_get0_key(const RSA *r, BIGNUM **n, BIGNUM **e, BIGNUM **d) *d = r->d; } -void RSA_get0_factors(const RSA *r, BIGNUM **p, BIGNUM **q) +void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) { if (p != NULL) *p = r->p; @@ -184,7 +181,8 @@ void RSA_get0_factors(const RSA *r, BIGNUM **p, BIGNUM **q) } void RSA_get0_crt_params(const RSA *r, - BIGNUM **dmp1, BIGNUM **dmq1, BIGNUM **iqmp) + const BIGNUM **dmp1, const BIGNUM **dmq1, + const BIGNUM **iqmp) { if (dmp1 != NULL) *dmp1 = r->dmp1; |