]> git.proxmox.com Git - cargo.git/blob - vendor/openssl-sys/src/rsa.rs
351ac84c0328a4b884627628b6658caf158d536c
[cargo.git] / vendor / openssl-sys / src / rsa.rs
1 use libc::*;
2 use std::ptr;
3
4 use *;
5
6 pub const RSA_F4: c_long = 0x10001;
7
8 cfg_if! {
9 if #[cfg(not(ossl300))] {
10 pub unsafe fn EVP_PKEY_CTX_set_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad: c_int) -> c_int {
11 EVP_PKEY_CTX_ctrl(
12 ctx,
13 EVP_PKEY_RSA,
14 -1,
15 EVP_PKEY_CTRL_RSA_PADDING,
16 pad,
17 ptr::null_mut(),
18 )
19 }
20 pub unsafe fn EVP_PKEY_CTX_get_rsa_padding(ctx: *mut EVP_PKEY_CTX, ppad: *mut c_int) -> c_int {
21 EVP_PKEY_CTX_ctrl(
22 ctx,
23 EVP_PKEY_RSA,
24 -1,
25 EVP_PKEY_CTRL_GET_RSA_PADDING,
26 0,
27 ppad as *mut c_void,
28 )
29 }
30
31 pub unsafe fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int {
32 EVP_PKEY_CTX_ctrl(
33 ctx,
34 EVP_PKEY_RSA,
35 EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY,
36 EVP_PKEY_CTRL_RSA_PSS_SALTLEN,
37 len,
38 ptr::null_mut(),
39 )
40 }
41
42 pub unsafe fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *mut EVP_MD) -> c_int {
43 EVP_PKEY_CTX_ctrl(
44 ctx,
45 EVP_PKEY_RSA,
46 EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT,
47 EVP_PKEY_CTRL_RSA_MGF1_MD,
48 0,
49 md as *mut c_void,
50 )
51 }
52 }
53 }
54
55 #[cfg(any(ossl102, libressl310))]
56 pub unsafe fn EVP_PKEY_CTX_set_rsa_oaep_md(ctx: *mut EVP_PKEY_CTX, md: *mut EVP_MD) -> c_int {
57 EVP_PKEY_CTX_ctrl(
58 ctx,
59 EVP_PKEY_RSA,
60 EVP_PKEY_OP_TYPE_CRYPT,
61 EVP_PKEY_CTRL_RSA_OAEP_MD,
62 0,
63 md as *mut c_void,
64 )
65 }
66
67 #[cfg(any(ossl102, libressl310))]
68 pub unsafe fn EVP_PKEY_CTX_set0_rsa_oaep_label(
69 ctx: *mut EVP_PKEY_CTX,
70 label: *mut c_void,
71 len: c_int,
72 ) -> c_int {
73 EVP_PKEY_CTX_ctrl(
74 ctx,
75 EVP_PKEY_RSA,
76 EVP_PKEY_OP_TYPE_CRYPT,
77 EVP_PKEY_CTRL_RSA_OAEP_LABEL,
78 len,
79 label as *mut c_void,
80 )
81 }
82
83 pub const EVP_PKEY_CTRL_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 1;
84 pub const EVP_PKEY_CTRL_RSA_PSS_SALTLEN: c_int = EVP_PKEY_ALG_CTRL + 2;
85
86 pub const EVP_PKEY_CTRL_RSA_MGF1_MD: c_int = EVP_PKEY_ALG_CTRL + 5;
87
88 pub const EVP_PKEY_CTRL_GET_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 6;
89
90 #[cfg(any(ossl102, libressl310))]
91 pub const EVP_PKEY_CTRL_RSA_OAEP_MD: c_int = EVP_PKEY_ALG_CTRL + 9;
92 #[cfg(any(ossl102, libressl310))]
93 pub const EVP_PKEY_CTRL_RSA_OAEP_LABEL: c_int = EVP_PKEY_ALG_CTRL + 10;
94
95 pub const RSA_PKCS1_PADDING: c_int = 1;
96 #[cfg(not(ossl300))]
97 pub const RSA_SSLV23_PADDING: c_int = 2;
98 pub const RSA_NO_PADDING: c_int = 3;
99 pub const RSA_PKCS1_OAEP_PADDING: c_int = 4;
100 pub const RSA_X931_PADDING: c_int = 5;
101 pub const RSA_PKCS1_PSS_PADDING: c_int = 6;