1
0

jose-jwk-use 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh -ex
  2. echo '{}' | jose jwk use -i- -u encrypt
  3. ! echo '{}' | jose jwk use -i- -r -u encrypt
  4. ! echo '{"use": true}' | jose jwk use -i- -u encrypt
  5. ! echo '{"key_ops": []}' | jose jwk use -i- -u encrypt
  6. ! echo '{"key_ops": [true]}' | jose jwk use -i- -u encrypt
  7. echo '{"use": "enc"}' | jose jwk use -i- -u encrypt
  8. ! echo '{"use": "sig"}' | jose jwk use -i- -u encrypt
  9. tmp='{"key_ops": ["encrypt", "decrypt"]}'
  10. echo "$tmp" | jose jwk use -i- -u encrypt
  11. echo "$tmp" | jose jwk use -i- -u encrypt -u decrypt
  12. echo "$tmp" | jose jwk use -i- -a -u encrypt -u decrypt
  13. echo "$tmp" | jose jwk use -i- -u encrypt -u sign
  14. ! echo "$tmp" | jose jwk use -i- -u sign
  15. ! echo "$tmp" | jose jwk use -i- -a -u encrypt -u sign
  16. tmp='{"use": "sig", "key_ops": ["encrypt", "decrypt"]}'
  17. echo "$tmp" | jose jwk use -i- -u encrypt -u sign
  18. echo "$tmp" | jose jwk use -i- -a -u encrypt -u sign
  19. ! echo '{"use": "enc"}' | jose jwk use -i- -u deriveKey
  20. ! echo '{"use": "enc"}' | jose jwk use -i- -u deriveBits
  21. ! echo '{"use": "sig"}' | jose jwk use -i- -u deriveKey
  22. ! echo '{"use": "sig"}' | jose jwk use -i- -u deriveBits
  23. jwkset=`jose jwk gen -i '{"keys":[{"alg":"A128KW"},{"alg":"ES256"}]}'`
  24. [ "`echo "$jwkset" | jose jwk use -i- -u wrapKey -s -o-`" \
  25. = "`jose fmt -j "$jwkset" -g keys -d 1 -Uo-`" ]
  26. [ "`echo "$jwkset" | jose jwk use -i- -u verify -s -o-`" \
  27. = "`jose fmt -j "$jwkset" -g keys -d 0 -Uo-`" ]
  28. [ "`echo "$jwkset" | jose jwk use -i- -u wrapKey -o-`" \
  29. = "`jose fmt -j "$jwkset" -g keys -g 0 -o-`" ]
  30. [ "`echo "$jwkset" | jose jwk use -i- -u verify -o-`" \
  31. = "`jose fmt -j "$jwkset" -g keys -g 1 -o-`" ]
  32. echo "$jwkset" | jose jwk use -i- -u verify -o-