1
0

jose-jwk-use 1.6 KB

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