openssl_sys/handwritten/
rsa.rs1use 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 #[cfg(any(ossl110, libressl))]
25 pub fn RSA_set0_key(r: *mut RSA, n: *mut BIGNUM, e: *mut BIGNUM, d: *mut BIGNUM) -> c_int;
26 #[cfg(any(ossl110, libressl))]
27 pub fn RSA_set0_factors(r: *mut RSA, p: *mut BIGNUM, q: *mut BIGNUM) -> c_int;
28 #[cfg(any(ossl110, libressl))]
29 pub fn RSA_set0_crt_params(
30 r: *mut RSA,
31 dmp1: *mut BIGNUM,
32 dmq1: *mut BIGNUM,
33 iqmp: *mut BIGNUM,
34 ) -> c_int;
35 #[cfg(any(ossl110, libressl))]
36 pub fn RSA_get0_key(
37 r: *const RSA,
38 n: *mut *const BIGNUM,
39 e: *mut *const BIGNUM,
40 d: *mut *const BIGNUM,
41 );
42 #[cfg(any(ossl110, libressl))]
43 pub fn RSA_get0_factors(r: *const RSA, p: *mut *const BIGNUM, q: *mut *const BIGNUM);
44 #[cfg(any(ossl110, libressl))]
45 pub fn RSA_get0_crt_params(
46 r: *const RSA,
47 dmp1: *mut *const BIGNUM,
48 dmq1: *mut *const BIGNUM,
49 iqmp: *mut *const BIGNUM,
50 );
51
52 #[cfg(not(ossl110))]
53 pub fn RSA_generate_key(
54 modsz: c_int,
55 e: c_ulong,
56 cb: Option<extern "C" fn(c_int, c_int, *mut c_void)>,
57 cbarg: *mut c_void,
58 ) -> *mut RSA;
59
60 pub fn RSA_generate_key_ex(
61 rsa: *mut RSA,
62 bits: c_int,
63 e: *mut BIGNUM,
64 cb: *mut BN_GENCB,
65 ) -> c_int;
66
67 pub fn RSA_public_encrypt(
68 flen: c_int,
69 from: *const u8,
70 to: *mut u8,
71 k: *mut RSA,
72 pad: c_int,
73 ) -> c_int;
74 pub fn RSA_private_encrypt(
75 flen: c_int,
76 from: *const u8,
77 to: *mut u8,
78 k: *mut RSA,
79 pad: c_int,
80 ) -> c_int;
81 pub fn RSA_public_decrypt(
82 flen: c_int,
83 from: *const u8,
84 to: *mut u8,
85 k: *mut RSA,
86 pad: c_int,
87 ) -> c_int;
88 pub fn RSA_private_decrypt(
89 flen: c_int,
90 from: *const u8,
91 to: *mut u8,
92 k: *mut RSA,
93 pad: c_int,
94 ) -> c_int;
95 pub fn RSA_check_key(r: *const RSA) -> c_int;
96 pub fn RSA_free(rsa: *mut RSA);
97 pub fn RSA_up_ref(rsa: *mut RSA) -> c_int;
98
99 pub fn i2d_RSAPublicKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
100 pub fn d2i_RSAPublicKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
101 pub fn i2d_RSAPrivateKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
102 pub fn d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
103
104 pub fn RSA_sign(
105 t: c_int,
106 m: *const u8,
107 mlen: c_uint,
108 sig: *mut u8,
109 siglen: *mut c_uint,
110 k: *mut RSA,
111 ) -> c_int;
112 pub fn RSA_verify(
113 t: c_int,
114 m: *const u8,
115 mlen: c_uint,
116 sig: *const u8,
117 siglen: c_uint,
118 k: *mut RSA,
119 ) -> c_int;
120
121 pub fn RSA_padding_check_PKCS1_type_2(
122 to: *mut c_uchar,
123 tlen: c_int,
124 f: *const c_uchar,
125 fl: c_int,
126 rsa_len: c_int,
127 ) -> c_int;
128}