From: seantywork Date: Wed, 3 Dec 2025 07:59:17 +0000 (+0000) Subject: crypt assoclen X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=61e015cbb09b739182e4de3a6927af93359d59a5;p=linuxyz.git crypt assoclen --- diff --git a/kcrypt/gcm/kcrypt.c b/kcrypt/gcm/kcrypt.c index 2a2a5a9..da93ad2 100644 --- a/kcrypt/gcm/kcrypt.c +++ b/kcrypt/gcm/kcrypt.c @@ -34,6 +34,12 @@ static int run_kcrypt(void) { struct scatterlist sg2 = { 0 }; DECLARE_CRYPTO_WAIT(wait); + u8 assoc_msg[16] = { + 0x11, 0x22, 0x33, 0x44, + 0x11, 0x22, 0x33, 0x44, + 0x11, 0x22, 0x33, 0x44, + 0x11, 0x22, 0x33, 0x44, + }; u8 nonce[12] = { 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -104,7 +110,7 @@ static int run_kcrypt(void) { goto kcrypt_end; } - memset(buffer, 0, aes_gcm_assoclen); + memcpy(buffer, assoc_msg, aes_gcm_assoclen); memcpy(buffer + aes_gcm_assoclen, test_data, test_datalen); bp = buffer + aes_gcm_assoclen; bp_end = bp + test_datalen; @@ -123,7 +129,7 @@ static int run_kcrypt(void) { aead_request_set_crypt(req, &sg, &sg2, test_datalen, nonce + nonce_saltlen); - aead_request_set_ad(req, aes_gcm_taglen); + aead_request_set_ad(req, aes_gcm_assoclen); // aead_request_set_ad(req, 0); @@ -132,9 +138,10 @@ static int run_kcrypt(void) { printk("kcrypt: encrypt: failed: %d.\n", err); goto kcrypt_end; } - printk("authentication tag: "); + memcpy(buffer2, assoc_msg, aes_gcm_assoclen); + printk("assoc: "); bp = buffer2; - bp_end += aes_gcm_taglen; + bp_end = bp + aes_gcm_assoclen; while (bp != bp_end) { printk("%c\n", isprint(*bp) ? *bp : '.'); bp++; @@ -147,6 +154,12 @@ static int run_kcrypt(void) { bp++; } + printk("authentication tag: "); + bp_end += aes_gcm_taglen; + while (bp != bp_end) { + printk("%c\n", isprint(*bp) ? *bp : '.'); + bp++; + } aead_request_set_crypt(req, &sg2, &sg, test_datalen + aes_gcm_taglen, nonce + nonce_saltlen); aead_request_set_ad(req, aes_gcm_taglen);