1 use libc::*;
2 use std::ptr;
3
4 use *;
5
6 pub const RSA_F4: c_long = 0x10001;
7
EVP_PKEY_CTX_set_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad: c_int) -> c_int8 pub unsafe fn EVP_PKEY_CTX_set_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad: c_int) -> c_int {
9 EVP_PKEY_CTX_ctrl(
10 ctx,
11 EVP_PKEY_RSA,
12 -1,
13 EVP_PKEY_CTRL_RSA_PADDING,
14 pad,
15 ptr::null_mut(),
16 )
17 }
18
EVP_PKEY_CTX_get_rsa_padding(ctx: *mut EVP_PKEY_CTX, ppad: *mut c_int) -> c_int19 pub unsafe fn EVP_PKEY_CTX_get_rsa_padding(ctx: *mut EVP_PKEY_CTX, ppad: *mut c_int) -> c_int {
20 EVP_PKEY_CTX_ctrl(
21 ctx,
22 EVP_PKEY_RSA,
23 -1,
24 EVP_PKEY_CTRL_GET_RSA_PADDING,
25 0,
26 ppad as *mut c_void,
27 )
28 }
29
EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int30 pub unsafe fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int {
31 EVP_PKEY_CTX_ctrl(
32 ctx,
33 EVP_PKEY_RSA,
34 EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY,
35 EVP_PKEY_CTRL_RSA_PSS_SALTLEN,
36 len,
37 ptr::null_mut(),
38 )
39 }
40
EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *mut EVP_MD) -> c_int41 pub unsafe fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *mut EVP_MD) -> c_int {
42 EVP_PKEY_CTX_ctrl(
43 ctx,
44 EVP_PKEY_RSA,
45 EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT,
46 EVP_PKEY_CTRL_RSA_MGF1_MD,
47 0,
48 md as *mut c_void,
49 )
50 }
51
52 pub const EVP_PKEY_CTRL_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 1;
53 pub const EVP_PKEY_CTRL_RSA_PSS_SALTLEN: c_int = EVP_PKEY_ALG_CTRL + 2;
54
55 pub const EVP_PKEY_CTRL_RSA_MGF1_MD: c_int = EVP_PKEY_ALG_CTRL + 5;
56
57 pub const EVP_PKEY_CTRL_GET_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 6;
58
59 pub const RSA_PKCS1_PADDING: c_int = 1;
60 pub const RSA_SSLV23_PADDING: c_int = 2;
61 pub const RSA_NO_PADDING: c_int = 3;
62 pub const RSA_PKCS1_OAEP_PADDING: c_int = 4;
63 pub const RSA_X931_PADDING: c_int = 5;
64 pub const RSA_PKCS1_PSS_PADDING: c_int = 6;
65
66 extern "C" {
RSA_new() -> *mut RSA67 pub fn RSA_new() -> *mut RSA;
RSA_size(k: *const RSA) -> c_int68 pub fn RSA_size(k: *const RSA) -> c_int;
69
70 #[cfg(any(ossl110, libressl273))]
RSA_set0_key( r: *mut ::RSA, n: *mut ::BIGNUM, e: *mut ::BIGNUM, d: *mut ::BIGNUM, ) -> c_int71 pub fn RSA_set0_key(
72 r: *mut ::RSA,
73 n: *mut ::BIGNUM,
74 e: *mut ::BIGNUM,
75 d: *mut ::BIGNUM,
76 ) -> c_int;
77 #[cfg(any(ossl110, libressl273))]
RSA_set0_factors(r: *mut ::RSA, p: *mut ::BIGNUM, q: *mut ::BIGNUM) -> c_int78 pub fn RSA_set0_factors(r: *mut ::RSA, p: *mut ::BIGNUM, q: *mut ::BIGNUM) -> c_int;
79 #[cfg(any(ossl110, libressl273))]
RSA_set0_crt_params( r: *mut ::RSA, dmp1: *mut ::BIGNUM, dmq1: *mut ::BIGNUM, iqmp: *mut ::BIGNUM, ) -> c_int80 pub fn RSA_set0_crt_params(
81 r: *mut ::RSA,
82 dmp1: *mut ::BIGNUM,
83 dmq1: *mut ::BIGNUM,
84 iqmp: *mut ::BIGNUM,
85 ) -> c_int;
86 #[cfg(any(ossl110, libressl273))]
RSA_get0_key( r: *const ::RSA, n: *mut *const ::BIGNUM, e: *mut *const ::BIGNUM, d: *mut *const ::BIGNUM, )87 pub fn RSA_get0_key(
88 r: *const ::RSA,
89 n: *mut *const ::BIGNUM,
90 e: *mut *const ::BIGNUM,
91 d: *mut *const ::BIGNUM,
92 );
93 #[cfg(any(ossl110, libressl273))]
RSA_get0_factors(r: *const ::RSA, p: *mut *const ::BIGNUM, q: *mut *const ::BIGNUM)94 pub fn RSA_get0_factors(r: *const ::RSA, p: *mut *const ::BIGNUM, q: *mut *const ::BIGNUM);
95 #[cfg(any(ossl110, libressl273))]
RSA_get0_crt_params( r: *const ::RSA, dmp1: *mut *const ::BIGNUM, dmq1: *mut *const ::BIGNUM, iqmp: *mut *const ::BIGNUM, )96 pub fn RSA_get0_crt_params(
97 r: *const ::RSA,
98 dmp1: *mut *const ::BIGNUM,
99 dmq1: *mut *const ::BIGNUM,
100 iqmp: *mut *const ::BIGNUM,
101 );
102
103 #[cfg(not(ossl110))]
RSA_generate_key( modsz: c_int, e: c_ulong, cb: Option<extern "C" fn(c_int, c_int, *mut c_void)>, cbarg: *mut c_void, ) -> *mut RSA104 pub fn RSA_generate_key(
105 modsz: c_int,
106 e: c_ulong,
107 cb: Option<extern "C" fn(c_int, c_int, *mut c_void)>,
108 cbarg: *mut c_void,
109 ) -> *mut RSA;
110
RSA_generate_key_ex( rsa: *mut RSA, bits: c_int, e: *mut BIGNUM, cb: *mut BN_GENCB, ) -> c_int111 pub fn RSA_generate_key_ex(
112 rsa: *mut RSA,
113 bits: c_int,
114 e: *mut BIGNUM,
115 cb: *mut BN_GENCB,
116 ) -> c_int;
117
RSA_public_encrypt( flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int, ) -> c_int118 pub fn RSA_public_encrypt(
119 flen: c_int,
120 from: *const u8,
121 to: *mut u8,
122 k: *mut RSA,
123 pad: c_int,
124 ) -> c_int;
RSA_private_encrypt( flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int, ) -> c_int125 pub fn RSA_private_encrypt(
126 flen: c_int,
127 from: *const u8,
128 to: *mut u8,
129 k: *mut RSA,
130 pad: c_int,
131 ) -> c_int;
RSA_public_decrypt( flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int, ) -> c_int132 pub fn RSA_public_decrypt(
133 flen: c_int,
134 from: *const u8,
135 to: *mut u8,
136 k: *mut RSA,
137 pad: c_int,
138 ) -> c_int;
RSA_private_decrypt( flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int, ) -> c_int139 pub fn RSA_private_decrypt(
140 flen: c_int,
141 from: *const u8,
142 to: *mut u8,
143 k: *mut RSA,
144 pad: c_int,
145 ) -> c_int;
RSA_check_key(r: *const ::RSA) -> c_int146 pub fn RSA_check_key(r: *const ::RSA) -> c_int;
RSA_free(rsa: *mut RSA)147 pub fn RSA_free(rsa: *mut RSA);
RSA_up_ref(rsa: *mut RSA) -> c_int148 pub fn RSA_up_ref(rsa: *mut RSA) -> c_int;
149
i2d_RSAPublicKey(k: *const RSA, buf: *mut *mut u8) -> c_int150 pub fn i2d_RSAPublicKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
d2i_RSAPublicKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA151 pub fn d2i_RSAPublicKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
i2d_RSAPrivateKey(k: *const RSA, buf: *mut *mut u8) -> c_int152 pub fn i2d_RSAPrivateKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA153 pub fn d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
154
RSA_sign( t: c_int, m: *const u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint, k: *mut RSA, ) -> c_int155 pub fn RSA_sign(
156 t: c_int,
157 m: *const u8,
158 mlen: c_uint,
159 sig: *mut u8,
160 siglen: *mut c_uint,
161 k: *mut RSA,
162 ) -> c_int;
RSA_verify( t: c_int, m: *const u8, mlen: c_uint, sig: *const u8, siglen: c_uint, k: *mut RSA, ) -> c_int163 pub fn RSA_verify(
164 t: c_int,
165 m: *const u8,
166 mlen: c_uint,
167 sig: *const u8,
168 siglen: c_uint,
169 k: *mut RSA,
170 ) -> c_int;
171
RSA_padding_check_PKCS1_type_2( to: *mut c_uchar, tlen: c_int, f: *const c_uchar, fl: c_int, rsa_len: c_int, ) -> c_int172 pub fn RSA_padding_check_PKCS1_type_2(
173 to: *mut c_uchar,
174 tlen: c_int,
175 f: *const c_uchar,
176 fl: c_int,
177 rsa_len: c_int,
178 ) -> c_int;
179 }
180