12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #!/bin/bash -ex
- ALGS=`jose alg -k sign`
- tmpdir=`mktemp -d 2>/dev/null || mktemp -d -t jose`
- function onexit() {
- rm -rf $tmpdir
- }
- trap exit ERR
- trap onexit EXIT
- msg=$tmpdir/msg.txt
- echo -n hi > $msg
- for a in $ALGS; do
- jwk=$tmpdir/$a.jwk
- jws=$tmpdir/$a.jws
- jose jwk gen -i "{\"alg\":\"$a\"}" -o $jwk
- jose jwk pub -i $jwk -o $jwk.pub
- old=$prv
- prv=$jwk
- done
- for a in $ALGS; do
- jwk=$tmpdir/$a.jwk
- jws=$tmpdir/$a.jws
- echo -n hi | jose jws sig -I- -k $jwk | jose jws ver -i- -k $jwk
- echo -n hi | jose jws sig -I- -k $jwk -c | jose jws ver -i- -k $jwk
- jose jws sig -o $jws -k $jwk -I $msg
- jose jws ver -i $jws -k $jwk
- rm -f $jws
- jose jws sig -o $jws -k $jwk -I $msg -c
- jose jws ver -i $jws -k $jwk
- rm -f $jws
- det=`jose jws sig -I $msg -k $jwk -o /dev/null -O-`
- [ "$det" == "hi" ]
- jws=`jose jws sig -I $msg -k $jwk -O /dev/null`
- ! jose jws ver -i "$jws" -k $jwk
- det=`jose jws ver -i "$jws" -k $jwk -I $msg -O-`
- [ "$det" == "hi" ]
- jws=`jose jws sig -I $msg -k $jwk`
- det=`jose jws ver -i "$jws" -k $jwk`
- [ "$det" == "" ]
- det=`jose jws ver -i "$jws" -k $jwk -O-`
- [ "$det" == "hi" ]
- jws=`jose jws sig -I $msg -k $jwk -c`
- det=`jose jws ver -i "$jws" -k $jwk`
- [ "$det" == "" ]
- det=`jose jws ver -i "$jws" -k $jwk -O-`
- [ "$det" == "hi" ]
- jws=`jose jws sig -k $jwk -I $msg -s "{\"protected\":{\"alg\":\"$a\"}}"`
- jose jws ver -i "$jws" -k $jwk
- jws=`jose jws sig -k $jwk -i "{\"payload\":\"aGkK\"}"`
- jose jws ver -i "$jws" -k $jwk
- for b in $ALGS; do
- [ $a == $b ] && continue
- ! jose jws sig -I $msg -k $jwk -s "{\"protected\":{\"alg\":\"$b\"}}"
- jws=`jose jws sig -I $msg -k $jwk`
- ! jose jws ver -i "$jws" -k $tmpdir/$b.jwk
- done
- jws=`jose jws sig -I $msg -k $jwk -k $prv`
- jose jws ver -i "$jws" -k $jwk
- jose jws ver -i "$jws" -k $prv
- ! jose jws ver -i "$jws" -k $old
- jose jws ver -i "$jws" -k $jwk -k $prv -a
- ! jose jws ver -i "$jws" -k $jwk -k $prv -k $old -a
- old=$prv
- prv=$jwk
- done
- for tmpl in '{"kty":"oct","bytes":32}' '{"kty":"RSA","bits":2048}' '{"kty":"EC","crv":"P-256"}'; do
- jose jwk gen -i "$tmpl" -o $tmpdir/jwk
- echo -n "$msg" | jose jws sig -I- -k $tmpdir/jwk -o $tmpdir/jws
- [ "`jose jws ver -i $tmpdir/jws -k $tmpdir/jwk -O-`" == "$msg" ]
- done
|