tests: Move code to add new DES keys to common
authorSimon Wilkinson <sxw@your-file-system.com>
Mon, 30 May 2011 17:18:33 +0000 (18:18 +0100)
committerDerrick Brashear <shadow@dementia.org>
Tue, 7 Jun 2011 14:50:30 +0000 (07:50 -0700)
Make the code which adds a new (static) DES key to a cell's
configuration generally available, as this will also be useful in
constructing other tests

Change-Id: I5d284016628e9d25a198607ffd6f8f1a63ddf652
Reviewed-on: http://gerrit.openafs.org/4807
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

tests/auth/superuser-t.c
tests/common/common.h
tests/common/config.c

index dae89c1..dd53b98 100644 (file)
@@ -38,6 +38,7 @@
 #include <afs/afsutil.h>
 #include <afs/com_err.h>
 
+#define HC_DEPRECATED
 #include <rx/rxkad.h>
 #include <rx/rx_identity.h>
 
@@ -436,7 +437,6 @@ int main(int argc, char **argv)
     struct afsconf_dir *dir;
     char *dirname;
     int serverPid, clientPid, waited, stat;
-    char keymaterial[]="\x19\x17\xff\xe6\xbb\x77\x2e\xfc";
     int code;
 
     /* Start the client and the server if requested */
@@ -465,10 +465,7 @@ int main(int argc, char **argv)
        exit(1);
     }
 
-    DES_set_odd_parity((DES_cblock *)keymaterial);
-
-    /* Add a key to it so we can use it for connection tests */
-    code = afsconf_AddKey(dir, 1, keymaterial, 1);
+    code = afstest_AddDESKeyFile(dir);
     if (code) {
        afs_com_err("superuser-t", code, "while adding new key\n");
        exit(1);
index 9f8fe2b..2bd2a27 100644 (file)
@@ -24,3 +24,6 @@
 
 extern char *afstest_BuildTestConfig(void);
 extern void afstest_UnlinkTestConfig(char *);
+
+struct afsconf_dir;
+extern int afstest_AddDESKeyFile(struct afsconf_dir *dir);
index 1170240..7574465 100644 (file)
 #include <afs/param.h>
 #include <roken.h>
 
+#include <afs/cellconfig.h>
 #include <afs/afsutil.h>
 
+#include <hcrypto/des.h>
+
 #include "common.h"
 
 static FILE *
@@ -110,3 +113,14 @@ afstest_UnlinkTestConfig(char *dir)
     unlinkConfigFile(dir, "UserList");
     rmdir(dir);
 }
+
+int
+afstest_AddDESKeyFile(struct afsconf_dir *dir)
+{
+    char keymaterial[]="\x19\x17\xff\xe6\xbb\x77\x2e\xfc";
+
+    /* Make sure that it is actually a valid key */
+    DES_set_odd_parity((DES_cblock *)keymaterial);
+
+    return afsconf_AddKey(dir, 1, keymaterial, 1);
+}