OK?

---
 sys/conf/files         |  2 ++
 sys/crypto/cryptodev.h |  9 ++++++---
 sys/crypto/xform.c     | 21 +++++++++++++++++++++
 sys/crypto/xform.h     |  2 ++
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git sys/conf/files sys/conf/files
index 04c3ff7..40cceab 100644
--- sys/conf/files
+++ sys/conf/files
@@ -856,10 +856,12 @@ file crypto/michael.c                     wlan
 file crypto/cmac.c                     wlan
 file crypto/hmac.c                     wlan | (softraid & crypto)
 file crypto/gmac.c                     ipsec | crypto
 file crypto/key_wrap.c                 wlan
 file crypto/idgen.c                    inet6 | nfsclient | nfsserver
+file crypto/chachapoly.c               ipsec | crypto
+file crypto/poly1305.c                 ipsec | crypto
 file crypto/siphash.c
 file netmpls/mpls_input.c              mpls
 file netmpls/mpls_output.c             mpls
 file netmpls/mpls_proto.c              mpls
 file netmpls/mpls_raw.c                        mpls
diff --git sys/crypto/cryptodev.h sys/crypto/cryptodev.h
index f4af569..5923512 100644
--- sys/crypto/cryptodev.h
+++ sys/crypto/cryptodev.h
@@ -75,11 +75,12 @@
 #define DES_BLOCK_LEN          8
 #define DES3_BLOCK_LEN         8
 #define BLOWFISH_BLOCK_LEN     8
 #define CAST128_BLOCK_LEN      8
 #define RIJNDAEL128_BLOCK_LEN  16
-#define EALG_MAX_BLOCK_LEN     16 /* Keep this updated */
+#define CHACHA20_BLOCK_LEN     64
+#define EALG_MAX_BLOCK_LEN     64 /* Keep this updated */
 
 /* Maximum hash algorithm result length */
 #define AALG_MAX_RESULT_LEN    64 /* Keep this updated */
 
 #define CRYPTO_DES_CBC         1
@@ -105,12 +106,14 @@
 #define CRYPTO_AES_GCM_16      23
 #define CRYPTO_AES_128_GMAC    24
 #define CRYPTO_AES_192_GMAC    25
 #define CRYPTO_AES_256_GMAC    26
 #define CRYPTO_AES_GMAC                27
-#define CRYPTO_ESN             28 /* Support for Extended Sequence Numbers */
-#define CRYPTO_ALGORITHM_MAX   28 /* Keep updated */
+#define CRYPTO_CHACHA20_POLY1305       28
+#define CRYPTO_CHACHA20_POLY1305_MAC   29
+#define CRYPTO_ESN             30 /* Support for Extended Sequence Numbers */
+#define CRYPTO_ALGORITHM_MAX   30 /* Keep updated */
 
 /* Algorithm flags */
 #define        CRYPTO_ALG_FLAG_SUPPORTED       0x01 /* Algorithm is supported 
*/
 #define        CRYPTO_ALG_FLAG_RNG_ENABLE      0x02 /* Has HW RNG for DH/DSA */
 #define        CRYPTO_ALG_FLAG_DSA_SHA         0x04 /* Can do SHA on msg */
diff --git sys/crypto/xform.c sys/crypto/xform.c
index 84b762b..3f4a517 100644
--- sys/crypto/xform.c
+++ sys/crypto/xform.c
@@ -215,10 +215,20 @@ struct enc_xform enc_xform_aes_xts = {
        aes_xts_decrypt,
        aes_xts_setkey,
        aes_xts_reinit
 };
 
+struct enc_xform enc_xform_chacha20_poly1305 = {
+       CRYPTO_CHACHA20_POLY1305, "CHACHA20-POLY1305",
+       1, 8, 32+4, 32+4,
+       sizeof(struct chacha20_ctx),
+       chacha20_crypt,
+       chacha20_crypt,
+       chacha20_setkey,
+       chacha20_reinit
+};
+
 struct enc_xform enc_xform_arc4 = {
        CRYPTO_ARC4, "ARC4",
        1, 1, 1, 32, 0,
        NULL,
        NULL,
@@ -312,10 +322,21 @@ struct auth_hash auth_hash_gmac_aes_256 = {
        (void (*)(void *, const u_int8_t *, u_int16_t)) AES_GMAC_Reinit,
        (int  (*)(void *, const u_int8_t *, u_int16_t)) AES_GMAC_Update,
        (void (*)(u_int8_t *, void *)) AES_GMAC_Final
 };
 
+struct auth_hash auth_hash_chacha20_poly1305 = {
+       CRYPTO_CHACHA20_POLY1305_MAC, "CHACHA20-POLY1305",
+       CHACHA20_KEYSIZE+CHACHA20_SALT, POLY1305_BLOCK_LEN, POLY1305_TAGLEN,
+       sizeof(CHACHA_POLY_CTX), CHACHA20_BLOCK_LEN,
+       (void (*)(void *)) Chacha_Poly_Init,
+       (void (*)(void *, const u_int8_t *, u_int16_t)) Chacha_Poly_Setkey,
+       (void (*)(void *, const u_int8_t *, u_int16_t)) Chacha_Poly_Reinit,
+       (int  (*)(void *, const u_int8_t *, u_int16_t)) Chacha_Poly_Update,
+       (void (*)(u_int8_t *, void *)) Chacha_Poly_Final
+};
+
 struct auth_hash auth_hash_md5 = {
        CRYPTO_MD5, "MD5",
        0, 16, 16, sizeof(MD5_CTX), 0,
        (void (*) (void *)) MD5Init, NULL, NULL,
        MD5Update_int,
diff --git sys/crypto/xform.h sys/crypto/xform.h
index 0e7678c..4591666 100644
--- sys/crypto/xform.h
+++ sys/crypto/xform.h
@@ -83,10 +83,11 @@ extern struct enc_xform enc_xform_cast5;
 extern struct enc_xform enc_xform_rijndael128;
 extern struct enc_xform enc_xform_aes_ctr;
 extern struct enc_xform enc_xform_aes_gcm;
 extern struct enc_xform enc_xform_aes_gmac;
 extern struct enc_xform enc_xform_aes_xts;
+extern struct enc_xform enc_xform_chacha20_poly1305;
 extern struct enc_xform enc_xform_arc4;
 extern struct enc_xform enc_xform_null;
 
 extern struct auth_hash auth_hash_md5;
 extern struct auth_hash auth_hash_sha1;
@@ -97,10 +98,11 @@ extern struct auth_hash auth_hash_hmac_sha2_256_128;
 extern struct auth_hash auth_hash_hmac_sha2_384_192;
 extern struct auth_hash auth_hash_hmac_sha2_512_256;
 extern struct auth_hash auth_hash_gmac_aes_128;
 extern struct auth_hash auth_hash_gmac_aes_192;
 extern struct auth_hash auth_hash_gmac_aes_256;
+extern struct auth_hash auth_hash_chacha20_poly1305;
 
 extern struct comp_algo comp_algo_deflate;
 extern struct comp_algo comp_algo_lzs;
 
 #endif /* _CRYPTO_XFORM_H_ */
-- 
2.6.2

Reply via email to