#! /bin/sh

LD_LIBRARY_PATH=`pwd`/src/openssl/.libs:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=`pwd`/src/gcrypt/.libs:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=`pwd`/src/gnutls/.libs:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH


CONFIG=test-20120910/xmlsec-crypto-config
CONFIG=test-20121124/xmlsec-crypto-config


check_envel_rsa_x509chain() {
echo === $1 $2 $3 ===

#--print-debug 
./apps/xmlsec1 sign \
  --crypto $1 --crypto-config $CONFIG \
  --pkcs12 tests/keys/rsakey.p12 --pwd secret \
  --output $3 \
  tests/aleksey-xmldsig-01/enveloping-rsa-x509chain.tmpl


./apps/xmlsec1 verify \
  --crypto $2 --crypto-config $CONFIG \
  --trusted-der tests/keys/cacert.der --enabled-key-data x509 \
  $3

echo +++
}


#ko#
check_envel_rsa_x509chain gnutls  gnutls  tmp-file-GxG
#ok#
check_envel_rsa_x509chain openssl gnutls  tmp-file-OxG
#ko#
check_envel_rsa_x509chain gnutls  openssl tmp-file-GxO
#ko#
check_envel_rsa_x509chain gnutls  nss     tmp-file-GxN


: || \
./apps/xmlsec1 verify \
  --crypto gnutls --crypto-config $CONFIG \
  --trusted-der tests/keys/cacert.der --enabled-key-data x509 \
  tmp-file-OxG
