]>
Commit | Line | Data |
---|---|---|
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> | |
11 | ||
12 | struct rsa_st { | |
13 | /* | |
14 | * The first parameter is used to pickup errors where this is passed | |
15 | * instead of aEVP_PKEY, it is set to 0 | |
16 | */ | |
17 | int pad; | |
18 | long version; | |
19 | const RSA_METHOD *meth; | |
20 | /* functional reference if 'meth' is ENGINE-provided */ | |
21 | ENGINE *engine; | |
22 | BIGNUM *n; | |
23 | BIGNUM *e; | |
24 | BIGNUM *d; | |
25 | BIGNUM *p; | |
26 | BIGNUM *q; | |
27 | BIGNUM *dmp1; | |
28 | BIGNUM *dmq1; | |
29 | BIGNUM *iqmp; | |
30 | /* be careful using this if the RSA structure is shared */ | |
31 | CRYPTO_EX_DATA ex_data; | |
32 | int references; | |
33 | int flags; | |
34 | /* Used to cache montgomery values */ | |
35 | BN_MONT_CTX *_method_mod_n; | |
36 | BN_MONT_CTX *_method_mod_p; | |
37 | BN_MONT_CTX *_method_mod_q; | |
38 | /* | |
39 | * all BIGNUM values are actually in the following data, if it is not | |
40 | * NULL | |
41 | */ | |
42 | char *bignum_data; | |
43 | BN_BLINDING *blinding; | |
44 | BN_BLINDING *mt_blinding; | |
45 | CRYPTO_RWLOCK *lock; | |
46 | }; | |
47 | ||
b72c9121 RL |
48 | struct rsa_meth_st { |
49 | char *name; | |
50 | int (*rsa_pub_enc) (int flen, const unsigned char *from, | |
51 | unsigned char *to, RSA *rsa, int padding); | |
52 | int (*rsa_pub_dec) (int flen, const unsigned char *from, | |
53 | unsigned char *to, RSA *rsa, int padding); | |
54 | int (*rsa_priv_enc) (int flen, const unsigned char *from, | |
55 | unsigned char *to, RSA *rsa, int padding); | |
56 | int (*rsa_priv_dec) (int flen, const unsigned char *from, | |
57 | unsigned char *to, RSA *rsa, int padding); | |
58 | /* Can be null */ | |
59 | int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); | |
60 | /* Can be null */ | |
61 | int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |
62 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | |
63 | /* called at new */ | |
64 | int (*init) (RSA *rsa); | |
65 | /* called at free */ | |
66 | int (*finish) (RSA *rsa); | |
67 | /* RSA_METHOD_FLAG_* things */ | |
68 | int flags; | |
69 | /* may be needed! */ | |
70 | char *app_data; | |
71 | /* | |
72 | * New sign and verify functions: some libraries don't allow arbitrary | |
73 | * data to be signed/verified: this allows them to be used. Note: for | |
74 | * this to work the RSA_public_decrypt() and RSA_private_encrypt() should | |
75 | * *NOT* be used RSA_sign(), RSA_verify() should be used instead. | |
76 | */ | |
77 | int (*rsa_sign) (int type, | |
78 | const unsigned char *m, unsigned int m_length, | |
79 | unsigned char *sigret, unsigned int *siglen, | |
80 | const RSA *rsa); | |
81 | int (*rsa_verify) (int dtype, const unsigned char *m, | |
82 | unsigned int m_length, const unsigned char *sigbuf, | |
83 | unsigned int siglen, const RSA *rsa); | |
84 | /* | |
85 | * If this callback is NULL, the builtin software RSA key-gen will be | |
86 | * used. This is for behavioural compatibility whilst the code gets | |
87 | * rewired, but one day it would be nice to assume there are no such | |
88 | * things as "builtin software" implementations. | |
89 | */ | |
90 | int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); | |
91 | }; | |
92 | ||
0f113f3e MC |
93 | extern int int_rsa_verify(int dtype, const unsigned char *m, |
94 | unsigned int m_len, unsigned char *rm, | |
95 | size_t *prm_len, const unsigned char *sigbuf, | |
96 | size_t siglen, RSA *rsa); |