aboutsummaryrefslogtreecommitdiff
path: root/openssl-sys/src/aes.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-09-08 21:13:15 -0700
committerSteven Fackler <[email protected]>2018-09-12 19:21:18 -0700
commit93a4e96255744363b80603e821e94b551621fbd8 (patch)
tree1c1e77369f63d55738a5cbeea65d2d7c515d2971 /openssl-sys/src/aes.rs
parentclean up example (diff)
downloadrust-openssl-93a4e96255744363b80603e821e94b551621fbd8.tar.xz
rust-openssl-93a4e96255744363b80603e821e94b551621fbd8.zip
Refactor openssl-sys
The old layout tried to structure itself by version but it ended up with a lot of duplication. Instead, follow the structure of the header files.
Diffstat (limited to 'openssl-sys/src/aes.rs')
-rw-r--r--openssl-sys/src/aes.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/openssl-sys/src/aes.rs b/openssl-sys/src/aes.rs
new file mode 100644
index 00000000..cbb289c6
--- /dev/null
+++ b/openssl-sys/src/aes.rs
@@ -0,0 +1,28 @@
+use libc::*;
+
+pub const AES_ENCRYPT: c_int = 1;
+pub const AES_DECRYPT: c_int = 0;
+
+pub const AES_MAXNR: c_int = 14;
+pub const AES_BLOCK_SIZE: c_int = 16;
+
+#[repr(C)]
+pub struct AES_KEY {
+ // There is some business with AES_LONG which is there to ensure the values here are 32 bits
+ rd_key: [u32; 4 * (AES_MAXNR as usize + 1)],
+ rounds: c_int,
+}
+
+extern "C" {
+ pub fn AES_set_encrypt_key(userKey: *const c_uchar, bits: c_int, key: *mut AES_KEY) -> c_int;
+ pub fn AES_set_decrypt_key(userKey: *const c_uchar, bits: c_int, key: *mut AES_KEY) -> c_int;
+
+ pub fn AES_ige_encrypt(
+ in_: *const c_uchar,
+ out: *mut c_uchar,
+ length: size_t,
+ key: *const AES_KEY,
+ ivec: *mut c_uchar,
+ enc: c_int,
+ );
+}