Convert key length from bits to bytes
authormikeb <mikeb@openbsd.org>
Tue, 20 Feb 2018 15:02:13 +0000 (15:02 +0000)
committermikeb <mikeb@openbsd.org>
Tue, 20 Feb 2018 15:02:13 +0000 (15:02 +0000)
Reported by Renaud Allard, fix tested by Renaud (i386) and fcambus@ (amd64).
OK visa, fcambus

sys/arch/amd64/amd64/via.c
sys/arch/i386/i386/via.c

index c0e1e54..0f8f63f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: via.c,v 1.26 2017/12/24 16:19:27 fcambus Exp $        */
+/*     $OpenBSD: via.c,v 1.27 2018/02/20 15:02:13 mikeb Exp $  */
 /*     $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $    */
 
 /*-
@@ -179,9 +179,9 @@ viac3_crypto_newsession(u_int32_t *sidp, struct cryptoini *cri)
 
                        /* Build expanded keys for both directions */
                        AES_KeySetup_Encrypt(ses->ses_ekey, c->cri_key,
-                           c->cri_klen);
+                           c->cri_klen / 8);
                        AES_KeySetup_Decrypt(ses->ses_dkey, c->cri_key,
-                           c->cri_klen);
+                           c->cri_klen / 8);
                        for (i = 0; i < 4 * (AES_MAXROUNDS + 1); i++) {
                                ses->ses_ekey[i] = ntohl(ses->ses_ekey[i]);
                                ses->ses_dkey[i] = ntohl(ses->ses_dkey[i]);
index 860fa45..89fd4a3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: via.c,v 1.40 2017/12/29 13:24:11 fcambus Exp $        */
+/*     $OpenBSD: via.c,v 1.41 2018/02/20 15:02:13 mikeb Exp $  */
 /*     $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $    */
 
 /*-
@@ -180,9 +180,9 @@ viac3_crypto_newsession(u_int32_t *sidp, struct cryptoini *cri)
 
                        /* Build expanded keys for both directions */
                        AES_KeySetup_Encrypt(ses->ses_ekey, c->cri_key,
-                           c->cri_klen);
+                           c->cri_klen / 8);
                        AES_KeySetup_Decrypt(ses->ses_dkey, c->cri_key,
-                           c->cri_klen);
+                           c->cri_klen / 8);
                        for (i = 0; i < 4 * (AES_MAXROUNDS + 1); i++) {
                                ses->ses_ekey[i] = ntohl(ses->ses_ekey[i]);
                                ses->ses_dkey[i] = ntohl(ses->ses_dkey[i]);