]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/rsa/rsa_locl.h
Use method key type instead of EVP_PKEY_RSA
[thirdparty/openssl.git] / crypto / rsa / rsa_locl.h
CommitLineData
9862e9aa
RL
1/*
2 * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
2039c421
RS
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
9862e9aa 7 * https://www.openssl.org/source/license.html
9862e9aa
RL
8 */
9
10#include <openssl/rsa.h>
2f545ae4 11#include "internal/refcount.h"
9862e9aa
RL
12
13struct rsa_st {
14 /*
15 * The first parameter is used to pickup errors where this is passed
16 * instead of aEVP_PKEY, it is set to 0
17 */
18 int pad;
19 long version;
20 const RSA_METHOD *meth;
21 /* functional reference if 'meth' is ENGINE-provided */
22 ENGINE *engine;
23 BIGNUM *n;
24 BIGNUM *e;
25 BIGNUM *d;
26 BIGNUM *p;
27 BIGNUM *q;
28 BIGNUM *dmp1;
29 BIGNUM *dmq1;
30 BIGNUM *iqmp;
d771441d
DSH
31 /* If a PSS only key this contains the parameter restrictions */
32 RSA_PSS_PARAMS *pss;
9862e9aa
RL
33 /* be careful using this if the RSA structure is shared */
34 CRYPTO_EX_DATA ex_data;
2f545ae4 35 CRYPTO_REF_COUNT references;
9862e9aa
RL
36 int flags;
37 /* Used to cache montgomery values */
38 BN_MONT_CTX *_method_mod_n;
39 BN_MONT_CTX *_method_mod_p;
40 BN_MONT_CTX *_method_mod_q;
41 /*
42 * all BIGNUM values are actually in the following data, if it is not
43 * NULL
44 */
45 char *bignum_data;
46 BN_BLINDING *blinding;
47 BN_BLINDING *mt_blinding;
48 CRYPTO_RWLOCK *lock;
49};
50
b72c9121
RL
51struct rsa_meth_st {
52 char *name;
53 int (*rsa_pub_enc) (int flen, const unsigned char *from,
54 unsigned char *to, RSA *rsa, int padding);
55 int (*rsa_pub_dec) (int flen, const unsigned char *from,
56 unsigned char *to, RSA *rsa, int padding);
57 int (*rsa_priv_enc) (int flen, const unsigned char *from,
58 unsigned char *to, RSA *rsa, int padding);
59 int (*rsa_priv_dec) (int flen, const unsigned char *from,
60 unsigned char *to, RSA *rsa, int padding);
61 /* Can be null */
62 int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
63 /* Can be null */
64 int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
65 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
66 /* called at new */
67 int (*init) (RSA *rsa);
68 /* called at free */
69 int (*finish) (RSA *rsa);
70 /* RSA_METHOD_FLAG_* things */
71 int flags;
72 /* may be needed! */
73 char *app_data;
74 /*
75 * New sign and verify functions: some libraries don't allow arbitrary
76 * data to be signed/verified: this allows them to be used. Note: for
77 * this to work the RSA_public_decrypt() and RSA_private_encrypt() should
78 * *NOT* be used RSA_sign(), RSA_verify() should be used instead.
79 */
80 int (*rsa_sign) (int type,
81 const unsigned char *m, unsigned int m_length,
82 unsigned char *sigret, unsigned int *siglen,
83 const RSA *rsa);
84 int (*rsa_verify) (int dtype, const unsigned char *m,
85 unsigned int m_length, const unsigned char *sigbuf,
86 unsigned int siglen, const RSA *rsa);
87 /*
88 * If this callback is NULL, the builtin software RSA key-gen will be
89 * used. This is for behavioural compatibility whilst the code gets
90 * rewired, but one day it would be nice to assume there are no such
91 * things as "builtin software" implementations.
92 */
93 int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
94};
95
0f113f3e
MC
96extern int int_rsa_verify(int dtype, const unsigned char *m,
97 unsigned int m_len, unsigned char *rm,
98 size_t *prm_len, const unsigned char *sigbuf,
99 size_t siglen, RSA *rsa);