diff --git a/minimal-examples/crypto/minimal-crypto-jwk/README.md b/minimal-examples/crypto/minimal-crypto-jwk/README.md index 6807746c2..eea687da2 100644 --- a/minimal-examples/crypto/minimal-crypto-jwk/README.md +++ b/minimal-examples/crypto/minimal-crypto-jwk/README.md @@ -28,6 +28,7 @@ Commandline option|Meaning -v |For EC keys, the curve, eg, "P-384"... this implies the key bits --kid "ID string"|Key identity string --use "use[ use]"|Key use restriction (mutually exclusive with --key-ops): sig, enc +--alg |Specify the algorithm the key is designed for, eg "RSA1_5" --key-ops "op[ op]"|Key valid operations (mutually exclusive with --use): sign, verify, encrypt, decrypt, wrapKey, unwrapKey, deriveKey, deriveBits -c|Format the jwk as a linebroken C string --public |Only output the full, private key, not the public version first diff --git a/minimal-examples/crypto/minimal-crypto-jwk/main.c b/minimal-examples/crypto/minimal-crypto-jwk/main.c index be875d2a4..ba474386c 100644 --- a/minimal-examples/crypto/minimal-crypto-jwk/main.c +++ b/minimal-examples/crypto/minimal-crypto-jwk/main.c @@ -67,15 +67,14 @@ format_c(int fd, const char *key) int main(int argc, const char **argv) { - struct lws_context_creation_info info; - struct lws_context *context; - const char *p; int result = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE; - int bits = 4096; enum lws_gencrypto_kty kty = LWS_GENCRYPTO_KTY_RSA; + struct lws_context_creation_info info; + const char *curve = "P-256", *p; + struct lws_context *context; struct lws_jwk jwk; + int bits = 4096; char key[32768]; - const char *curve = "P-256"; int vl = sizeof(key); if ((p = lws_cmdline_option(argc, argv, "-d"))) @@ -129,6 +128,9 @@ int main(int argc, const char **argv) if ((p = lws_cmdline_option(argc, argv, "--use"))) lws_jwk_strdup_meta(&jwk, JWK_META_USE, p, strlen(p)); + if ((p = lws_cmdline_option(argc, argv, "--alg"))) + lws_jwk_strdup_meta(&jwk, JWK_META_ALG, p, strlen(p)); + if ((p = lws_cmdline_option(argc, argv, "--key-ops"))) lws_jwk_strdup_meta(&jwk, JWK_META_KEY_OPS, p, strlen(p));