Skip to main content

openssl_sys/handwritten/
rsa.rs

1use super::super::*;
2use libc::*;
3
4cfg_if! {
5    if #[cfg(ossl300)] {
6        extern "C" {
7            pub fn EVP_PKEY_CTX_set_rsa_keygen_bits(ctx: *mut EVP_PKEY_CTX, bits: c_int) -> c_int;
8            pub fn EVP_PKEY_CTX_set1_rsa_keygen_pubexp(ctx: *mut EVP_PKEY_CTX, pubexp: *mut BIGNUM) -> c_int;
9
10            pub fn EVP_PKEY_CTX_set_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad_mode: c_int) -> c_int;
11            pub fn EVP_PKEY_CTX_get_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad_mode: *mut c_int) -> c_int;
12
13            pub fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int;
14            pub fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *const EVP_MD) -> c_int;
15        }
16    }
17}
18
19#[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
20extern "C" {
21    pub fn RSA_new() -> *mut RSA;
22    pub fn RSA_size(k: *const RSA) -> c_int;
23
24    pub fn RSA_set0_key(r: *mut RSA, n: *mut BIGNUM, e: *mut BIGNUM, d: *mut BIGNUM) -> c_int;
25    pub fn RSA_set0_factors(r: *mut RSA, p: *mut BIGNUM, q: *mut BIGNUM) -> c_int;
26    pub fn RSA_set0_crt_params(
27        r: *mut RSA,
28        dmp1: *mut BIGNUM,
29        dmq1: *mut BIGNUM,
30        iqmp: *mut BIGNUM,
31    ) -> c_int;
32    pub fn RSA_get0_key(
33        r: *const RSA,
34        n: *mut *const BIGNUM,
35        e: *mut *const BIGNUM,
36        d: *mut *const BIGNUM,
37    );
38    pub fn RSA_get0_factors(r: *const RSA, p: *mut *const BIGNUM, q: *mut *const BIGNUM);
39    pub fn RSA_get0_crt_params(
40        r: *const RSA,
41        dmp1: *mut *const BIGNUM,
42        dmq1: *mut *const BIGNUM,
43        iqmp: *mut *const BIGNUM,
44    );
45
46    #[cfg(not(ossl110))]
47    pub fn RSA_generate_key(
48        modsz: c_int,
49        e: c_ulong,
50        cb: Option<extern "C" fn(c_int, c_int, *mut c_void)>,
51        cbarg: *mut c_void,
52    ) -> *mut RSA;
53
54    pub fn RSA_generate_key_ex(
55        rsa: *mut RSA,
56        bits: c_int,
57        e: *mut BIGNUM,
58        cb: *mut BN_GENCB,
59    ) -> c_int;
60
61    pub fn RSA_public_encrypt(
62        flen: c_int,
63        from: *const u8,
64        to: *mut u8,
65        k: *mut RSA,
66        pad: c_int,
67    ) -> c_int;
68    pub fn RSA_private_encrypt(
69        flen: c_int,
70        from: *const u8,
71        to: *mut u8,
72        k: *mut RSA,
73        pad: c_int,
74    ) -> c_int;
75    pub fn RSA_public_decrypt(
76        flen: c_int,
77        from: *const u8,
78        to: *mut u8,
79        k: *mut RSA,
80        pad: c_int,
81    ) -> c_int;
82    pub fn RSA_private_decrypt(
83        flen: c_int,
84        from: *const u8,
85        to: *mut u8,
86        k: *mut RSA,
87        pad: c_int,
88    ) -> c_int;
89    pub fn RSA_check_key(r: *const RSA) -> c_int;
90    pub fn RSA_free(rsa: *mut RSA);
91    pub fn RSA_up_ref(rsa: *mut RSA) -> c_int;
92
93    pub fn i2d_RSAPublicKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
94    pub fn d2i_RSAPublicKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
95    pub fn i2d_RSAPrivateKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
96    pub fn d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
97
98    pub fn RSA_sign(
99        t: c_int,
100        m: *const u8,
101        mlen: c_uint,
102        sig: *mut u8,
103        siglen: *mut c_uint,
104        k: *mut RSA,
105    ) -> c_int;
106    pub fn RSA_verify(
107        t: c_int,
108        m: *const u8,
109        mlen: c_uint,
110        sig: *const u8,
111        siglen: c_uint,
112        k: *mut RSA,
113    ) -> c_int;
114
115    pub fn RSA_padding_check_PKCS1_type_2(
116        to: *mut c_uchar,
117        tlen: c_int,
118        f: *const c_uchar,
119        fl: c_int,
120        rsa_len: c_int,
121    ) -> c_int;
122}