From a05359f02a70e792163840de2caeb8d8eb586d10 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Thu, 29 Dec 2022 20:46:21 -0800 Subject: [PATCH] WebCrypto: added missed support for AES-* keys of size 192. --- external/njs_webcrypto_module.c | 12 ++++++++++++ test/webcrypto/aes.t.js | 3 +++ 2 files changed, 15 insertions(+) diff --git a/external/njs_webcrypto_module.c b/external/njs_webcrypto_module.c index 886dcb7c..bedc0c22 100644 --- a/external/njs_webcrypto_module.c +++ b/external/njs_webcrypto_module.c @@ -663,6 +663,10 @@ njs_cipher_aes_gcm(njs_vm_t *vm, njs_str_t *data, njs_webcrypto_key_t *key, cipher = EVP_aes_128_gcm(); break; + case 24: + cipher = EVP_aes_192_gcm(); + break; + case 32: cipher = EVP_aes_256_gcm(); break; @@ -961,6 +965,10 @@ njs_cipher_aes_ctr(njs_vm_t *vm, njs_str_t *data, njs_webcrypto_key_t *key, cipher = EVP_aes_128_ctr(); break; + case 24: + cipher = EVP_aes_192_ctr(); + break; + case 32: cipher = EVP_aes_256_ctr(); break; @@ -1162,6 +1170,10 @@ njs_cipher_aes_cbc(njs_vm_t *vm, njs_str_t *data, njs_webcrypto_key_t *key, cipher = EVP_aes_128_cbc(); break; + case 24: + cipher = EVP_aes_192_cbc(); + break; + case 32: cipher = EVP_aes_256_cbc(); break; diff --git a/test/webcrypto/aes.t.js b/test/webcrypto/aes.t.js index 03acd6d7..1f5c136f 100644 --- a/test/webcrypto/aes.t.js +++ b/test/webcrypto/aes.t.js @@ -66,6 +66,7 @@ let aes_tsuite = { { name: "AES-GCM", data: "aabbcc", tagLength: 112 }, { name: "AES-GCM", data: "aabbcc", tagLength: 113, exception: "TypeError: AES-GCM Invalid tagLength" }, { name: "AES-GCM", data: "aabbcc", key: "aabbcc", exception: "TypeError: Invalid key length" }, + { name: "AES-GCM", data: "aabbcc", key: "001122330011223300112233001122330011223300112233" }, { name: "AES-GCM", data: "aabbccdd".repeat(4096) }, { name: "AES-CTR", data: "aa" }, @@ -84,6 +85,7 @@ let aes_tsuite = { { name: "AES-CTR", data: "aabbccdd".repeat(4096), counter: "ffffffffffffffffffffffffffffffff", length: 11 }, { name: "AES-CTR", data: "aabbccdd".repeat(4096), length: 20 }, { name: "AES-CTR", data: "aabbccdd".repeat(4096), length: 24 }, + { name: "AES-CTR", data: "aabbcc", key: "001122330011223300112233001122330011223300112233" }, { name: "AES-CTR", data: "aabbccdd", length: 129, exception: "TypeError: AES-CTR algorithm.length must be between 1 and 128" }, { name: "AES-CTR", data: "aabbcc", key: "aabbcc", exception: "TypeError: Invalid key length" }, @@ -92,6 +94,7 @@ let aes_tsuite = { { name: "AES-CBC", data: "aabbccdd".repeat(4) }, { name: "AES-CBC", data: "aabbccdd".repeat(4096) }, { name: "AES-CBC", data: "aabbccdd".repeat(5), iv: "ffffffffffffffffffffffffffffffff" }, + { name: "AES-CBC", data: "aabbcc", key: "001122330011223300112233001122330011223300112233" }, { name: "AES-CBC", data: "aabbcc", key: "aabbcc", exception: "TypeError: Invalid key length" }, ]}; -- 2.47.3