1 /* $OpenBSD: rsa_meth.c,v 1.1 2018/03/17 15:12:56 tb Exp $ */
3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <openssl/err.h>
22 #include <openssl/rsa.h>
25 RSA_meth_new(const char *name
, int flags
)
29 if ((meth
= calloc(1, sizeof(*meth
))) == NULL
)
31 if ((meth
->name
= strdup(name
)) == NULL
) {
41 RSA_meth_free(RSA_METHOD
*meth
)
44 free((char *)meth
->name
);
50 RSA_meth_dup(const RSA_METHOD
*meth
)
54 if ((copy
= calloc(1, sizeof(*copy
))) == NULL
)
56 memcpy(copy
, meth
, sizeof(*copy
));
57 if ((copy
->name
= strdup(meth
->name
)) == NULL
) {
66 RSA_meth_set_priv_enc(RSA_METHOD
*meth
, int (*priv_enc
)(int flen
,
67 const unsigned char *from
, unsigned char *to
, RSA
*rsa
, int padding
))
69 meth
->rsa_priv_enc
= priv_enc
;
74 RSA_meth_set_priv_dec(RSA_METHOD
*meth
, int (*priv_dec
)(int flen
,
75 const unsigned char *from
, unsigned char *to
, RSA
*rsa
, int padding
))
77 meth
->rsa_priv_dec
= priv_dec
;
82 RSA_meth_set_finish(RSA_METHOD
*meth
, int (*finish
)(RSA
*rsa
))
84 meth
->finish
= finish
;