1
0

jose-jwk-exc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh -ex
  2. tmpdir=`mktemp -d 2>/dev/null || mktemp -d -t jose`
  3. onexit() {
  4. rm -rf $tmpdir
  5. }
  6. trap onexit EXIT
  7. for T in '{"alg":"ECDH"}' '{"alg":"ECDH","crv":"P-256"}' '{"kty":"EC","crv":"P-256"}'; do
  8. jose jwk gen -i "$T" -o $tmpdir/exc_a.jwk
  9. jose jwk gen -i "$T" -o $tmpdir/exc_b.jwk
  10. jose jwk pub -i $tmpdir/exc_a.jwk -o $tmpdir/exc_a.pub.jwk
  11. jose jwk pub -i $tmpdir/exc_b.jwk -o $tmpdir/exc_b.pub.jwk
  12. a=`jose jwk exc -l $tmpdir/exc_a.jwk -r $tmpdir/exc_b.pub.jwk`
  13. b=`jose jwk exc -l $tmpdir/exc_b.jwk -r $tmpdir/exc_a.pub.jwk`
  14. c=`jose jwk exc -l $tmpdir/exc_a.jwk -r $tmpdir/exc_b.jwk`
  15. d=`jose jwk exc -l $tmpdir/exc_b.jwk -r $tmpdir/exc_a.jwk`
  16. test "$a" = "$b"
  17. test "$c" = "$d"
  18. test "$a" = "$c"
  19. ! jose jwk exc -l $tmpdir/exc_a.pub.jwk -r $tmpdir/exc_b.jwk
  20. ! jose jwk exc -l $tmpdir/exc_b.pub.jwk -r $tmpdir/exc_a.jwk
  21. ! jose jwk exc -l $tmpdir/exc_a.pub.jwk -r $tmpdir/exc_b.pub.jwk
  22. ! jose jwk exc -l $tmpdir/exc_b.pub.jwk -r $tmpdir/exc_a.pub.jwk
  23. done
  24. jose jwk gen -i '{"alg":"ECDH","crv":"P-384"}' -o $tmpdir/exc_c.jwk
  25. ! jose jwk exc -l $tmpdir/exc_c.jwk -r $tmpdir/exc_a.pub.jwk
  26. jose jwk gen -i '{"kty":"EC","crv":"P-384"}' -o $tmpdir/exc_c.jwk
  27. ! jose jwk exc -l $tmpdir/exc_c.jwk -r $tmpdir/exc_a.pub.jwk
  28. jose jwk gen -i '{ "alg": "ES256" }' -o $tmpdir/exc_c.jwk
  29. ! jose jwk exc -l $tmpdir/exc_c.jwk -r $tmpdir/exc_a.pub.jwk
  30. srv=`jose jwk gen -i '{"alg":"ECMR"}'`
  31. clt=`jose jwk gen -i '{"alg":"ECMR"}'`
  32. eph=`jose jwk gen -i '{"alg":"ECMR"}'`
  33. spb=`echo "$srv" | jose jwk pub -i-`
  34. cpb=`echo "$clt" | jose jwk pub -i-`
  35. key=`echo "$clt$spb" | jose jwk exc -l- -r-`
  36. sub=`echo "$eph$spb" | jose jwk exc -l- -r- -i '{"alg":"ECMR"}'`
  37. req=`echo "$cpb$eph" | jose jwk exc -l- -r- -i '{"alg":"ECMR"}'`
  38. rep=`echo "$srv$req" | jose jwk exc -l- -r- -i '{"alg":"ECMR"}'`
  39. rec=`echo "$rep$sub" | jose jwk exc -l- -r-`
  40. echo "$key$rec" | jose fmt -j- -Oj- -OE