summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Bar-Lev <alon.barlev@gmail.com>2015-06-21 20:43:34 +0300
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2015-06-22 20:46:33 +0200
commit3c4d62624eb0f8a0d4e0bc91dde4e97108360576 (patch)
tree85af5047ae5573a4faf1b4a9990800bdb4cf10db
parent01ac68dceee7da98da368d122f0bf592589ff9dd (diff)
downloadgnutls-3c4d62624eb0f8a0d4e0bc91dde4e97108360576.tar.gz
tests: suite: ciphersuite: fixups
fix separate builddir issue, without modifying locations, quite ugly. re-indent using tab. fix shebang. Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
-rwxr-xr-xtests/suite/ciphersuite/scan-gnutls.sh36
-rw-r--r--tests/suite/ciphersuite/test-ciphers.js106
-rwxr-xr-xtests/suite/ciphersuite/test-ciphersuites.sh24
3 files changed, 89 insertions, 77 deletions
diff --git a/tests/suite/ciphersuite/scan-gnutls.sh b/tests/suite/ciphersuite/scan-gnutls.sh
index 95cd9bdba5..2a2379eb48 100755
--- a/tests/suite/ciphersuite/scan-gnutls.sh
+++ b/tests/suite/ciphersuite/scan-gnutls.sh
@@ -1,23 +1,25 @@
-#/bin/sh
+#!/bin/sh
# ./scan-gnutls.sh > gnutls-ciphers.js
echo 'var gnutls_ciphersuites = {'
-cd ../../../lib/algorithms/ && gcc -E ciphersuites.c -I.. -I../../ -DHAVE_CONFIG_H -DHAVE_LIBNETTLE -I../../gl -I../includes -DENABLE_DHE -DENABLE_ECDHE -DENABLE_PSK -DENABLE_ANON -DENABLE_SRP \
- | awk '/^static const gnutls_cipher_suite_entry_st cs_algorithms/, /;/ { print; }' \
- | grep '{' | head -n-1 | tail -n+2 \
- | sed -r -e 's#\{ *0x(..), *0x(..) *\}#0x\1\2#;s# *\{ *"#"#;s#\}##;s#, +# #g' \
- -e 's#GNUTLS_VERSION_UNKNOWN#unknown#' \
- -e 's#GNUTLS_DTLS_VERSION_MIN#GNUTLS_DTLS1_0#;s#GNUTLS_TLS1 #GNUTLS_TLS1_0 #' \
- -e 's#TLS([0-9])_([0-9])#TLS\1.\2#g;s#GNUTLS_SSL3#SSL3.0#;s#_#-#g;s#GNUTLS-(CIPHER|KX|MAC)-##g;s#GNUTLS-##g' \
- | gawk --non-decimal-data '{ if ($5 == "AEAD") { mac = $8; } else { mac = $5; }; sub("UMAC-", "UMAC", mac); sub("DIG-", "", mac); if (mac == "SHA1") { mac = "SHA"; } \
- cipher = $3; sub("ARCFOUR", "RC4", cipher); sub("3DES-CBC", "3DES-EDE-CBC", cipher); \
- kx = $4; if (sub("ANON-", "", kx)) { kx = kx "-anon"; }; sub("SRP", "SRP-SHA", kx); \
- if ($5 != "AEAD" || cipher ~ /GCM/) { name = "TLS_" kx "_WITH_" cipher "_" mac; } else { name = "TLS_" kx "_WITH_" cipher }; \
- gsub("-", "_", name); printf ("%d# \"%s\": { id: %s, name: \"%s\", gnutlsname: %s, cipher: \"%s\", kx: \"%s\", mac: \"%s\", min_version: \"%s\", min_dtls_version: \"%s\", prf: \"%s\" },\n", $2, name, $2, name, $1, $3, $4, $5, $6, $7, $8) }' \
- | sort -n \
- | cut -d'#' -f2- \
- | column -t \
- | sed -e 's#: #: #g;s#, #, #g;s#{ #{ #g;s#^# #'
+srcdir="${srcdir:-..}"
+top_builddir="${top_builddir:-../../..}"
+gcc -E "${srcdir}/../../lib/algorithms/ciphersuites.c" -I"${top_builddir}" -I"${srcdir}/../../lib" -DHAVE_CONFIG_H -DHAVE_LIBNETTLE -I"${srcdir}/../../gl" -I"${srcdir}/../includes" -DENABLE_DHE -DENABLE_ECDHE -DENABLE_PSK -DENABLE_ANON -DENABLE_SRP \
+ | awk '/^static const gnutls_cipher_suite_entry_st cs_algorithms/, /;/ { print; }' \
+ | grep '{' | head -n-1 | tail -n+2 \
+ | sed -r -e 's#\{ *0x(..), *0x(..) *\}#0x\1\2#;s# *\{ *"#"#;s#\}##;s#, +# #g' \
+ -e 's#GNUTLS_VERSION_UNKNOWN#unknown#' \
+ -e 's#GNUTLS_DTLS_VERSION_MIN#GNUTLS_DTLS1_0#;s#GNUTLS_TLS1 #GNUTLS_TLS1_0 #' \
+ -e 's#TLS([0-9])_([0-9])#TLS\1.\2#g;s#GNUTLS_SSL3#SSL3.0#;s#_#-#g;s#GNUTLS-(CIPHER|KX|MAC)-##g;s#GNUTLS-##g' \
+ | gawk --non-decimal-data '{ if ($5 == "AEAD") { mac = $8; } else { mac = $5; }; sub("UMAC-", "UMAC", mac); sub("DIG-", "", mac); if (mac == "SHA1") { mac = "SHA"; } \
+ cipher = $3; sub("ARCFOUR", "RC4", cipher); sub("3DES-CBC", "3DES-EDE-CBC", cipher); \
+ kx = $4; if (sub("ANON-", "", kx)) { kx = kx "-anon"; }; sub("SRP", "SRP-SHA", kx); \
+ if ($5 != "AEAD" || cipher ~ /GCM/) { name = "TLS_" kx "_WITH_" cipher "_" mac; } else { name = "TLS_" kx "_WITH_" cipher }; \
+ gsub("-", "_", name); printf ("%d# \"%s\": { id: %s, name: \"%s\", gnutlsname: %s, cipher: \"%s\", kx: \"%s\", mac: \"%s\", min_version: \"%s\", min_dtls_version: \"%s\", prf: \"%s\" },\n", $2, name, $2, name, $1, $3, $4, $5, $6, $7, $8) }' \
+ | sort -n \
+ | cut -d'#' -f2- \
+ | column -t \
+ | sed -e 's#: #: #g;s#, #, #g;s#{ #{ #g;s#^# #'
echo '};'
diff --git a/tests/suite/ciphersuite/test-ciphers.js b/tests/suite/ciphersuite/test-ciphers.js
index 2336cb474a..1985045742 100644
--- a/tests/suite/ciphersuite/test-ciphers.js
+++ b/tests/suite/ciphersuite/test-ciphers.js
@@ -4,12 +4,20 @@ var fs = require('fs');
var vm = require('vm');
function include(path) {
- var code = fs.readFileSync(path, 'utf-8');
- vm.runInThisContext(code, path);
+ var code = fs.readFileSync(path, 'utf-8');
+ vm.runInThisContext(code, path);
}
-include('./gnutls-ciphers.js');
-include('./registry-ciphers.js');
+srcdir=process.env["srcdir"];
+if (srcdir == undefined) {
+ srcdir = ".";
+}
+builddir=process.env['builddir']
+if (builddir == undefined) {
+ builddir = ".";
+}
+include(builddir + "/gnutls-ciphers.js");
+include(srcdir + "/registry-ciphers.js");
(function() {
@@ -17,51 +25,51 @@ include('./registry-ciphers.js');
// console.log("Test: ", require('util').inspect(priority_config(priority(s)), false, 10));
// console.log("Test: ", require('util').inspect(priority_ciphersuites(priority(s)), false, 10));
- // check whether gnutls ciphersuite names match the kx/cipher/mac/prf combination
- for (var i in gnutls_ciphersuites) {
- if (!gnutls_ciphersuites.hasOwnProperty(i)) continue;
- var cs = gnutls_ciphersuites[i];
- var mac = cs.mac;
- if (mac == "AEAD") mac = cs.prf.replace("DIG-", "");
- mac = mac.replace("UMAC-", "UMAC");
- var cipher = cs.cipher.replace("3DES-CBC", "3DES-EDE-CBC");
- var kx = cs.kx.replace("ANON-DH", "DH-ANON").replace("ANON-ECDH", "ECDH-ANON").replace("SRP", "SRP-SHA");
+ // check whether gnutls ciphersuite names match the kx/cipher/mac/prf combination
+ for (var i in gnutls_ciphersuites) {
+ if (!gnutls_ciphersuites.hasOwnProperty(i)) continue;
+ var cs = gnutls_ciphersuites[i];
+ var mac = cs.mac;
+ if (mac == "AEAD") mac = cs.prf.replace("DIG-", "");
+ mac = mac.replace("UMAC-", "UMAC");
+ var cipher = cs.cipher.replace("3DES-CBC", "3DES-EDE-CBC");
+ var kx = cs.kx.replace("ANON-DH", "DH-ANON").replace("ANON-ECDH", "ECDH-ANON").replace("SRP", "SRP-SHA");
+
+ if (cs.mac == "AEAD") {
+ if (kx + "-" + cipher != cs.gnutlsname && kx + "-" + cipher + "-SHA256" != cs.gnutlsname && kx + "-" + cipher + "-SHA384" != cs.gnutlsname) {
+ console.log("Broken AEAD ciphersuite: ", kx + "-" + cipher, " ", cs.gnutlsname);
+ process.exit(1);
+ }
+ } else {
+ if (kx + "-" + cipher + "-" + mac != cs.gnutlsname) {
+ console.log("Broken ciphersuite name: ", kx + "-" + cipher + "-" + mac, " ", cs.gnutlsname);
+ process.exit(1);
+ }
+ }
+ if (cs.name !== i) {
+ console.log("Name doesn't match index:", cs.name, i);
+ process.exit(1);
+ }
+ if (!registry_ciphersuites[cs.id]) {
+ if (cipher.match(/SALSA20/)) {
+ var warned_salsa20;
+ if (!warned_salsa20) {
+ /* warn only once */
+ console.log("Unofficial SALSA20 ciphers");
+ warned_salsa20 = 1;
+ }
+ } else {
+ console.log("Unofficial cipher:", cs.name, cs.id);
+ }
+ } else if (registry_ciphersuites[cs.id] !== cs.name) {
+ if (cs.name !== "TLS_DHE_PSK_WITH_AES_128_CCM_8" &&
+ cs.name !== "TLS_DHE_PSK_WITH_AES_256_CCM_8") {
+ console.log("Name doesn't match official name for id:", cs.name, registry_ciphersuites[cs.id], cs.id);
+ process.exit(1);
+ }
+ }
+ }
- if (cs.mac == "AEAD") {
- if (kx + "-" + cipher != cs.gnutlsname && kx + "-" + cipher + "-SHA256" != cs.gnutlsname && kx + "-" + cipher + "-SHA384" != cs.gnutlsname) {
- console.log("Broken AEAD ciphersuite: ", kx + "-" + cipher, " ", cs.gnutlsname);
- process.exit(1);
- }
- } else {
- if (kx + "-" + cipher + "-" + mac != cs.gnutlsname) {
- console.log("Broken ciphersuite name: ", kx + "-" + cipher + "-" + mac, " ", cs.gnutlsname);
- process.exit(1);
- }
- }
- if (cs.name !== i) {
- console.log("Name doesn't match index:", cs.name, i);
- process.exit(1);
- }
- if (!registry_ciphersuites[cs.id]) {
- if (cipher.match(/SALSA20/)) {
- var warned_salsa20;
- if (!warned_salsa20) {
- /* warn only once */
- console.log("Unofficial SALSA20 ciphers");
- warned_salsa20 = 1;
- }
- } else {
- console.log("Unofficial cipher:", cs.name, cs.id);
- }
- } else if (registry_ciphersuites[cs.id] !== cs.name) {
- if (cs.name !== "TLS_DHE_PSK_WITH_AES_128_CCM_8" &&
- cs.name !== "TLS_DHE_PSK_WITH_AES_256_CCM_8") {
- console.log("Name doesn't match official name for id:", cs.name, registry_ciphersuites[cs.id], cs.id);
- process.exit(1);
- }
- }
- }
-
- process.exit(0);
+ process.exit(0);
})();
diff --git a/tests/suite/ciphersuite/test-ciphersuites.sh b/tests/suite/ciphersuite/test-ciphersuites.sh
index 028a92f8e7..88306dd12a 100755
--- a/tests/suite/ciphersuite/test-ciphersuites.sh
+++ b/tests/suite/ciphersuite/test-ciphersuites.sh
@@ -1,22 +1,24 @@
-#! /bin/sh
+#!/bin/sh
+
+srcdir="${srcdir:-..}"
+top_builddir="${top_builddir:-../../..}"
nodejs --help >/dev/null 2>&1
-if test $? = 0;then
-NODEJS=nodejs
+if test $? = 0; then
+ NODEJS=nodejs
else
- node --help >/dev/null 2>&1
- if test $? = 0;then
- NODEJS=node
- fi
+ node --help >/dev/null 2>&1
+ if test $? = 0; then
+ NODEJS=node
+ fi
fi
-if test "z$NODEJS" = "z";then
+if test -z "${NODEJS}"; then
echo "You need nodejs to run this test"
exit 77
fi
set -e
-cd ciphersuite && ( \
-./scan-gnutls.sh > gnutls-ciphers.js && \
-$NODEJS test-ciphers.js )
+"${srcdir}/ciphersuite/scan-gnutls.sh" > "${top_builddir}/tests/suite/ciphersuite/gnutls-ciphers.js"
+srcdir="${srcdir}/ciphersuite" builddir="${top_builddir}/tests/suite/ciphersuite" ${NODEJS} "${srcdir}/ciphersuite/test-ciphers.js"