summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawrence Teo <lteo@cvs.openbsd.org>2014-03-25 04:29:50 +0000
committerLawrence Teo <lteo@cvs.openbsd.org>2014-03-25 04:29:50 +0000
commit97c4290810337997562495544ba05bda297b8f23 (patch)
treeb5dac987ac9fd2141fc7abf82b216f6f921bb98c
parent065ddc2da574e53ea186fd98629707f3328aeb84 (diff)
Update the libskey regression tests:
- Remove the MD4 data sets since MD4 has been removed from base - Add new data sets for RMD-160 (suggested by millert@) - Ensure that the default algorithm is "md5" (as documented on the skey man pages) - Ensure that skey_set_algorithm() will not blindly accept an unsupported algorithm - Ensure that skey_set_algorithm() recognizes the algorithms in the provided data set - Ensure that skey_get_algorithm() returns the algorithm set by skey_set_algorithm() looks good to millert@
-rw-r--r--regress/lib/libskey/skeytest.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/regress/lib/libskey/skeytest.c b/regress/lib/libskey/skeytest.c
index 3da99cd42c3..933a2527223 100644
--- a/regress/lib/libskey/skeytest.c
+++ b/regress/lib/libskey/skeytest.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: skeytest.c,v 1.3 2008/06/26 05:42:05 ray Exp $ */
+/* $OpenBSD: skeytest.c,v 1.4 2014/03/25 04:29:49 lteo Exp $ */
/* $NetBSD: skeytest.c,v 1.3 2002/02/21 07:38:18 itojun Exp $ */
/*-
@@ -27,8 +27,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/* This is a regression test for the S/Key implementation
- against the data set from Appendix C of RFC2289 */
+/*
+ * This is a regression test for the S/Key implementation against the data set
+ * from Appendix C of RFC2289 without the MD4 set (MD4 support was removed from
+ * OpenBSD base in March 2014) and with the addition of an RIPEMD-160 set.
+ */
#include <stdio.h>
#include <string.h>
@@ -43,18 +46,18 @@ struct regPass {
struct regRes res[4];
} regPass[] = {
{ "This is a test.", "TeSt", {
- { "md4", "D1854218EBBB0B51", "63473EF01CD0B444", "C5E612776E6C237A" },
{ "md5", "9E876134D90499DD", "7965E05436F5029F", "50FE1962C4965880" },
+ { "rmd160","3A1BFB10A64B4CCD", "39D56BF655E65DE7", "42F84BA862941033" },
{ "sha1","BB9E6AE1979D8FF4", "63D936639734385B", "87FEC7768B73CCF9" },
{ NULL } } },
{ "AbCdEfGhIjK", "alpha1", {
- { "md4", "50076F47EB1ADE4E", "65D20D1949B5F7AB", "D150C82CCE6F62D1" },
{ "md5", "87066DD9644BF206", "7CD34C1040ADD14B", "5AA37A81F212146C" },
+ { "rmd160","726EDD1BB5DB3642", "46A231C501A1D2CE", "848664EF3A300CC9" },
{ "sha1","AD85F658EBE383C9", "D07CE229B5CF119B", "27BC71035AAF3DC6" },
{ NULL } } },
{ "OTP's are good", "correct", {
- { "md4", "849C79D4F6F55388", "8C0992FB250847B1", "3F3BF4B4145FD74B" },
{ "md5", "F205753943DE4CF9", "DDCDAC956F234937", "B203E28FA525BE47" },
+ { "rmd160","F90D03CC969208C8", "B6F5D25A08A90009", "C890C1F05018BA5F" },
{ "sha1","D51F3E99BF8E6F0B", "82AEB52D943774E4", "4F296A74FE1567EC" },
{ NULL } } },
{ NULL }
@@ -68,13 +71,35 @@ main(int argc, char *argv[])
int i = 0;
int errors = 0;
int j;
-
+
+ if (strcmp(skey_get_algorithm(), "md5") != 0) {
+ errors++;
+ printf("default algorithm is not md5\n");
+ }
+
+ if (skey_set_algorithm("md4") != NULL) {
+ errors++;
+ printf("accepted unsupported algorithm md4\n");
+ }
+
for(rp = regPass; rp->passphrase; rp++) {
struct regRes *rr;
i++;
for(rr = rp->res; rr->algo; rr++) {
- skey_set_algorithm(rr->algo);
+ if (skey_set_algorithm(rr->algo) == NULL) {
+ errors++;
+ printf("Set %d: %s algorithm is not supported\n",
+ i, rr->algo);
+ continue;
+ }
+
+ if (strcmp(skey_get_algorithm(), rr->algo) != 0) {
+ errors++;
+ printf("Set %d: unable to set algorithm to %s\n",
+ i, rr->algo);
+ continue;
+ }
keycrunch(data, rp->seed, rp->passphrase);
btoa8(prn, data);