123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include <openssl/rsa.h>
- #include "internal/refcount.h"
- #define RSA_MAX_PRIME_NUM 5
- #define RSA_MIN_MODULUS_BITS 512
- typedef struct rsa_prime_info_st {
- BIGNUM *r;
- BIGNUM *d;
- BIGNUM *t;
-
- BIGNUM *pp;
- BN_MONT_CTX *m;
- } RSA_PRIME_INFO;
- DECLARE_ASN1_ITEM(RSA_PRIME_INFO)
- DEFINE_STACK_OF(RSA_PRIME_INFO)
- struct rsa_st {
-
- int pad;
- int32_t version;
- const RSA_METHOD *meth;
-
- ENGINE *engine;
- BIGNUM *n;
- BIGNUM *e;
- BIGNUM *d;
- BIGNUM *p;
- BIGNUM *q;
- BIGNUM *dmp1;
- BIGNUM *dmq1;
- BIGNUM *iqmp;
-
- STACK_OF(RSA_PRIME_INFO) *prime_infos;
-
- RSA_PSS_PARAMS *pss;
-
- CRYPTO_EX_DATA ex_data;
- CRYPTO_REF_COUNT references;
- int flags;
-
- BN_MONT_CTX *_method_mod_n;
- BN_MONT_CTX *_method_mod_p;
- BN_MONT_CTX *_method_mod_q;
-
- char *bignum_data;
- BN_BLINDING *blinding;
- BN_BLINDING *mt_blinding;
- CRYPTO_RWLOCK *lock;
- };
- struct rsa_meth_st {
- char *name;
- int (*rsa_pub_enc) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- int (*rsa_pub_dec) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- int (*rsa_priv_enc) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- int (*rsa_priv_dec) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
-
- int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
-
- int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
-
- int (*init) (RSA *rsa);
-
- int (*finish) (RSA *rsa);
-
- int flags;
-
- char *app_data;
-
- int (*rsa_sign) (int type,
- const unsigned char *m, unsigned int m_length,
- unsigned char *sigret, unsigned int *siglen,
- const RSA *rsa);
- int (*rsa_verify) (int dtype, const unsigned char *m,
- unsigned int m_length, const unsigned char *sigbuf,
- unsigned int siglen, const RSA *rsa);
-
- int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
- int (*rsa_multi_prime_keygen) (RSA *rsa, int bits, int primes,
- BIGNUM *e, BN_GENCB *cb);
- };
- extern int int_rsa_verify(int dtype, const unsigned char *m,
- unsigned int m_len, unsigned char *rm,
- size_t *prm_len, const unsigned char *sigbuf,
- size_t siglen, RSA *rsa);
- #define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
- #define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS)
- RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd,
- const EVP_MD *mgf1md, int saltlen);
- int rsa_pss_get_param(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd,
- const EVP_MD **pmgf1md, int *psaltlen);
- void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo);
- void rsa_multip_info_free(RSA_PRIME_INFO *pinfo);
- RSA_PRIME_INFO *rsa_multip_info_new(void);
- int rsa_multip_calc_product(RSA *rsa);
- int rsa_multip_cap(int bits);
|