BSD 4_4_Lite1 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Sun, 22 Jan 1989 01:45:28 +0000 (17:45 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Sun, 22 Jan 1989 01:45:28 +0000 (17:45 -0800)
Work on file Domestic/src/kerberosIV/des/key_parity.c
Work on file usr/src/kerberosIV/des/key_parity.c

Synthesized-from: CSRG/cd2/4.4BSD-Lite1

Domestic/src/kerberosIV/des/key_parity.c [new file with mode: 0644]
usr/src/kerberosIV/des/key_parity.c [new file with mode: 0644]

diff --git a/Domestic/src/kerberosIV/des/key_parity.c b/Domestic/src/kerberosIV/des/key_parity.c
new file mode 100644 (file)
index 0000000..539db98
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * $Source: /mit/kerberos/src/lib/des/RCS/key_parity.c,v $
+ * $Author: jtkohl $
+ *
+ * Copyright 1989 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ *
+ * These routines check and fix parity of encryption keys for the DES
+ * algorithm.
+ *
+ * Under U.S. law, this software may not be exported outside the US
+ * without license from the U.S. Commerce department.
+ *
+ * These routines form the library interface to the DES facilities.
+ *
+ */
+
+#ifndef        lint
+static char rcsid_key_parity_c[] =
+"$Header: key_parity.c,v 4.0 89/01/22 11:45:12 jtkohl Exp $";
+#endif lint
+
+#include <mit-copyright.h>
+#include <des.h>
+#include "des_internal.h"
+
+#include "odd.h"          /* Load compile-time generated odd_parity table */
+
+/*
+ * des_fixup_key_parity: Forces odd parity per byte; parity is bits
+ *                       8,16,...64 in des order, implies 0, 8, 16, ...
+ *                       vax order.
+ */
+void
+des_fixup_key_parity(key)
+     register des_cblock key;
+{
+    int i;
+
+    for (i=0; i<sizeof(des_cblock); i++)
+      key[i] = odd_parity[key[i]];
+
+    return;
+}
+
+/*
+ * des_check_key_parity: returns true iff key has the correct des parity.
+ *                       See des_fix_key_parity for the definition of
+ *                       correct des parity.
+ */
+int
+des_check_key_parity(key)
+     register des_cblock key;
+{
+    int i;
+
+    for (i=0; i<sizeof(des_cblock); i++)
+      if (key[i] != odd_parity[key[i]])
+       return(0);
+
+    return(1);
+}
diff --git a/usr/src/kerberosIV/des/key_parity.c b/usr/src/kerberosIV/des/key_parity.c
new file mode 100644 (file)
index 0000000..539db98
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * $Source: /mit/kerberos/src/lib/des/RCS/key_parity.c,v $
+ * $Author: jtkohl $
+ *
+ * Copyright 1989 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ *
+ * These routines check and fix parity of encryption keys for the DES
+ * algorithm.
+ *
+ * Under U.S. law, this software may not be exported outside the US
+ * without license from the U.S. Commerce department.
+ *
+ * These routines form the library interface to the DES facilities.
+ *
+ */
+
+#ifndef        lint
+static char rcsid_key_parity_c[] =
+"$Header: key_parity.c,v 4.0 89/01/22 11:45:12 jtkohl Exp $";
+#endif lint
+
+#include <mit-copyright.h>
+#include <des.h>
+#include "des_internal.h"
+
+#include "odd.h"          /* Load compile-time generated odd_parity table */
+
+/*
+ * des_fixup_key_parity: Forces odd parity per byte; parity is bits
+ *                       8,16,...64 in des order, implies 0, 8, 16, ...
+ *                       vax order.
+ */
+void
+des_fixup_key_parity(key)
+     register des_cblock key;
+{
+    int i;
+
+    for (i=0; i<sizeof(des_cblock); i++)
+      key[i] = odd_parity[key[i]];
+
+    return;
+}
+
+/*
+ * des_check_key_parity: returns true iff key has the correct des parity.
+ *                       See des_fix_key_parity for the definition of
+ *                       correct des parity.
+ */
+int
+des_check_key_parity(key)
+     register des_cblock key;
+{
+    int i;
+
+    for (i=0; i<sizeof(des_cblock); i++)
+      if (key[i] != odd_parity[key[i]])
+       return(0);
+
+    return(1);
+}