jose-jwk-gen 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh -ex
  2. ALGS=`jose alg -k sign -k wrap -k encr | grep -v '^dir$'`
  3. ##
  4. ### Generate a key for every supported algorithm
  5. ##
  6. for a in $ALGS; do
  7. jose jwk gen -i "{\"alg\": \"$a\"}"
  8. done
  9. ##
  10. ### Generate a key for each parameter
  11. ##
  12. jose jwk gen -i '{ "kty": "EC", "crv": "P-256" }'
  13. jose jwk gen -i '{ "kty": "EC", "crv": "P-384" }'
  14. jose jwk gen -i '{ "kty": "EC", "crv": "P-521" }'
  15. jose jwk gen -i '{ "kty": "EC", "crv": "secp256k1" }'
  16. jose jwk gen -i '{ "kty": "RSA", "bits": 3072 }'
  17. ! jose jwk gen -i '{ "kty": "RSA", "bits": 3072, "e": 257 }'
  18. ! jose jwk gen -i '{ "kty": "RSA", "bits": 3072, "e": 65536 }'
  19. ! jose jwk gen -i '{ "kty": "RSA", "bits": 3072, "e": 65537 }'
  20. ! jose jwk gen -i '{ "kty": "RSA", "bits": 3072, "e": "AQE" }' # 257.
  21. jose jwk gen -i '{ "kty": "RSA", "bits": 3072, "e": "AQAB"}' # 65537.
  22. jose jwk gen -i '{ "kty": "oct", "bytes": 32 }'
  23. ##
  24. ### Test the key types we can't generate
  25. ##
  26. ! jose jwk gen -i '{"alg": "dir"}'
  27. ##
  28. ### Test invalid keys
  29. ##
  30. ! jose jwk gen -i '{"not_valid": "RS256"}'
  31. ##
  32. ### Test the set output option
  33. ##
  34. jose jwk gen -s -i '{ "kty": "EC", "crv": "P-256" }' \
  35. | jose fmt -j- -Og keys -A \
  36. -l -j 1 -EUU \
  37. -g 0 -O \
  38. -g kty -q EC -EUU \
  39. -g crv -q P-256 -EUU