tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ectest.sh (2590B)


      1 #! /bin/bash
      2 #
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 ########################################################################
      8 #
      9 # tests/ec/ectest.sh
     10 #
     11 # needs to work on all Unix and Windows platforms
     12 #
     13 # special strings
     14 # ---------------
     15 #   FIXME ... known problems, search for this string
     16 #   NOTE .... unexpected behavior
     17 #
     18 ########################################################################
     19 
     20 ############################## ectest_init #############################
     21 # local shell function to initialize this script
     22 ########################################################################
     23 
     24 ectest_init()
     25 {
     26  SCRIPTNAME="ectest.sh"
     27  if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ] ; then
     28      cd ../common
     29      . ./init.sh
     30  fi
     31  SCRIPTNAME="ectest.sh"
     32  html_head "freebl and pk11 ectest tests"
     33 }
     34 
     35 ectest_cleanup()
     36 {
     37  html "</TABLE><BR>"
     38  cd ${QADIR}
     39  . common/cleanup.sh
     40 }
     41 
     42 ectest_genkeydb_test()
     43 {
     44  certutil -N -d "${HOSTDIR}" -f "${R_PWFILE}" 2>&1
     45  if [ $? -ne 0 ]; then
     46    return $?
     47  fi
     48  curves=( \
     49    "curve25519" \
     50    "secp256r1" \
     51    "secp384r1" \
     52    "secp521r1" \
     53  )
     54  for curve in "${curves[@]}"; do
     55    echo "Test $curve key generation using certutil ..."
     56    certutil -G -d "${HOSTDIR}" -k ec -q $curve -f "${R_PWFILE}" -z ${NOISE_FILE}
     57    if [ $? -ne 0 ]; then
     58      html_failed "ec test certutil keygen - $curve"
     59    else
     60      html_passed "ec test certutil keygen - $curve"
     61    fi
     62  done
     63  echo "Test sect571r1 key generation using certutil that should fail because it's not implemented ..."
     64  certutil -G -d "${HOSTDIR}" -k ec -q sect571r1 -f "${R_PWFILE}" -z ${NOISE_FILE}
     65  if [ $? -eq 0 ]; then
     66    html_failed "ec test certutil keygen - $curve"
     67  else
     68    html_passed "ec test certutil keygen - $curve"
     69  fi
     70 }
     71 
     72 ectest_init
     73 ectest_genkeydb_test
     74 # TODO: expose individual tests and failures instead of overall
     75 if [ -f ${BINDIR}/fbectest ]; then
     76  FB_ECTEST_OUT=$(fbectest -n -d 2>&1)
     77  FB_ECTEST_OUT=`echo $FB_ECTEST_OUT | grep -i 'not okay\|Assertion failure'`
     78  if [ -n "$FB_ECTEST_OUT" ] ; then
     79    html_failed "freebl ec tests"
     80  else
     81    html_passed "freebl ec tests"
     82  fi
     83 fi
     84 if [ -f ${BINDIR}/pk11ectest ]; then
     85  PK11_ECTEST_OUT=$(pk11ectest -n -d 2>&1)
     86  PK11_ECTEST_OUT=`echo $PK11_ECTEST_OUT | grep -i 'not okay\|Assertion failure'`
     87  if [ -n "$PK11_ECTEST_OUT" ] ; then
     88    html_failed "pk11 ec tests"
     89  else
     90    html_passed "pk11 ec tests"
     91  fi
     92 fi
     93 ectest_cleanup