summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/rsa/rsa_meth.c
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2019-06-05 15:41:33 +0000
committergilles <gilles@openbsd.org>2019-06-05 15:41:33 +0000
commitbd3f6f9a6aa46af4fac556c8ddd93ba6fe57ee47 (patch)
treedcb2ed7250f798aa2d166179d3d76d14f47c21eb /lib/libcrypto/rsa/rsa_meth.c
parentRemove workaround and return EINVAL when userland sends routing messages (diff)
downloadwireguard-openbsd-bd3f6f9a6aa46af4fac556c8ddd93ba6fe57ee47.tar.xz
wireguard-openbsd-bd3f6f9a6aa46af4fac556c8ddd93ba6fe57ee47.zip
provide getters and setters for the RSA_METHOD interface
ok tb@, jsing@, sthen@
Diffstat (limited to 'lib/libcrypto/rsa/rsa_meth.c')
-rw-r--r--lib/libcrypto/rsa/rsa_meth.c173
1 files changed, 172 insertions, 1 deletions
diff --git a/lib/libcrypto/rsa/rsa_meth.c b/lib/libcrypto/rsa/rsa_meth.c
index ae613cc65c5..095368b0cf1 100644
--- a/lib/libcrypto/rsa/rsa_meth.c
+++ b/lib/libcrypto/rsa/rsa_meth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_meth.c,v 1.2 2018/09/12 06:35:38 djm Exp $ */
+/* $OpenBSD: rsa_meth.c,v 1.3 2019/06/05 15:41:33 gilles Exp $ */
/*
* Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
*
@@ -102,3 +102,174 @@ RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa))
meth->finish = finish;
return 1;
}
+
+int
+RSA_meth_set_pub_enc(RSA_METHOD *meth, int (*pub_enc)(int flen,
+ const unsigned char *from, unsigned char *to, RSA *rsa, int padding))
+{
+ meth->rsa_pub_enc = pub_enc;
+ return 1;
+}
+
+int
+RSA_meth_set_pub_dec(RSA_METHOD *meth, int (*pub_dec)(int flen,
+ const unsigned char *from, unsigned char *to, RSA *rsa, int padding))
+{
+ meth->rsa_pub_dec = pub_dec;
+ return 1;
+}
+
+int
+RSA_meth_set_mod_exp(RSA_METHOD *meth, int (*mod_exp)(BIGNUM *r0,
+ const BIGNUM *i, RSA *rsa, BN_CTX *ctx))
+{
+ meth->rsa_mod_exp = mod_exp;
+ return 1;
+}
+
+int
+RSA_meth_set_bn_mod_exp(RSA_METHOD *meth, int (*bn_mod_exp)(BIGNUM *r,
+ const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *m_ctx))
+{
+ meth->bn_mod_exp = bn_mod_exp;
+ return 1;
+}
+
+int
+RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa))
+{
+ meth->init = init;
+ return 1;
+}
+
+int
+RSA_meth_set_keygen(RSA_METHOD *meth, int (*keygen)(RSA *rsa, int bits,
+ BIGNUM *e, BN_GENCB *cb))
+{
+ meth->rsa_keygen = keygen;
+ return 1;
+}
+
+int
+RSA_meth_set_flags(RSA_METHOD *meth, int flags)
+{
+ meth->flags = flags;
+ return 1;
+}
+
+int
+RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)
+{
+ meth->app_data = app_data;
+ return 1;
+}
+
+const char *
+RSA_meth_get0_name(const RSA_METHOD *meth)
+{
+ return meth->name;
+}
+
+int
+(*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen,
+ const unsigned char *from, unsigned char *to, RSA *rsa, int padding)
+{
+ return meth->rsa_pub_enc;
+}
+
+int
+(*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen,
+ const unsigned char *from, unsigned char *to, RSA *rsa, int padding)
+{
+ return meth->rsa_pub_dec;
+}
+
+int
+(*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen,
+ const unsigned char *from, unsigned char *to, RSA *rsa, int padding)
+{
+ return meth->rsa_priv_enc;
+}
+
+int
+(*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen,
+ const unsigned char *from, unsigned char *to, RSA *rsa, int padding)
+{
+ return meth->rsa_priv_dec;
+}
+
+int
+(*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
+ RSA *rsa, BN_CTX *ctx)
+{
+ return meth->rsa_mod_exp;
+}
+
+int
+(*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r,
+ const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *m_ctx)
+{
+ return meth->bn_mod_exp;
+}
+
+int
+(*RSA_meth_get_init(const RSA_METHOD *meth))(RSA *rsa)
+{
+ return meth->init;
+}
+
+int
+(*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
+ BN_GENCB *cb)
+{
+ return meth->rsa_keygen;
+}
+
+int
+RSA_meth_get_flags(const RSA_METHOD *meth)
+{
+ return meth->flags;
+}
+
+void *
+RSA_meth_get0_app_data(const RSA_METHOD *meth)
+{
+ return meth->app_data;
+}
+
+int
+(*RSA_meth_get_sign(const RSA_METHOD *meth))(int type,
+ const unsigned char *m, unsigned int m_length,
+ unsigned char *sigret, unsigned int *siglen,
+ const RSA *rsa)
+{
+ return meth->rsa_sign;
+}
+
+int
+RSA_meth_set_sign(RSA_METHOD *meth, int (*sign)(int type,
+ const unsigned char *m, unsigned int m_length, unsigned char *sigret,
+ unsigned int *siglen, const RSA *rsa))
+{
+ meth->rsa_sign = sign;
+ return 1;
+}
+
+int
+(*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype,
+ const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf,
+ unsigned int siglen, const RSA *rsa)
+{
+ return meth->rsa_verify;
+}
+
+int
+RSA_meth_set_verify(RSA_METHOD *meth, int (*verify)(int dtype,
+ const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf,
+ unsigned int siglen, const RSA *rsa))
+{
+ meth->rsa_verify = verify;
+ return 1;
+}