aboutsummaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-10-24 19:20:41 +0100
committerMichael Brown <mcb30@ipxe.org>2022-10-25 13:21:30 +0100
commitda81214cec87201dc18c0ce71224367e13a6edfb (patch)
tree85952ee981f3c970cb95b2f72a5c342c748a9e0c /src/crypto
parent0c383bf00afbef1a9cfe02829d1bc6ee46e1c16b (diff)
downloadipxe-da81214cec87201dc18c0ce71224367e13a6edfb.tar.gz
[crypto] Add concept of authentication tag to cipher algorithms
Some ciphers (such as GCM) support the concept of a tag that can be used to authenticate the encrypted data. Add a cipher method for generating an authentication tag. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/aes.c2
-rw-r--r--src/crypto/arc4.c2
-rw-r--r--src/crypto/crypto_null.c6
3 files changed, 10 insertions, 0 deletions
diff --git a/src/crypto/aes.c b/src/crypto/aes.c
index d7393285f..4a7668b6b 100644
--- a/src/crypto/aes.c
+++ b/src/crypto/aes.c
@@ -783,10 +783,12 @@ struct cipher_algorithm aes_algorithm = {
.name = "aes",
.ctxsize = sizeof ( struct aes_context ),
.blocksize = AES_BLOCKSIZE,
+ .authsize = 0,
.setkey = aes_setkey,
.setiv = cipher_null_setiv,
.encrypt = aes_encrypt,
.decrypt = aes_decrypt,
+ .auth = cipher_null_auth,
};
/* AES in Electronic Codebook mode */
diff --git a/src/crypto/arc4.c b/src/crypto/arc4.c
index 0dba2fc59..4d98abead 100644
--- a/src/crypto/arc4.c
+++ b/src/crypto/arc4.c
@@ -119,8 +119,10 @@ struct cipher_algorithm arc4_algorithm = {
.name = "ARC4",
.ctxsize = ARC4_CTX_SIZE,
.blocksize = 1,
+ .authsize = 0,
.setkey = arc4_setkey,
.setiv = cipher_null_setiv,
.encrypt = arc4_xor,
.decrypt = arc4_xor,
+ .auth = cipher_null_auth,
};
diff --git a/src/crypto/crypto_null.c b/src/crypto/crypto_null.c
index ef6041b5b..26cfbfc4e 100644
--- a/src/crypto/crypto_null.c
+++ b/src/crypto/crypto_null.c
@@ -76,14 +76,20 @@ void cipher_null_decrypt ( void *ctx __unused, const void *src, void *dst,
memcpy ( dst, src, len );
}
+void cipher_null_auth ( void *ctx __unused, void *auth __unused ) {
+ /* Do nothing */
+}
+
struct cipher_algorithm cipher_null = {
.name = "null",
.ctxsize = 0,
.blocksize = 1,
+ .authsize = 0,
.setkey = cipher_null_setkey,
.setiv = cipher_null_setiv,
.encrypt = cipher_null_encrypt,
.decrypt = cipher_null_decrypt,
+ .auth = cipher_null_auth,
};
int pubkey_null_init ( void *ctx __unused, const void *key __unused,