aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/plugins/test_vectors/Makefile.am1
-rw-r--r--src/libstrongswan/plugins/test_vectors/test_vectors.h4
-rw-r--r--src/libstrongswan/plugins/test_vectors/test_vectors/des.c65
3 files changed, 70 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/test_vectors/Makefile.am b/src/libstrongswan/plugins/test_vectors/Makefile.am
index ce888c22f..4df30a65f 100644
--- a/src/libstrongswan/plugins/test_vectors/Makefile.am
+++ b/src/libstrongswan/plugins/test_vectors/Makefile.am
@@ -13,6 +13,7 @@ libstrongswan_test_vectors_la_SOURCES = \
test_vectors/blowfish.c \
test_vectors/camellia_cbc.c \
test_vectors/cast.c \
+ test_vectors/des.c \
test_vectors/idea.c \
test_vectors/rc5.c \
test_vectors/serpent_cbc.c \
diff --git a/src/libstrongswan/plugins/test_vectors/test_vectors.h b/src/libstrongswan/plugins/test_vectors/test_vectors.h
index 48cb62958..a85f8a9a7 100644
--- a/src/libstrongswan/plugins/test_vectors/test_vectors.h
+++ b/src/libstrongswan/plugins/test_vectors/test_vectors.h
@@ -28,6 +28,10 @@ TEST_VECTOR_CRYPTER(camellia_cbc4)
TEST_VECTOR_CRYPTER(camellia_cbc5)
TEST_VECTOR_CRYPTER(camellia_cbc6)
TEST_VECTOR_CRYPTER(cast1)
+TEST_VECTOR_CRYPTER(des_cbc1)
+TEST_VECTOR_CRYPTER(des_cbc2)
+TEST_VECTOR_CRYPTER(des_ecb1)
+TEST_VECTOR_CRYPTER(des_ecb2)
TEST_VECTOR_CRYPTER(des3_cbc1)
TEST_VECTOR_CRYPTER(des3_cbc2)
TEST_VECTOR_CRYPTER(idea1)
diff --git a/src/libstrongswan/plugins/test_vectors/test_vectors/des.c b/src/libstrongswan/plugins/test_vectors/test_vectors/des.c
new file mode 100644
index 000000000..80b5f1010
--- /dev/null
+++ b/src/libstrongswan/plugins/test_vectors/test_vectors/des.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Andreas Steffen
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the Licenseor (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be usefulbut
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include <crypto/crypto_tester.h>
+
+/**
+ * All testvectors from https://www.cosic.esat.kuleuven.be/nessie/testvectors/
+ */
+
+/**
+ * DES 56 bit: set 8, vector #0
+ */
+crypter_test_vector_t des_ecb1 = {
+ .alg = ENCR_DES_ECB, .key_size = 8, .len = 8,
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plain = "\x41\xAD\x06\x85\x48\x80\x9D\x02",
+ .cipher = "\x00\x11\x22\x33\x44\x55\x66\x77"
+};
+
+/**
+ * DES 56 bit: set 8, vector #1
+ */
+crypter_test_vector_t des_ecb2 = {
+ .alg = ENCR_DES_ECB, .key_size = 8, .len = 8,
+ .key = "\x2B\xD6\x45\x9F\x82\xC5\xB3\x00",
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plain = "\xB1\x0F\x84\x30\x97\xA0\xF9\x32",
+ .cipher = "\xEA\x02\x47\x14\xAD\x5C\x4D\x84"
+};
+
+/**
+ * DES 56 bit: set 8, vector #0
+ */
+crypter_test_vector_t des_cbc1 = {
+ .alg = ENCR_DES, .key_size = 8, .len = 8,
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plain = "\x41\xAD\x06\x85\x48\x80\x9D\x02",
+ .cipher = "\x00\x11\x22\x33\x44\x55\x66\x77"
+};
+
+/**
+ * DES 56 bit: set 8, vector #1
+ */
+crypter_test_vector_t des_cbc2 = {
+ .alg = ENCR_DES, .key_size = 8, .len = 8,
+ .key = "\x2B\xD6\x45\x9F\x82\xC5\xB3\x00",
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plain = "\xB1\x0F\x84\x30\x97\xA0\xF9\x32",
+ .cipher = "\xEA\x02\x47\x14\xAD\x5C\x4D\x84"
+};
+