Blame nss/tests/tools/tools.sh

Packit 40b132
#! /bin/bash  
Packit 40b132
#
Packit 40b132
# This Source Code Form is subject to the terms of the Mozilla Public
Packit 40b132
# License, v. 2.0. If a copy of the MPL was not distributed with this
Packit 40b132
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
#
Packit 40b132
# mozilla/security/nss/tests/tools/tools.sh
Packit 40b132
#
Packit 40b132
# Script to test basic functionality of NSS tools 
Packit 40b132
#
Packit 40b132
# needs to work on all Unix and Windows platforms
Packit 40b132
#
Packit 40b132
# tests implemented:
Packit 40b132
#    pk12util
Packit 40b132
#    signtool
Packit 40b132
#
Packit 40b132
# special strings
Packit 40b132
# ---------------
Packit 40b132
#   FIXME ... known problems, search for this string
Packit 40b132
#   NOTE .... unexpected behavior
Packit 40b132
########################################################################
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithSha1And128BitRc4=\
Packit 40b132
"PKCS #12 V2 PBE With SHA-1 and 128 Bit RC4"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithSha1And40BitRc4=\
Packit 40b132
"PKCS #12 V2 PBE With SHA-1 and 40 Bit RC4"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithSha1AndTripleDESCBC=\
Packit 40b132
"PKCS #12 V2 PBE With SHA-1 and Triple DES-CBC"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithSha1And128BitRc2Cbc=\
Packit 40b132
"PKCS #12 V2 PBE With SHA-1 and 128 Bit RC2 CBC"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithSha1And40BitRc2Cbc=\
Packit 40b132
"PKCS #12 V2 PBE With SHA-1 and 40 Bit RC2 CBC"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithMd2AndDESCBC=\
Packit 40b132
"PKCS #5 Password Based Encryption with MD2 and DES-CBC"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithMd5AndDESCBC=\
Packit 40b132
"PKCS #5 Password Based Encryption with MD5 and DES-CBC"
Packit 40b132
Packit 40b132
  export pkcs12v2pbeWithSha1AndDESCBC=\
Packit 40b132
"PKCS #5 Password Based Encryption with SHA-1 and DES-CBC"
Packit 40b132
  
Packit 40b132
  export pkcs5pbeWithMD2AndDEScbc=\
Packit 40b132
"PKCS #5 Password Based Encryption with MD2 and DES-CBC"
Packit 40b132
Packit 40b132
  export pkcs5pbeWithMD5AndDEScbc=\
Packit 40b132
"PKCS #5 Password Based Encryption with MD5 and DES-CBC"
Packit 40b132
Packit 40b132
  export pkcs5pbeWithSha1AndDEScbc=\
Packit 40b132
"PKCS #5 Password Based Encryption with SHA-1 and DES-CBC"
Packit 40b132
Packit 40b132
############################## tools_init ##############################
Packit 40b132
# local shell function to initialize this script 
Packit 40b132
########################################################################
Packit 40b132
tools_init()
Packit 40b132
{
Packit 40b132
  SCRIPTNAME=tools.sh      # sourced - $0 would point to all.sh
Packit 40b132
Packit 40b132
  if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
Packit 40b132
      CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
Packit 40b132
  fi
Packit 40b132
Packit 40b132
  if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
Packit 40b132
      cd ../common
Packit 40b132
      . ./init.sh
Packit 40b132
  fi
Packit 40b132
  if [ ! -r $CERT_LOG_FILE ]; then  # we need certificates here
Packit 40b132
      cd ../cert
Packit 40b132
      . ./cert.sh
Packit 40b132
  fi
Packit 40b132
  SCRIPTNAME=tools.sh
Packit 40b132
Packit 40b132
  if [ -z "$NSS_DISABLE_ECC" ] ; then
Packit 40b132
      html_head "Tools Tests with ECC"
Packit 40b132
  else
Packit 40b132
      html_head "Tools Tests"
Packit 40b132
  fi
Packit 40b132
Packit 40b132
  grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || {
Packit 40b132
      Exit 15 "Fatal - S/MIME of cert.sh needs to pass first"
Packit 40b132
  }
Packit 40b132
Packit 40b132
  TOOLSDIR=${HOSTDIR}/tools
Packit 40b132
  COPYDIR=${TOOLSDIR}/copydir
Packit 40b132
  SIGNDIR=${TOOLSDIR}/signdir
Packit 40b132
Packit 40b132
  R_TOOLSDIR=../tools
Packit 40b132
  R_COPYDIR=../tools/copydir
Packit 40b132
  R_SIGNDIR=../tools/signdir
Packit 40b132
  P_R_COPYDIR=${R_COPYDIR}
Packit 40b132
  P_R_SIGNDIR=${R_SIGNDIR}
Packit 40b132
  if [ -n "${MULTIACCESS_DBM}" ]; then
Packit 40b132
      P_R_COPYDIR="multiaccess:Tools.$version"
Packit 40b132
      P_R_SIGNDIR="multiaccess:Tools.sign.$version"
Packit 40b132
  fi
Packit 40b132
Packit 40b132
  mkdir -p ${TOOLSDIR}
Packit 40b132
  mkdir -p ${COPYDIR}
Packit 40b132
  mkdir -p ${SIGNDIR}
Packit 40b132
  cp ${ALICEDIR}/* ${SIGNDIR}/
Packit 40b132
  mkdir -p ${TOOLSDIR}/html
Packit 40b132
  cp ${QADIR}/tools/sign*.html ${TOOLSDIR}/html
Packit 40b132
Packit 40b132
  cd ${TOOLSDIR}
Packit 40b132
}
Packit 40b132
Packit 40b132
########################## list_p12_file ###############################
Packit 40b132
# List the key and cert in the specified p12 file
Packit 40b132
########################################################################
Packit 40b132
list_p12_file()
Packit 40b132
{
Packit 40b132
  echo "$SCRIPTNAME: Listing Alice's pk12 file"
Packit 40b132
  echo "pk12util -l ${1} -w ${R_PWFILE}"
Packit 40b132
    
Packit 40b132
  ${BINDIR}/pk12util -l ${1} -w ${R_PWFILE} 2>&1
Packit 40b132
  ret=$?
Packit 40b132
  html_msg $ret 0 "Listing ${1} (pk12util -l)"
Packit 40b132
  check_tmpfile
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Import the key and cert from the specified p12 file
Packit 40b132
########################################################################
Packit 40b132
import_p12_file()
Packit 40b132
{
Packit 40b132
  echo "$SCRIPTNAME: Importing Alice's pk12 ${1} file"
Packit 40b132
  echo "pk12util -i ${1} -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE}"
Packit 40b132
    
Packit 40b132
  ${BINDIR}/pk12util -i ${1} -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE} 2>&1
Packit 40b132
  ret=$?
Packit 40b132
  html_msg $ret 0 "Importing ${1} (pk12util -i)"
Packit 40b132
  check_tmpfile
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Export the key and cert to a p12 file using default ciphers
Packit 40b132
########################################################################
Packit 40b132
export_with_default_ciphers() 
Packit 40b132
{
Packit 40b132
  echo "$SCRIPTNAME: Exporting Alice's key & cert with [default:default] (pk12util -o)"
Packit 40b132
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
Packit 40b132
  echo "         -k ${R_PWFILE} -w ${R_PWFILE}"
Packit 40b132
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} \
Packit 40b132
                       -k ${R_PWFILE} -w ${R_PWFILE} 2>&1  
Packit 40b132
  ret=$?  
Packit 40b132
  html_msg $ret 0 "Exporting Alices's key & cert with [default:default] (pk12util -o)"
Packit 40b132
  check_tmpfile
Packit 40b132
  return $ret
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Exports key/cert to a p12 file, the key encryption cipher is specified
Packit 40b132
# and the cert encryption cipher is blank for default.
Packit 40b132
########################################################################
Packit 40b132
export_with_key_cipher() 
Packit 40b132
{
Packit 40b132
  # $1 key encryption cipher   
Packit 40b132
  echo "$SCRIPTNAME: Exporting with [${1}:default]"
Packit 40b132
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
Packit 40b132
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -c ${1}"
Packit 40b132
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} \
Packit 40b132
                     -k ${R_PWFILE} -w ${R_PWFILE} -c "${1}" 2>&1  
Packit 40b132
  ret=$?  
Packit 40b132
  html_msg $ret 0 "Exporting with [${1}:default] (pk12util -o)"
Packit 40b132
  check_tmpfile
Packit 40b132
  return $ret
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Exports key/cert to a p12 file, the key encryption cipher is left
Packit 40b132
# empty for default and the cert encryption cipher is specified.
Packit 40b132
########################################################################
Packit 40b132
export_with_cert_cipher() 
Packit 40b132
{
Packit 40b132
  # $1 certificate encryption cipher
Packit 40b132
  echo "$SCRIPTNAME: Exporting with [default:${1}]"
Packit 40b132
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
Packit 40b132
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -C ${1}"
Packit 40b132
  ${BINDIR}/pk12util -o Alice.p12 -n "Alice" -d ${P_R_ALICEDIR} \
Packit 40b132
                     -k ${R_PWFILE} -w ${R_PWFILE} -C "${1}" 2>&1  
Packit 40b132
  ret=$?  
Packit 40b132
  html_msg $ret 0 "Exporting with [default:${1}] (pk12util -o)"
Packit 40b132
  check_tmpfile
Packit 40b132
  return $ret
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Exports key/cert to a p12 file, both the key encryption cipher and
Packit 40b132
# the cert encryption cipher are specified.
Packit 40b132
########################################################################
Packit 40b132
export_with_both_key_and_cert_cipher()
Packit 40b132
{
Packit 40b132
  # $1 key encryption cipher or ""
Packit 40b132
  # $2 certificate encryption cipher or ""
Packit 40b132
  
Packit 40b132
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
Packit 40b132
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -c ${1} -C ${2}"     
Packit 40b132
  ${BINDIR}/pk12util -o Alice.p12 -n Alice -d ${P_R_ALICEDIR} \
Packit 40b132
                       -k ${R_PWFILE} -w ${R_PWFILE} \
Packit 40b132
                       -c "${1}" -C "${2}" 2>&1  
Packit 40b132
  ret=$?    
Packit 40b132
  html_msg $ret 0 "Exporting with [${1}:${2}] (pk12util -o)"
Packit 40b132
  check_tmpfile
Packit 40b132
  return $ret
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Exports key and cert to a p12 file, both the key encryption cipher 
Packit 40b132
# and the cert encryption cipher are specified. The key and cert are
Packit 40b132
# imported and the p12 file is listed
Packit 40b132
########################################################################
Packit 40b132
export_list_import()
Packit 40b132
{
Packit 40b132
  # $1 key encryption cipher
Packit 40b132
  # $2 certificate encryption cipher
Packit 40b132
    
Packit 40b132
  if [ "${1}" != "DEFAULT" -a "${2}" != "DEFAULT" ]; then
Packit 40b132
      export_with_both_key_and_cert_cipher "${1}" "${2}"
Packit 40b132
  elif [ "${1}" != "DEFAULT" -a "${2}" = "DEFAULT" ]; then
Packit 40b132
      export_with_key_cipher "${1}"
Packit 40b132
  elif [ "${1}" = "DEFAULT" -a "${2}" != "DEFAULT" ]; then
Packit 40b132
      export_with_cert_cipher "${2}"
Packit 40b132
  else
Packit 40b132
      export_with_default_ciphers
Packit 40b132
  fi
Packit 40b132
    
Packit 40b132
  list_p12_file Alice.p12
Packit 40b132
  import_p12_file Alice.p12
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Export using the pkcs5pbe ciphers for key and certificate encryption.
Packit 40b132
# List the contents of and import from the p12 file.
Packit 40b132
########################################################################
Packit 40b132
tools_p12_export_list_import_all_pkcs5pbe_ciphers()
Packit 40b132
{  
Packit 40b132
  # specify each on key and cert cipher
Packit 40b132
  for key_cipher in "${pkcs5pbeWithMD2AndDEScbc}" \
Packit 40b132
                    "${pkcs5pbeWithMD5AndDEScbc}" \
Packit 40b132
                    "${pkcs5pbeWithSha1AndDEScbc}"\
Packit 40b132
                    "DEFAULT"; do
Packit 40b132
      for cert_cipher in "${pkcs5pbeWithMD2AndDEScbc}" \
Packit 40b132
                         "${pkcs5pbeWithMD5AndDEScbc}" \
Packit 40b132
                         "${pkcs5pbeWithSha1AndDEScbc}" \
Packit 40b132
                         "DEFAULT"\
Packit 40b132
                         "null"; do
Packit 40b132
            export_list_import "${key_cipher}" "${cert_cipher}"
Packit 40b132
      done       
Packit 40b132
  done
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Export using the pkcs5v2 ciphers for key and certificate encryption.
Packit 40b132
# List the contents of and import from the p12 file.
Packit 40b132
########################################################################
Packit 40b132
tools_p12_export_list_import_all_pkcs5v2_ciphers()
Packit 40b132
{
Packit 40b132
  # These should pass
Packit 40b132
  for key_cipher in\
Packit 40b132
    RC2-CBC \
Packit 40b132
    DES-EDE3-CBC \
Packit 40b132
    AES-128-CBC \
Packit 40b132
    AES-192-CBC \
Packit 40b132
    AES-256-CBC \
Packit 40b132
    CAMELLIA-128-CBC \
Packit 40b132
    CAMELLIA-192-CBC \
Packit 40b132
    CAMELLIA-256-CBC; do
Packit 40b132
Packit 40b132
#---------------------------------------------------------------
Packit 40b132
# Bug 452464 - pk12util -o fails when -C option specifies AES or
Packit 40b132
# Camellia ciphers
Packit 40b132
# FIXME Restore these to the list
Packit 40b132
#    AES-128-CBC, \
Packit 40b132
#    AES-192-CBC, \
Packit 40b132
#    AES-256-CBC, \
Packit 40b132
#    CAMELLIA-128-CBC, \
Packit 40b132
#    CAMELLIA-192-CBC, \
Packit 40b132
#    CAMELLIA-256-CBC, \
Packit 40b132
#  when 452464 is fixed
Packit 40b132
#---------------------------------------------------------------  
Packit 40b132
    for cert_cipher in \
Packit 40b132
      RC2-CBC \
Packit 40b132
      DES-EDE3-CBC \
Packit 40b132
      null; do
Packit 40b132
	  export_list_import ${key_cipher} ${cert_cipher}
Packit 40b132
	done
Packit 40b132
  done
Packit 40b132
}
Packit 40b132
Packit 40b132
########################################################################
Packit 40b132
# Export using the pkcs12v2pbe ciphers for key and certificate encryption.
Packit 40b132
# List the contents of and import from the p12 file.
Packit 40b132
########################################################################
Packit 40b132
tools_p12_export_list_import_all_pkcs12v2pbe_ciphers()
Packit 40b132
{ 
Packit 40b132
#---------------------------------------------------------------
Packit 40b132
# Bug 452471 - pk12util -o fails when -c option specifies pkcs12v2 PBE ciphers
Packit 40b132
# FIXME - Restore these to the list 
Packit 40b132
#                "${pkcs12v2pbeWithSha1And128BitRc4}" \
Packit 40b132
#                "${pkcs12v2pbeWithSha1And40BitRc4}" \
Packit 40b132
#	             "${pkcs12v2pbeWithSha1AndTripleDESCBC}" \
Packit 40b132
#                "${pkcs12v2pbeWithSha1And128BitRc2Cbc}" \
Packit 40b132
#                "${pkcs12v2pbeWithSha1And40BitRc2Cbc}" \
Packit 40b132
#                "${pkcs12v2pbeWithMd2AndDESCBC}" \
Packit 40b132
#                "${pkcs12v2pbeWithMd5AndDESCBC}" \
Packit 40b132
#                "${pkcs12v2pbeWithSha1AndDESCBC}" \
Packit 40b132
#                "DEFAULT"; do
Packit 40b132
# when 452471 is fixed
Packit 40b132
#---------------------------------------------------------------
Packit 40b132
#  for key_cipher in \
Packit 40b132
    key_cipher="DEFAULT"
Packit 40b132
    for cert_cipher in "${pkcs12v2pbeWithSha1And128BitRc4}" \
Packit 40b132
                  "${pkcs12v2pbeWithSha1And40BitRc4}" \
Packit 40b132
                  "${pkcs12v2pbeWithSha1AndTripleDESCBC}" \
Packit 40b132
                  "${pkcs12v2pbeWithSha1And128BitRc2Cbc}" \
Packit 40b132
                  "${pkcs12v2pbeWithSha1And40BitRc2Cbc}" \
Packit 40b132
                  "${pkcs12v2pbeWithMd2AndDESCBC}" \
Packit 40b132
                  "${pkcs12v2pbeWithMd5AndDESCBC}" \
Packit 40b132
                  "${pkcs12v2pbeWithSha1AndDESCBC}" \
Packit 40b132
                  "DEFAULT"\
Packit 40b132
                  "null"; do        
Packit 40b132
	  export_list_import "${key_cipher}" "${key_cipher}" 
Packit 40b132
	done
Packit 40b132
  #done
Packit 40b132
}
Packit 40b132
Packit 40b132
#########################################################################
Packit 40b132
# Export with no encryption on key should fail but on cert should pass
Packit 40b132
#########################################################################
Packit 40b132
tools_p12_export_with_null_ciphers()
Packit 40b132
{
Packit 40b132
  # use null as the key encryption algorithm default for the cert one
Packit 40b132
  # should fail
Packit 40b132
  
Packit 40b132
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
Packit 40b132
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -c null"     
Packit 40b132
  ${BINDIR}/pk12util -o Alice.p12 -n Alice -d ${P_R_ALICEDIR} \
Packit 40b132
                       -k ${R_PWFILE} -w ${R_PWFILE} \
Packit 40b132
                       -c null 2>&1  
Packit 40b132
  ret=$?
Packit 40b132
  html_msg $ret 30 "Exporting with [null:default] (pk12util -o)"
Packit 40b132
  check_tmpfile
Packit 40b132
Packit 40b132
  # use default as the key encryption algorithm null for the cert one
Packit 40b132
  # should pass
Packit 40b132
  
Packit 40b132
  echo "pk12util -o Alice.p12 -n \"Alice\" -d ${P_R_ALICEDIR} \\"
Packit 40b132
  echo "         -k ${R_PWFILE} -w ${R_PWFILE} -C null"     
Packit 40b132
  ${BINDIR}/pk12util -o Alice.p12 -n Alice -d ${P_R_ALICEDIR} \
Packit 40b132
                       -k ${R_PWFILE} -w ${R_PWFILE} \
Packit 40b132
                       -C null 2>&1  
Packit 40b132
  ret=$?
Packit 40b132
  html_msg $ret 0 "Exporting with [default:null] (pk12util -o)"
Packit 40b132
  check_tmpfile
Packit 40b132
 
Packit 40b132
}
Packit 40b132
Packit 40b132
#########################################################################
Packit 40b132
# Exports using the default key and certificate encryption ciphers.
Packit 40b132
# Imports from  and lists the contents of the p12 file.
Packit 40b132
# Repeats the test with ECC if enabled.
Packit 40b132
########################################################################
Packit 40b132
tools_p12_export_list_import_with_default_ciphers()
Packit 40b132
{
Packit 40b132
  echo "$SCRIPTNAME: Exporting Alice's email cert & key - default ciphers"
Packit 40b132
  
Packit 40b132
  export_list_import "DEFAULT" "DEFAULT"
Packit 40b132
Packit 40b132
  if [ -z "$NSS_DISABLE_ECC" ] ; then
Packit 40b132
      echo "$SCRIPTNAME: Exporting Alice's email EC cert & key---------------"
Packit 40b132
      echo "pk12util -o Alice-ec.p12 -n \"Alice-ec\" -d ${P_R_ALICEDIR} -k ${R_PWFILE} \\"
Packit 40b132
      echo "         -w ${R_PWFILE}"
Packit 40b132
      ${BINDIR}/pk12util -o Alice-ec.p12 -n "Alice-ec" -d ${P_R_ALICEDIR} -k ${R_PWFILE} \
Packit 40b132
           -w ${R_PWFILE} 2>&1 
Packit 40b132
      ret=$?
Packit 40b132
      html_msg $ret 0 "Exporting Alice's email EC cert & key (pk12util -o)"
Packit 40b132
      check_tmpfile
Packit 40b132
Packit 40b132
      echo "$SCRIPTNAME: Importing Alice's email EC cert & key --------------"
Packit 40b132
      echo "pk12util -i Alice-ec.p12 -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE}"
Packit 40b132
      ${BINDIR}/pk12util -i Alice-ec.p12 -d ${P_R_COPYDIR} -k ${R_PWFILE} -w ${R_PWFILE} 2>&1
Packit 40b132
      ret=$?
Packit 40b132
      html_msg $ret 0 "Importing Alice's email EC cert & key (pk12util -i)"
Packit 40b132
      check_tmpfile
Packit 40b132
Packit 40b132
      echo "$SCRIPTNAME: Listing Alice's pk12 EC file -----------------"
Packit 40b132
      echo "pk12util -l Alice-ec.p12 -w ${R_PWFILE}"
Packit 40b132
      ${BINDIR}/pk12util -l Alice-ec.p12 -w ${R_PWFILE} 2>&1
Packit 40b132
      ret=$?
Packit 40b132
      html_msg $ret 0 "Listing Alice's pk12 EC file (pk12util -l)"
Packit 40b132
      check_tmpfile
Packit 40b132
  fi
Packit 40b132
}
Packit 40b132
Packit 40b132
############################## tools_p12 ###############################
Packit 40b132
# local shell function to test basic functionality of pk12util
Packit 40b132
########################################################################
Packit 40b132
tools_p12()
Packit 40b132
{
Packit 40b132
  tools_p12_export_list_import_with_default_ciphers
Packit 40b132
  tools_p12_export_list_import_all_pkcs5v2_ciphers
Packit 40b132
  tools_p12_export_list_import_all_pkcs5pbe_ciphers
Packit 40b132
  tools_p12_export_list_import_all_pkcs12v2pbe_ciphers
Packit 40b132
  tools_p12_export_with_null_ciphers
Packit 40b132
}
Packit 40b132
Packit 40b132
############################## tools_sign ##############################
Packit 40b132
# local shell function pk12util uses a hardcoded tmp file, if this exists
Packit 40b132
# and is owned by another user we don't get reasonable errormessages 
Packit 40b132
########################################################################
Packit 40b132
check_tmpfile()
Packit 40b132
{
Packit 40b132
  if [ $ret != "0" -a -f /tmp/Pk12uTemp ] ; then
Packit 40b132
      echo "Error: pk12util temp file exists. Please remove this file and"
Packit 40b132
      echo "       rerun the test (/tmp/Pk12uTemp) "
Packit 40b132
  fi
Packit 40b132
}
Packit 40b132
Packit 40b132
############################## tools_sign ##############################
Packit 40b132
# local shell function to test basic functionality of signtool
Packit 40b132
########################################################################
Packit 40b132
tools_sign()
Packit 40b132
{
Packit 40b132
  echo "$SCRIPTNAME: Create objsign cert -------------------------------"
Packit 40b132
  echo "signtool -G \"objectsigner\" -d ${P_R_SIGNDIR} -p \"nss\""
Packit 40b132
  ${BINDIR}/signtool -G "objsigner" -d ${P_R_SIGNDIR} -p "nss" 2>&1 <
Packit 40b132
y
Packit 40b132
TEST
Packit 40b132
MOZ
Packit 40b132
NSS
Packit 40b132
NY
Packit 40b132
US
Packit 40b132
liz
Packit 40b132
liz@moz.org
Packit 40b132
SIGNSCRIPT
Packit 40b132
  html_msg $? 0 "Create objsign cert (signtool -G)"
Packit 40b132
Packit 40b132
  echo "$SCRIPTNAME: Signing a jar of files ----------------------------"
Packit 40b132
  echo "signtool -Z nojs.jar -d ${P_R_SIGNDIR} -p \"nss\" -k objsigner \\"
Packit 40b132
  echo "         ${R_TOOLSDIR}/html"
Packit 40b132
  ${BINDIR}/signtool -Z nojs.jar -d ${P_R_SIGNDIR} -p "nss" -k objsigner \
Packit 40b132
           ${R_TOOLSDIR}/html
Packit 40b132
  html_msg $? 0 "Signing a jar of files (signtool -Z)"
Packit 40b132
Packit 40b132
  echo "$SCRIPTNAME: Listing signed files in jar ----------------------"
Packit 40b132
  echo "signtool -v nojs.jar -d ${P_R_SIGNDIR} -p nss -k objsigner"
Packit 40b132
  ${BINDIR}/signtool -v nojs.jar -d ${P_R_SIGNDIR} -p nss -k objsigner
Packit 40b132
  html_msg $? 0 "Listing signed files in jar (signtool -v)"
Packit 40b132
Packit 40b132
  echo "$SCRIPTNAME: Show who signed jar ------------------------------"
Packit 40b132
  echo "signtool -w nojs.jar -d ${P_R_SIGNDIR}"
Packit 40b132
  ${BINDIR}/signtool -w nojs.jar -d ${P_R_SIGNDIR}
Packit 40b132
  html_msg $? 0 "Show who signed jar (signtool -w)"
Packit 40b132
Packit 40b132
  echo "$SCRIPTNAME: Signing a xpi of files ----------------------------"
Packit 40b132
  echo "signtool -Z nojs.xpi -X -d ${P_R_SIGNDIR} -p \"nss\" -k objsigner \\"
Packit 40b132
  echo "         ${R_TOOLSDIR}/html"
Packit 40b132
  ${BINDIR}/signtool -Z nojs.xpi -X -d ${P_R_SIGNDIR} -p "nss" -k objsigner \
Packit 40b132
           ${R_TOOLSDIR}/html
Packit 40b132
  html_msg $? 0 "Signing a xpi of files (signtool -Z -X)"
Packit 40b132
Packit 40b132
  echo "$SCRIPTNAME: Listing signed files in xpi ----------------------"
Packit 40b132
  echo "signtool -v nojs.xpi -d ${P_R_SIGNDIR} -p nss -k objsigner"
Packit 40b132
  ${BINDIR}/signtool -v nojs.xpi -d ${P_R_SIGNDIR} -p nss -k objsigner
Packit 40b132
  html_msg $? 0 "Listing signed files in xpi (signtool -v)"
Packit 40b132
Packit 40b132
  echo "$SCRIPTNAME: Show who signed xpi ------------------------------"
Packit 40b132
  echo "signtool -w nojs.xpi -d ${P_R_SIGNDIR}"
Packit 40b132
  ${BINDIR}/signtool -w nojs.xpi -d ${P_R_SIGNDIR}
Packit 40b132
  html_msg $? 0 "Show who signed xpi (signtool -w)"
Packit 40b132
Packit 40b132
}
Packit 40b132
Packit 40b132
############################## tools_cleanup ###########################
Packit 40b132
# local shell function to finish this script (no exit since it might be 
Packit 40b132
# sourced)
Packit 40b132
########################################################################
Packit 40b132
tools_cleanup()
Packit 40b132
{
Packit 40b132
  html "
"
Packit 40b132
  cd ${QADIR}
Packit 40b132
  . common/cleanup.sh
Packit 40b132
}
Packit 40b132
Packit 40b132
################## main #################################################
Packit 40b132
Packit 40b132
tools_init
Packit 40b132
tools_p12
Packit 40b132
tools_sign
Packit 40b132
tools_cleanup
Packit 40b132
Packit 40b132