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