uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

tests (1323B)


      1 #!/bin/sh
      2 
      3 echo "exercise 1:"
      4 ./priv dat/priv.in
      5 echo
      6 
      7 echo "exercise 2:"
      8 ./priv -v dat/priv.in | awk '{print $2}' > dat/encrypt.in
      9 ./atoh 'Christos Margiolis' | ./encrypt dat/encrypt.in
     10 echo
     11 
     12 echo "exercise 3:"
     13 ./decrypt dat/decrypt.in | ./htoa
     14 echo
     15 
     16 echo "exercise 4:"
     17 printf "sign1: "; ./atoh 'This is a message' | ./sign dat/decrypt.in
     18 printf "sign2: "; ./atoh 'This iz a message' | ./sign dat/decrypt.in
     19 echo
     20 
     21 echo "exercise 5a:"
     22 ./verify dat/verify1_cor.in | tail -1 | awk '{print $2}' | ./htoa
     23 ./verify dat/verify1_inc.in | tail -1 | awk '{print $2}' | ./htoa
     24 echo
     25 
     26 echo "exercise 5b:"
     27 ./verify dat/verify2.in | tail -1 | awk '{print $2}' | ./htoa
     28 echo
     29 
     30 echo "exercise 6:"
     31 # fetch cert key
     32 openssl s_client -connect margiolis.net:443 -showcerts </dev/null 2>/dev/null |
     33 openssl x509 -outform pem > dat/c0.pem
     34 
     35 # extract e
     36 openssl x509 -in dat/c0.pem -text -noout | grep 'Exponent' |
     37 awk '{print $3}' | sed 's/(//;s/)//;s/0x//' > dat/cert.in
     38 
     39 # extract n
     40 openssl x509 -in dat/c0.pem -noout -modulus | sed 's/Modulus=//' >> dat/cert.in
     41 
     42 # extract signature
     43 openssl x509 -in dat/c0.pem -text -noout \
     44 	-certopt ca_default -certopt no_validity \
     45 	-certopt no_serial -certopt no_subject \
     46 	-certopt no_extensions -certopt no_signame |
     47 sed 1d | tr -d '[:space:]:' | sha256 >> dat/cert.in
     48 
     49 # finally..
     50 ./verify dat/cert.in