This commit is contained in:
purplerain 2023-07-10 00:10:46 +00:00
parent 2a351e0cdc
commit f57be82572
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
704 changed files with 20524 additions and 10572 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_ameth.c,v 1.29 2023/05/19 17:31:20 tb Exp $ */
/* $OpenBSD: rsa_ameth.c,v 1.30 2023/07/07 06:59:18 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -68,6 +68,7 @@
#include <openssl/x509.h>
#include "asn1_local.h"
#include "bn_local.h"
#include "cryptlib.h"
#include "evp_local.h"
#include "rsa_local.h"
@ -408,44 +409,13 @@ rsa_pss_param_print(BIO *bp, int pss_key, RSA_PSS_PARAMS *pss, int indent)
}
static void
update_buflen(const BIGNUM *b, size_t *pbuflen)
{
size_t i;
if (!b)
return;
if (*pbuflen < (i = (size_t)BN_num_bytes(b)))
*pbuflen = i;
}
static int
pkey_rsa_print(BIO *bp, const EVP_PKEY *pkey, int off, int priv)
{
const RSA *x = pkey->pkey.rsa;
unsigned char *m = NULL;
char *str;
const char *s;
int ret = 0, mod_len = 0;
size_t buf_len = 0;
update_buflen(x->n, &buf_len);
update_buflen(x->e, &buf_len);
if (priv) {
update_buflen(x->d, &buf_len);
update_buflen(x->p, &buf_len);
update_buflen(x->q, &buf_len);
update_buflen(x->dmp1, &buf_len);
update_buflen(x->dmq1, &buf_len);
update_buflen(x->iqmp, &buf_len);
}
m = malloc(buf_len + 10);
if (m == NULL) {
RSAerror(ERR_R_MALLOC_FAILURE);
goto err;
}
if (x->n != NULL)
mod_len = BN_num_bits(x->n);
@ -467,29 +437,28 @@ pkey_rsa_print(BIO *bp, const EVP_PKEY *pkey, int off, int priv)
str = "Modulus:";
s = "Exponent:";
}
if (!ASN1_bn_print(bp, str, x->n, m, off))
if (!bn_printf(bp, x->n, off, "%s", str))
goto err;
if (!ASN1_bn_print(bp, s, x->e, m, off))
if (!bn_printf(bp, x->e, off, "%s", s))
goto err;
if (priv) {
if (!ASN1_bn_print(bp, "privateExponent:", x->d, m, off))
if (!bn_printf(bp, x->d, off, "privateExponent:"))
goto err;
if (!ASN1_bn_print(bp, "prime1:", x->p, m, off))
if (!bn_printf(bp, x->p, off, "prime1:"))
goto err;
if (!ASN1_bn_print(bp, "prime2:", x->q, m, off))
if (!bn_printf(bp, x->q, off, "prime2:"))
goto err;
if (!ASN1_bn_print(bp, "exponent1:", x->dmp1, m, off))
if (!bn_printf(bp, x->dmp1, off, "exponent1:"))
goto err;
if (!ASN1_bn_print(bp, "exponent2:", x->dmq1, m, off))
if (!bn_printf(bp, x->dmq1, off, "exponent2:"))
goto err;
if (!ASN1_bn_print(bp, "coefficient:", x->iqmp, m, off))
if (!bn_printf(bp, x->iqmp, off, "coefficient:"))
goto err;
}
if (pkey_is_pss(pkey) && !rsa_pss_param_print(bp, 1, x->pss, off))
goto err;
ret = 1;
err:
free(m);
return ret;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_asn1.c,v 1.16 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_asn1.c,v 1.17 2023/07/08 12:26:45 beck Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@ -269,24 +269,28 @@ d2i_RSA_PSS_PARAMS(RSA_PSS_PARAMS **a, const unsigned char **in, long len)
return (RSA_PSS_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
&RSA_PSS_PARAMS_it);
}
LCRYPTO_ALIAS(d2i_RSA_PSS_PARAMS);
int
i2d_RSA_PSS_PARAMS(RSA_PSS_PARAMS *a, unsigned char **out)
{
return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSA_PSS_PARAMS_it);
}
LCRYPTO_ALIAS(i2d_RSA_PSS_PARAMS);
RSA_PSS_PARAMS *
RSA_PSS_PARAMS_new(void)
{
return (RSA_PSS_PARAMS *)ASN1_item_new(&RSA_PSS_PARAMS_it);
}
LCRYPTO_ALIAS(RSA_PSS_PARAMS_new);
void
RSA_PSS_PARAMS_free(RSA_PSS_PARAMS *a)
{
ASN1_item_free((ASN1_VALUE *)a, &RSA_PSS_PARAMS_it);
}
LCRYPTO_ALIAS(RSA_PSS_PARAMS_free);
static int
rsa_oaep_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
@ -349,24 +353,28 @@ d2i_RSA_OAEP_PARAMS(RSA_OAEP_PARAMS **a, const unsigned char **in, long len)
return (RSA_OAEP_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
&RSA_OAEP_PARAMS_it);
}
LCRYPTO_ALIAS(d2i_RSA_OAEP_PARAMS);
int
i2d_RSA_OAEP_PARAMS(RSA_OAEP_PARAMS *a, unsigned char **out)
{
return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSA_OAEP_PARAMS_it);
}
LCRYPTO_ALIAS(i2d_RSA_OAEP_PARAMS);
RSA_OAEP_PARAMS *
RSA_OAEP_PARAMS_new(void)
{
return (RSA_OAEP_PARAMS *)ASN1_item_new(&RSA_OAEP_PARAMS_it);
}
LCRYPTO_ALIAS(RSA_OAEP_PARAMS_new);
void
RSA_OAEP_PARAMS_free(RSA_OAEP_PARAMS *a)
{
ASN1_item_free((ASN1_VALUE *)a, &RSA_OAEP_PARAMS_it);
}
LCRYPTO_ALIAS(RSA_OAEP_PARAMS_free);
RSA *
d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len)
@ -374,12 +382,14 @@ d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len)
return (RSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
&RSAPrivateKey_it);
}
LCRYPTO_ALIAS(d2i_RSAPrivateKey);
int
i2d_RSAPrivateKey(const RSA *a, unsigned char **out)
{
return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSAPrivateKey_it);
}
LCRYPTO_ALIAS(i2d_RSAPrivateKey);
RSA *
@ -388,21 +398,25 @@ d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len)
return (RSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
&RSAPublicKey_it);
}
LCRYPTO_ALIAS(d2i_RSAPublicKey);
int
i2d_RSAPublicKey(const RSA *a, unsigned char **out)
{
return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSAPublicKey_it);
}
LCRYPTO_ALIAS(i2d_RSAPublicKey);
RSA *
RSAPublicKey_dup(RSA *rsa)
{
return ASN1_item_dup(&RSAPublicKey_it, rsa);
}
LCRYPTO_ALIAS(RSAPublicKey_dup);
RSA *
RSAPrivateKey_dup(RSA *rsa)
{
return ASN1_item_dup(&RSAPrivateKey_it, rsa);
}
LCRYPTO_ALIAS(RSAPrivateKey_dup);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_chk.c,v 1.17 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_chk.c,v 1.18 2023/07/08 12:26:45 beck Exp $ */
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
*
@ -220,3 +220,4 @@ err:
return (ret);
}
LCRYPTO_ALIAS(RSA_check_key);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_crpt.c,v 1.21 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_crpt.c,v 1.22 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -78,12 +78,14 @@ RSA_bits(const RSA *r)
{
return BN_num_bits(r->n);
}
LCRYPTO_ALIAS(RSA_bits);
int
RSA_size(const RSA *r)
{
return BN_num_bytes(r->n);
}
LCRYPTO_ALIAS(RSA_size);
int
RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
@ -91,6 +93,7 @@ RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
{
return rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);
}
LCRYPTO_ALIAS(RSA_public_encrypt);
int
RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
@ -98,6 +101,7 @@ RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
{
return rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);
}
LCRYPTO_ALIAS(RSA_private_encrypt);
int
RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
@ -105,6 +109,7 @@ RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
{
return rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);
}
LCRYPTO_ALIAS(RSA_private_decrypt);
int
RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
@ -112,12 +117,14 @@ RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
{
return rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);
}
LCRYPTO_ALIAS(RSA_public_decrypt);
int
RSA_flags(const RSA *r)
{
return r == NULL ? 0 : r->meth->flags;
}
LCRYPTO_ALIAS(RSA_flags);
void
RSA_blinding_off(RSA *rsa)
@ -126,6 +133,7 @@ RSA_blinding_off(RSA *rsa)
rsa->blinding = NULL;
rsa->flags |= RSA_FLAG_NO_BLINDING;
}
LCRYPTO_ALIAS(RSA_blinding_off);
int
RSA_blinding_on(RSA *rsa, BN_CTX *ctx)
@ -144,6 +152,7 @@ RSA_blinding_on(RSA *rsa, BN_CTX *ctx)
err:
return (ret);
}
LCRYPTO_ALIAS(RSA_blinding_on);
static BIGNUM *
rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p, const BIGNUM *q,
@ -220,3 +229,4 @@ err:
return ret;
}
LCRYPTO_ALIAS(RSA_setup_blinding);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_eay.c,v 1.60 2023/05/05 12:21:44 tb Exp $ */
/* $OpenBSD: rsa_eay.c,v 1.62 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -121,44 +121,8 @@
#include "bn_local.h"
#include "rsa_local.h"
static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx);
static int RSA_eay_init(RSA *rsa);
static int RSA_eay_finish(RSA *rsa);
static RSA_METHOD rsa_pkcs1_eay_meth = {
.name = "Eric Young's PKCS#1 RSA",
.rsa_pub_enc = RSA_eay_public_encrypt,
.rsa_pub_dec = RSA_eay_public_decrypt, /* signature verification */
.rsa_priv_enc = RSA_eay_private_encrypt, /* signing */
.rsa_priv_dec = RSA_eay_private_decrypt,
.rsa_mod_exp = RSA_eay_mod_exp,
.bn_mod_exp = BN_mod_exp_mont_ct, /* XXX probably we should not use Montgomery if e == 3 */
.init = RSA_eay_init,
.finish = RSA_eay_finish,
};
const RSA_METHOD *
RSA_PKCS1_OpenSSL(void)
{
return &rsa_pkcs1_eay_meth;
}
const RSA_METHOD *
RSA_PKCS1_SSLeay(void)
{
return &rsa_pkcs1_eay_meth;
}
static int
RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
rsa_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
RSA *rsa, int padding)
{
BIGNUM *f, *ret;
@ -348,7 +312,7 @@ rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, BN_CTX *ctx)
/* signing */
static int
RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
rsa_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
RSA *rsa, int padding)
{
BIGNUM *f, *ret, *res;
@ -476,7 +440,7 @@ err:
}
static int
RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
rsa_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
RSA *rsa, int padding)
{
BIGNUM *f, *ret;
@ -601,7 +565,7 @@ err:
/* signature verification */
static int
RSA_eay_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
rsa_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
RSA *rsa, int padding)
{
BIGNUM *f, *ret;
@ -701,7 +665,7 @@ err:
}
static int
RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
{
BIGNUM *r1, *m1, *vrfy;
BIGNUM dmp1, dmq1, c, pr1;
@ -852,14 +816,14 @@ err:
}
static int
RSA_eay_init(RSA *rsa)
rsa_init(RSA *rsa)
{
rsa->flags |= RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE;
return 1;
}
static int
RSA_eay_finish(RSA *rsa)
rsa_finish(RSA *rsa)
{
BN_MONT_CTX_free(rsa->_method_mod_n);
BN_MONT_CTX_free(rsa->_method_mod_p);
@ -867,3 +831,29 @@ RSA_eay_finish(RSA *rsa)
return 1;
}
static const RSA_METHOD rsa_pkcs1_meth = {
.name = "OpenSSL PKCS#1 RSA",
.rsa_pub_enc = rsa_public_encrypt,
.rsa_pub_dec = rsa_public_decrypt, /* signature verification */
.rsa_priv_enc = rsa_private_encrypt, /* signing */
.rsa_priv_dec = rsa_private_decrypt,
.rsa_mod_exp = rsa_mod_exp,
.bn_mod_exp = BN_mod_exp_mont_ct, /* XXX probably we should not use Montgomery if e == 3 */
.init = rsa_init,
.finish = rsa_finish,
};
const RSA_METHOD *
RSA_PKCS1_OpenSSL(void)
{
return &rsa_pkcs1_meth;
}
LCRYPTO_ALIAS(RSA_PKCS1_OpenSSL);
const RSA_METHOD *
RSA_PKCS1_SSLeay(void)
{
return RSA_PKCS1_OpenSSL();
}
LCRYPTO_ALIAS(RSA_PKCS1_SSLeay);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_err.c,v 1.21 2022/07/12 14:42:50 kn Exp $ */
/* $OpenBSD: rsa_err.c,v 1.22 2023/07/08 12:26:45 beck Exp $ */
/* ====================================================================
* Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
*
@ -155,3 +155,4 @@ ERR_load_RSA_strings(void)
}
#endif
}
LCRYPTO_ALIAS(ERR_load_RSA_strings);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_gen.c,v 1.29 2023/04/13 15:18:29 tb Exp $ */
/* $OpenBSD: rsa_gen.c,v 1.30 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -75,6 +75,7 @@ RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb)
return rsa->meth->rsa_keygen(rsa, bits, e_value, cb);
return rsa_builtin_keygen(rsa, bits, e_value, cb);
}
LCRYPTO_ALIAS(RSA_generate_key_ex);
static int
rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb)
@ -253,3 +254,4 @@ err:
return 0;
}
LCRYPTO_ALIAS(RSA_generate_key);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_lib.c,v 1.46 2023/03/11 21:14:26 tb Exp $ */
/* $OpenBSD: rsa_lib.c,v 1.47 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -83,12 +83,14 @@ RSA_new(void)
return r;
}
LCRYPTO_ALIAS(RSA_new);
void
RSA_set_default_method(const RSA_METHOD *meth)
{
default_RSA_meth = meth;
}
LCRYPTO_ALIAS(RSA_set_default_method);
const RSA_METHOD *
RSA_get_default_method(void)
@ -98,12 +100,14 @@ RSA_get_default_method(void)
return default_RSA_meth;
}
LCRYPTO_ALIAS(RSA_get_default_method);
const RSA_METHOD *
RSA_get_method(const RSA *rsa)
{
return rsa->meth;
}
LCRYPTO_ALIAS(RSA_get_method);
int
RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
@ -126,6 +130,7 @@ RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
meth->init(rsa);
return 1;
}
LCRYPTO_ALIAS(RSA_set_method);
RSA *
RSA_new_method(ENGINE *engine)
@ -179,6 +184,7 @@ RSA_new_method(ENGINE *engine)
return NULL;
}
LCRYPTO_ALIAS(RSA_new_method);
void
RSA_free(RSA *r)
@ -213,6 +219,7 @@ RSA_free(RSA *r)
RSA_PSS_PARAMS_free(r->pss);
free(r);
}
LCRYPTO_ALIAS(RSA_free);
int
RSA_up_ref(RSA *r)
@ -220,6 +227,7 @@ RSA_up_ref(RSA *r)
int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
return i > 1 ? 1 : 0;
}
LCRYPTO_ALIAS(RSA_up_ref);
int
RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
@ -228,24 +236,28 @@ RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp,
new_func, dup_func, free_func);
}
LCRYPTO_ALIAS(RSA_get_ex_new_index);
int
RSA_set_ex_data(RSA *r, int idx, void *arg)
{
return CRYPTO_set_ex_data(&r->ex_data, idx, arg);
}
LCRYPTO_ALIAS(RSA_set_ex_data);
void *
RSA_get_ex_data(const RSA *r, int idx)
{
return CRYPTO_get_ex_data(&r->ex_data, idx);
}
LCRYPTO_ALIAS(RSA_get_ex_data);
int
RSA_security_bits(const RSA *rsa)
{
return BN_security_bits(RSA_bits(rsa), -1);
}
LCRYPTO_ALIAS(RSA_security_bits);
void
RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
@ -257,6 +269,7 @@ RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
if (d != NULL)
*d = r->d;
}
LCRYPTO_ALIAS(RSA_get0_key);
int
RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
@ -279,6 +292,7 @@ RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
return 1;
}
LCRYPTO_ALIAS(RSA_set0_key);
void
RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
@ -291,6 +305,7 @@ RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
if (iqmp != NULL)
*iqmp = r->iqmp;
}
LCRYPTO_ALIAS(RSA_get0_crt_params);
int
RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
@ -315,6 +330,7 @@ RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
return 1;
}
LCRYPTO_ALIAS(RSA_set0_crt_params);
void
RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
@ -324,6 +340,7 @@ RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
if (q != NULL)
*q = r->q;
}
LCRYPTO_ALIAS(RSA_get0_factors);
int
RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q)
@ -342,78 +359,91 @@ RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q)
return 1;
}
LCRYPTO_ALIAS(RSA_set0_factors);
const BIGNUM *
RSA_get0_n(const RSA *r)
{
return r->n;
}
LCRYPTO_ALIAS(RSA_get0_n);
const BIGNUM *
RSA_get0_e(const RSA *r)
{
return r->e;
}
LCRYPTO_ALIAS(RSA_get0_e);
const BIGNUM *
RSA_get0_d(const RSA *r)
{
return r->d;
}
LCRYPTO_ALIAS(RSA_get0_d);
const BIGNUM *
RSA_get0_p(const RSA *r)
{
return r->p;
}
LCRYPTO_ALIAS(RSA_get0_p);
const BIGNUM *
RSA_get0_q(const RSA *r)
{
return r->q;
}
LCRYPTO_ALIAS(RSA_get0_q);
const BIGNUM *
RSA_get0_dmp1(const RSA *r)
{
return r->dmp1;
}
LCRYPTO_ALIAS(RSA_get0_dmp1);
const BIGNUM *
RSA_get0_dmq1(const RSA *r)
{
return r->dmq1;
}
LCRYPTO_ALIAS(RSA_get0_dmq1);
const BIGNUM *
RSA_get0_iqmp(const RSA *r)
{
return r->iqmp;
}
LCRYPTO_ALIAS(RSA_get0_iqmp);
const RSA_PSS_PARAMS *
RSA_get0_pss_params(const RSA *r)
{
return r->pss;
}
LCRYPTO_ALIAS(RSA_get0_pss_params);
void
RSA_clear_flags(RSA *r, int flags)
{
r->flags &= ~flags;
}
LCRYPTO_ALIAS(RSA_clear_flags);
int
RSA_test_flags(const RSA *r, int flags)
{
return r->flags & flags;
}
LCRYPTO_ALIAS(RSA_test_flags);
void
RSA_set_flags(RSA *r, int flags)
{
r->flags |= flags;
}
LCRYPTO_ALIAS(RSA_set_flags);
int
RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2)
@ -426,3 +456,4 @@ RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2)
return EVP_PKEY_CTX_ctrl(ctx, -1, optype, cmd, p1, p2);
}
LCRYPTO_ALIAS(RSA_pkey_ctx_ctrl);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_meth.c,v 1.6 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_meth.c,v 1.7 2023/07/08 12:26:45 beck Exp $ */
/*
* Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
*
@ -38,6 +38,7 @@ RSA_meth_new(const char *name, int flags)
return meth;
}
LCRYPTO_ALIAS(RSA_meth_new);
void
RSA_meth_free(RSA_METHOD *meth)
@ -48,6 +49,7 @@ RSA_meth_free(RSA_METHOD *meth)
free(meth->name);
free(meth);
}
LCRYPTO_ALIAS(RSA_meth_free);
RSA_METHOD *
RSA_meth_dup(const RSA_METHOD *meth)
@ -64,6 +66,7 @@ RSA_meth_dup(const RSA_METHOD *meth)
return copy;
}
LCRYPTO_ALIAS(RSA_meth_dup);
int
RSA_meth_set1_name(RSA_METHOD *meth, const char *name)
@ -76,12 +79,14 @@ RSA_meth_set1_name(RSA_METHOD *meth, const char *name)
meth->name = new_name;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set1_name);
int
(*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa)
{
return meth->finish;
}
LCRYPTO_ALIAS(RSA_meth_get_finish);
int
RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen,
@ -90,6 +95,7 @@ RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen,
meth->rsa_priv_enc = priv_enc;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_priv_enc);
int
RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen,
@ -98,6 +104,7 @@ RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen,
meth->rsa_priv_dec = priv_dec;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_priv_dec);
int
RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa))
@ -105,6 +112,7 @@ RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa))
meth->finish = finish;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_finish);
int
RSA_meth_set_pub_enc(RSA_METHOD *meth, int (*pub_enc)(int flen,
@ -113,6 +121,7 @@ RSA_meth_set_pub_enc(RSA_METHOD *meth, int (*pub_enc)(int flen,
meth->rsa_pub_enc = pub_enc;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_pub_enc);
int
RSA_meth_set_pub_dec(RSA_METHOD *meth, int (*pub_dec)(int flen,
@ -121,6 +130,7 @@ RSA_meth_set_pub_dec(RSA_METHOD *meth, int (*pub_dec)(int flen,
meth->rsa_pub_dec = pub_dec;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_pub_dec);
int
RSA_meth_set_mod_exp(RSA_METHOD *meth, int (*mod_exp)(BIGNUM *r0,
@ -129,6 +139,7 @@ RSA_meth_set_mod_exp(RSA_METHOD *meth, int (*mod_exp)(BIGNUM *r0,
meth->rsa_mod_exp = mod_exp;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_mod_exp);
int
RSA_meth_set_bn_mod_exp(RSA_METHOD *meth, int (*bn_mod_exp)(BIGNUM *r,
@ -138,6 +149,7 @@ RSA_meth_set_bn_mod_exp(RSA_METHOD *meth, int (*bn_mod_exp)(BIGNUM *r,
meth->bn_mod_exp = bn_mod_exp;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_bn_mod_exp);
int
RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa))
@ -145,6 +157,7 @@ RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa))
meth->init = init;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_init);
int
RSA_meth_set_keygen(RSA_METHOD *meth, int (*keygen)(RSA *rsa, int bits,
@ -153,6 +166,7 @@ RSA_meth_set_keygen(RSA_METHOD *meth, int (*keygen)(RSA *rsa, int bits,
meth->rsa_keygen = keygen;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_keygen);
int
RSA_meth_set_flags(RSA_METHOD *meth, int flags)
@ -160,6 +174,7 @@ RSA_meth_set_flags(RSA_METHOD *meth, int flags)
meth->flags = flags;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_flags);
int
RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)
@ -167,12 +182,14 @@ RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)
meth->app_data = app_data;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set0_app_data);
const char *
RSA_meth_get0_name(const RSA_METHOD *meth)
{
return meth->name;
}
LCRYPTO_ALIAS(RSA_meth_get0_name);
int
(*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen,
@ -180,6 +197,7 @@ int
{
return meth->rsa_pub_enc;
}
LCRYPTO_ALIAS(RSA_meth_get_pub_enc);
int
(*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen,
@ -187,6 +205,7 @@ int
{
return meth->rsa_pub_dec;
}
LCRYPTO_ALIAS(RSA_meth_get_pub_dec);
int
(*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen,
@ -194,6 +213,7 @@ int
{
return meth->rsa_priv_enc;
}
LCRYPTO_ALIAS(RSA_meth_get_priv_enc);
int
(*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen,
@ -201,6 +221,7 @@ int
{
return meth->rsa_priv_dec;
}
LCRYPTO_ALIAS(RSA_meth_get_priv_dec);
int
(*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
@ -208,6 +229,7 @@ int
{
return meth->rsa_mod_exp;
}
LCRYPTO_ALIAS(RSA_meth_get_mod_exp);
int
(*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r,
@ -216,12 +238,14 @@ int
{
return meth->bn_mod_exp;
}
LCRYPTO_ALIAS(RSA_meth_get_bn_mod_exp);
int
(*RSA_meth_get_init(const RSA_METHOD *meth))(RSA *rsa)
{
return meth->init;
}
LCRYPTO_ALIAS(RSA_meth_get_init);
int
(*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
@ -229,18 +253,21 @@ int
{
return meth->rsa_keygen;
}
LCRYPTO_ALIAS(RSA_meth_get_keygen);
int
RSA_meth_get_flags(const RSA_METHOD *meth)
{
return meth->flags;
}
LCRYPTO_ALIAS(RSA_meth_get_flags);
void *
RSA_meth_get0_app_data(const RSA_METHOD *meth)
{
return meth->app_data;
}
LCRYPTO_ALIAS(RSA_meth_get0_app_data);
int
(*RSA_meth_get_sign(const RSA_METHOD *meth))(int type,
@ -250,6 +277,7 @@ int
{
return meth->rsa_sign;
}
LCRYPTO_ALIAS(RSA_meth_get_sign);
int
RSA_meth_set_sign(RSA_METHOD *meth, int (*sign)(int type,
@ -259,6 +287,7 @@ RSA_meth_set_sign(RSA_METHOD *meth, int (*sign)(int type,
meth->rsa_sign = sign;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_sign);
int
(*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype,
@ -267,6 +296,7 @@ int
{
return meth->rsa_verify;
}
LCRYPTO_ALIAS(RSA_meth_get_verify);
int
RSA_meth_set_verify(RSA_METHOD *meth, int (*verify)(int dtype,
@ -276,3 +306,4 @@ RSA_meth_set_verify(RSA_METHOD *meth, int (*verify)(int dtype,
meth->rsa_verify = verify;
return 1;
}
LCRYPTO_ALIAS(RSA_meth_set_verify);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_none.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */
/* $OpenBSD: rsa_none.c,v 1.12 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -80,6 +80,7 @@ RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *from,
memcpy(to, from, flen);
return 1;
}
LCRYPTO_ALIAS(RSA_padding_add_none);
int
RSA_padding_check_none(unsigned char *to, int tlen, const unsigned char *from,
@ -94,3 +95,4 @@ RSA_padding_check_none(unsigned char *to, int tlen, const unsigned char *from,
memcpy(to + tlen - flen, from, flen);
return tlen;
}
LCRYPTO_ALIAS(RSA_padding_check_none);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_oaep.c,v 1.36 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_oaep.c,v 1.37 2023/07/08 12:26:45 beck Exp $ */
/*
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
*
@ -90,6 +90,7 @@ RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
return RSA_padding_add_PKCS1_OAEP_mgf1(to, tlen, from, flen, param,
plen, NULL, NULL);
}
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_OAEP);
int
RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
@ -156,6 +157,7 @@ RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
return rv;
}
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_OAEP_mgf1);
int
RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
@ -165,6 +167,7 @@ RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
return RSA_padding_check_PKCS1_OAEP_mgf1(to, tlen, from, flen, num,
param, plen, NULL, NULL);
}
LCRYPTO_ALIAS(RSA_padding_check_PKCS1_OAEP);
int
RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
@ -315,6 +318,7 @@ RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
return constant_time_select_int(good, mlen, -1);
}
LCRYPTO_ALIAS(RSA_padding_check_PKCS1_OAEP_mgf1);
int
PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,
@ -356,3 +360,4 @@ PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,
EVP_MD_CTX_cleanup(&c);
return rv;
}
LCRYPTO_ALIAS(PKCS1_MGF1);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_pk1.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */
/* $OpenBSD: rsa_pk1.c,v 1.16 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -90,6 +90,7 @@ RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
return 1;
}
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_type_1);
int
RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
@ -139,6 +140,7 @@ RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
return j;
}
LCRYPTO_ALIAS(RSA_padding_check_PKCS1_type_1);
int
RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
@ -172,6 +174,7 @@ RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
memcpy(p, from, flen);
return 1;
}
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_type_2);
int
RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
@ -211,3 +214,4 @@ RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
return j;
}
LCRYPTO_ALIAS(RSA_padding_check_PKCS1_type_2);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_pmeth.c,v 1.38 2023/05/05 12:21:44 tb Exp $ */
/* $OpenBSD: rsa_pmeth.c,v 1.39 2023/07/08 12:26:45 beck Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -877,4 +877,3 @@ const EVP_PKEY_METHOD rsa_pss_pkey_meth = {
.ctrl = pkey_rsa_ctrl,
.ctrl_str = pkey_rsa_ctrl_str
};

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_prn.c,v 1.9 2022/11/08 19:19:08 tobhe Exp $ */
/* $OpenBSD: rsa_prn.c,v 1.10 2023/07/08 12:26:45 beck Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -77,6 +77,7 @@ RSA_print_fp(FILE *fp, const RSA *x, int off)
BIO_free(b);
return ret;
}
LCRYPTO_ALIAS(RSA_print_fp);
int
RSA_print(BIO *bp, const RSA *x, int off)
@ -95,3 +96,4 @@ RSA_print(BIO *bp, const RSA *x, int off)
EVP_PKEY_free(pk);
return ret;
}
LCRYPTO_ALIAS(RSA_print);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_pss.c,v 1.16 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_pss.c,v 1.17 2023/07/08 12:26:45 beck Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2005.
*/
@ -77,6 +77,7 @@ RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash,
{
return RSA_verify_PKCS1_PSS_mgf1(rsa, mHash, Hash, NULL, EM, sLen);
}
LCRYPTO_ALIAS(RSA_verify_PKCS1_PSS);
int
RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
@ -178,6 +179,7 @@ err:
return ret;
}
LCRYPTO_ALIAS(RSA_verify_PKCS1_PSS_mgf1);
int
RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
@ -185,6 +187,7 @@ RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
{
return RSA_padding_add_PKCS1_PSS_mgf1(rsa, EM, mHash, Hash, NULL, sLen);
}
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_PSS);
int
RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
@ -282,3 +285,4 @@ err:
return ret;
}
LCRYPTO_ALIAS(RSA_padding_add_PKCS1_PSS_mgf1);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_saos.c,v 1.24 2018/09/05 00:55:33 djm Exp $ */
/* $OpenBSD: rsa_saos.c,v 1.25 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -99,6 +99,7 @@ RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_len,
freezero(s, (unsigned int)j + 1);
return ret;
}
LCRYPTO_ALIAS(RSA_sign_ASN1_OCTET_STRING);
int
RSA_verify_ASN1_OCTET_STRING(int dtype, const unsigned char *m,
@ -139,3 +140,4 @@ err:
freezero(s, (unsigned int)siglen);
return ret;
}
LCRYPTO_ALIAS(RSA_verify_ASN1_OCTET_STRING);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_sign.c,v 1.35 2022/11/26 16:08:54 tb Exp $ */
/* $OpenBSD: rsa_sign.c,v 1.36 2023/07/08 12:26:45 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -166,6 +166,7 @@ RSA_sign(int type, const unsigned char *m, unsigned int m_len,
freezero(tmps, (size_t)encoded_len);
return (ret);
}
LCRYPTO_ALIAS(RSA_sign);
/*
* int_rsa_verify verifies an RSA signature in `sigbuf' using `rsa'. It may be
@ -276,3 +277,4 @@ RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
return int_rsa_verify(dtype, m, m_len, NULL, NULL, sigbuf, siglen, rsa);
}
LCRYPTO_ALIAS(RSA_verify);