[njs] WebCrypto: added missed support for AES-* keys of size 192.

Dmitry Volyntsev xeioex at nginx.com
Thu Jan 5 04:42:40 UTC 2023


details:   https://hg.nginx.org/njs/rev/864bf6445ccb
branches:  
changeset: 2018:864bf6445ccb
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Dec 29 20:46:21 2022 -0800
description:
WebCrypto: added missed support for AES-* keys of size 192.

diffstat:

 external/njs_webcrypto_module.c |  12 ++++++++++++
 test/webcrypto/aes.t.js         |   3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)

diffs (63 lines):

diff -r 02aa50753dc1 -r 864bf6445ccb external/njs_webcrypto_module.c
--- a/external/njs_webcrypto_module.c	Thu Dec 29 20:39:29 2022 -0800
+++ b/external/njs_webcrypto_module.c	Thu Dec 29 20:46:21 2022 -0800
@@ -663,6 +663,10 @@ njs_cipher_aes_gcm(njs_vm_t *vm, njs_str
         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
         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
         cipher = EVP_aes_128_cbc();
         break;
 
+    case 24:
+        cipher = EVP_aes_192_cbc();
+        break;
+
     case 32:
         cipher = EVP_aes_256_cbc();
         break;
diff -r 02aa50753dc1 -r 864bf6445ccb test/webcrypto/aes.t.js
--- a/test/webcrypto/aes.t.js	Thu Dec 29 20:39:29 2022 -0800
+++ b/test/webcrypto/aes.t.js	Thu Dec 29 20:46:21 2022 -0800
@@ -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" },
 ]};
 


More information about the nginx-devel mailing list