summaryrefslogtreecommitdiffstats
path: root/sys/crypto/aesni/aesni.h
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2013-11-06 19:14:49 +0000
committerjmg <jmg@FreeBSD.org>2013-11-06 19:14:49 +0000
commitc4e415a9b1440f594d6d43168ad7345b647bfce9 (patch)
tree711bd1d028b843709e9bed610c1a6710cb235022 /sys/crypto/aesni/aesni.h
parent1070afa220ccfc51218967e7d40e8e2b77985dbb (diff)
downloadFreeBSD-src-c4e415a9b1440f594d6d43168ad7345b647bfce9.zip
FreeBSD-src-c4e415a9b1440f594d6d43168ad7345b647bfce9.tar.gz
make it so that from/to can be missaligned as it can happen (the geli
regression manages to do it)... We use a packed struct to coerce gcc/clang into producing unaligned loads (there is not packed pointer attribute, otherwise this would be easier)... use _storeu_ and _loadu_ when using the structure is overkill... be better at using types properly... Since we allocate our own key schedule and make sure it's aligned, use the __m128i type in various arguments to functions... clang ignores __aligned on prototypes and gcc errors on them, leave them in comments to document that these function arguments are require to be aligned... about all that changes is movdqa -> movdqu from reading the diff of the disassembly output... Noticed by: symbolics at gmx.com MFC after: 3 days
Diffstat (limited to 'sys/crypto/aesni/aesni.h')
-rw-r--r--sys/crypto/aesni/aesni.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/sys/crypto/aesni/aesni.h b/sys/crypto/aesni/aesni.h
index 17ca9c5..99edd42 100644
--- a/sys/crypto/aesni/aesni.h
+++ b/sys/crypto/aesni/aesni.h
@@ -71,29 +71,30 @@ struct aesni_session {
/*
* Internal functions, implemented in assembler.
*/
-void aesni_set_enckey(const uint8_t *userkey, uint8_t *encrypt_schedule,
- int number_of_rounds);
-void aesni_set_deckey(const uint8_t *encrypt_schedule,
- uint8_t *decrypt_schedule, int number_of_rounds);
+void aesni_set_enckey(const uint8_t *userkey,
+ uint8_t *encrypt_schedule /*__aligned(16)*/, int number_of_rounds);
+void aesni_set_deckey(const uint8_t *encrypt_schedule /*__aligned(16)*/,
+ uint8_t *decrypt_schedule /*__aligned(16)*/, int number_of_rounds);
/*
* Slightly more public interfaces.
*/
-void aesni_encrypt_cbc(int rounds, const void *key_schedule, size_t len,
- const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
-void aesni_decrypt_cbc(int rounds, const void *key_schedule, size_t len,
- uint8_t *buf, const uint8_t iv[AES_BLOCK_LEN]);
-void aesni_encrypt_ecb(int rounds, const void *key_schedule, size_t len,
- const uint8_t from[AES_BLOCK_LEN], uint8_t to[AES_BLOCK_LEN]);
-void aesni_decrypt_ecb(int rounds, const void *key_schedule, size_t len,
- const uint8_t from[AES_BLOCK_LEN], uint8_t to[AES_BLOCK_LEN]);
-
-void aesni_encrypt_xts(int rounds, const void *data_schedule,
- const void *tweak_schedule, size_t len, const uint8_t *from, uint8_t *to,
- const uint8_t iv[AES_BLOCK_LEN]);
-void aesni_decrypt_xts(int rounds, const void *data_schedule,
- const void *tweak_schedule, size_t len, const uint8_t *from, uint8_t *to,
+void aesni_encrypt_cbc(int rounds, const void *key_schedule /*__aligned(16)*/,
+ size_t len, const uint8_t *from, uint8_t *to,
const uint8_t iv[AES_BLOCK_LEN]);
+void aesni_decrypt_cbc(int rounds, const void *key_schedule /*__aligned(16)*/,
+ size_t len, uint8_t *buf, const uint8_t iv[AES_BLOCK_LEN]);
+void aesni_encrypt_ecb(int rounds, const void *key_schedule /*__aligned(16)*/,
+ size_t len, const uint8_t *from, uint8_t *to);
+void aesni_decrypt_ecb(int rounds, const void *key_schedule /*__aligned(16)*/,
+ size_t len, const uint8_t *from, uint8_t *to);
+
+void aesni_encrypt_xts(int rounds, const void *data_schedule /*__aligned(16)*/,
+ const void *tweak_schedule /*__aligned(16)*/, size_t len,
+ const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
+void aesni_decrypt_xts(int rounds, const void *data_schedule /*__aligned(16)*/,
+ const void *tweak_schedule /*__aligned(16)*/, size_t len,
+ const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
int aesni_cipher_setup(struct aesni_session *ses,
struct cryptoini *encini);
@@ -103,4 +104,4 @@ int aesni_cipher_process(struct aesni_session *ses,
uint8_t *aesni_cipher_alloc(struct cryptodesc *enccrd, struct cryptop *crp,
int *allocated);
-#endif
+#endif /* _AESNI_H_ */
OpenPOWER on IntegriCloud