Welcome! Log In Create A New Profile

Advanced

[njs] WebCrypto: sorted njs_webcrypto_alg accoding to njs_webcrypto_alg_t.

Dmitry Volyntsev
May 24, 2023 12:22AM
details: https://hg.nginx.org/njs/rev/510d8ebedfba
branches:
changeset: 2130:510d8ebedfba
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Mon May 22 22:48:58 2023 -0700
description:
WebCrypto: sorted njs_webcrypto_alg accoding to njs_webcrypto_alg_t.

So njs_webcrypto_alg[alg->type] can be used to get the algorithm name.

diffstat:

external/njs_webcrypto_module.c | 68 +++++++++++++++++++++-------------------
1 files changed, 35 insertions(+), 33 deletions(-)

diffs (120 lines):

diff -r 08a912ab9520 -r 510d8ebedfba external/njs_webcrypto_module.c
--- a/external/njs_webcrypto_module.c Mon May 22 17:59:47 2023 -0700
+++ b/external/njs_webcrypto_module.c Mon May 22 22:48:58 2023 -0700
@@ -45,6 +45,7 @@ typedef enum {
NJS_ALGORITHM_ECDH,
NJS_ALGORITHM_PBKDF2,
NJS_ALGORITHM_HKDF,
+ NJS_ALGORITHM_MAX,
} njs_webcrypto_alg_t;


@@ -54,6 +55,7 @@ typedef enum {
NJS_HASH_SHA256,
NJS_HASH_SHA384,
NJS_HASH_SHA512,
+ NJS_HASH_MAX,
} njs_webcrypto_hash_t;


@@ -153,6 +155,28 @@ static njs_webcrypto_entry_t njs_webcryp
(uintptr_t) & (njs_webcrypto_algorithm_t) { type, usage_mask, fmt_mask }

{
+ njs_str("RSASSA-PKCS1-v1_5"),
+ njs_webcrypto_algorithm(NJS_ALGORITHM_RSASSA_PKCS1_v1_5,
+ NJS_KEY_USAGE_SIGN |
+ NJS_KEY_USAGE_VERIFY |
+ NJS_KEY_USAGE_GENERATE_KEY,
+ NJS_KEY_FORMAT_PKCS8 |
+ NJS_KEY_FORMAT_SPKI |
+ NJS_KEY_FORMAT_JWK)
+ },
+
+ {
+ njs_str("RSA-PSS"),
+ njs_webcrypto_algorithm(NJS_ALGORITHM_RSA_PSS,
+ NJS_KEY_USAGE_SIGN |
+ NJS_KEY_USAGE_VERIFY |
+ NJS_KEY_USAGE_GENERATE_KEY,
+ NJS_KEY_FORMAT_PKCS8 |
+ NJS_KEY_FORMAT_SPKI |
+ NJS_KEY_FORMAT_JWK)
+ },
+
+ {
njs_str("RSA-OAEP"),
njs_webcrypto_algorithm(NJS_ALGORITHM_RSA_OAEP,
NJS_KEY_USAGE_ENCRYPT |
@@ -166,6 +190,16 @@ static njs_webcrypto_entry_t njs_webcryp
},

{
+ njs_str("HMAC"),
+ njs_webcrypto_algorithm(NJS_ALGORITHM_HMAC,
+ NJS_KEY_USAGE_GENERATE_KEY |
+ NJS_KEY_USAGE_SIGN |
+ NJS_KEY_USAGE_VERIFY,
+ NJS_KEY_FORMAT_RAW |
+ NJS_KEY_FORMAT_JWK)
+ },
+
+ {
njs_str("AES-GCM"),
njs_webcrypto_algorithm(NJS_ALGORITHM_AES_GCM,
NJS_KEY_USAGE_ENCRYPT |
@@ -202,28 +236,6 @@ static njs_webcrypto_entry_t njs_webcryp
},

{
- njs_str("RSASSA-PKCS1-v1_5"),
- njs_webcrypto_algorithm(NJS_ALGORITHM_RSASSA_PKCS1_v1_5,
- NJS_KEY_USAGE_SIGN |
- NJS_KEY_USAGE_VERIFY |
- NJS_KEY_USAGE_GENERATE_KEY,
- NJS_KEY_FORMAT_PKCS8 |
- NJS_KEY_FORMAT_SPKI |
- NJS_KEY_FORMAT_JWK)
- },
-
- {
- njs_str("RSA-PSS"),
- njs_webcrypto_algorithm(NJS_ALGORITHM_RSA_PSS,
- NJS_KEY_USAGE_SIGN |
- NJS_KEY_USAGE_VERIFY |
- NJS_KEY_USAGE_GENERATE_KEY,
- NJS_KEY_FORMAT_PKCS8 |
- NJS_KEY_FORMAT_SPKI |
- NJS_KEY_FORMAT_JWK)
- },
-
- {
njs_str("ECDSA"),
njs_webcrypto_algorithm(NJS_ALGORITHM_ECDSA,
NJS_KEY_USAGE_SIGN |
@@ -262,16 +274,6 @@ static njs_webcrypto_entry_t njs_webcryp
},

{
- njs_str("HMAC"),
- njs_webcrypto_algorithm(NJS_ALGORITHM_HMAC,
- NJS_KEY_USAGE_GENERATE_KEY |
- NJS_KEY_USAGE_SIGN |
- NJS_KEY_USAGE_VERIFY,
- NJS_KEY_FORMAT_RAW |
- NJS_KEY_FORMAT_JWK)
- },
-
- {
njs_null_str,
0
}
@@ -335,7 +337,7 @@ static njs_webcrypto_entry_t njs_webcryp


static njs_str_t
- njs_webcrypto_alg_name[NJS_ALGORITHM_HMAC + 1][NJS_HASH_SHA512 + 1] = {
+ njs_webcrypto_alg_name[NJS_ALGORITHM_HMAC + 1][NJS_HASH_MAX] = {
{
njs_null_str,
njs_str("RS1"),
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] WebCrypto: sorted njs_webcrypto_alg accoding to njs_webcrypto_alg_t.

Dmitry Volyntsev 241 May 24, 2023 12:22AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 92
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready