summaryrefslogtreecommitdiff
path: root/kerberosIV/des/random_key.c
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1995-12-14 06:52:55 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1995-12-14 06:52:55 +0000
commit8cf1f2a33575f93a2a1411591dea02dadfff25a0 (patch)
tree546551ebd40f0dfbbb6016a6028d467641b4ed8b /kerberosIV/des/random_key.c
parent02a248da23b192dd04bdb0fe2d61202086e9ceb3 (diff)
Kerberos IV code, based on a merge of fixed code from KTH and original
4.4BSD Lite code (international edition). Provides all functionality from the original 4.4BSD code plus standard Kerberos elements that were omitted in the 4.4BSD code.
Diffstat (limited to 'kerberosIV/des/random_key.c')
-rw-r--r--kerberosIV/des/random_key.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/kerberosIV/des/random_key.c b/kerberosIV/des/random_key.c
new file mode 100644
index 00000000000..f878824e4f8
--- /dev/null
+++ b/kerberosIV/des/random_key.c
@@ -0,0 +1,34 @@
+/* $Id: random_key.c,v 1.1 1995/12/14 06:52:45 tholo Exp $ */
+
+/* Copyright (C) 1992 Eric Young - see COPYING for more details */
+#include "des_locl.h"
+
+void des_random_key(ret)
+des_cblock ret;
+ {
+ des_key_schedule ks;
+ static u_int32_t c=0;
+ static pid_t pid=0;
+ static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
+ des_cblock key;
+
+#ifdef MSDOS
+ pid=1;
+#else
+ if (!pid) pid=getpid();
+#endif
+ ((u_int32_t *)key)[0]=(u_int32_t)time(NULL);
+ ((u_int32_t *)key)[1]=(u_int32_t)((pid)|((c++)<<16));
+
+ des_set_odd_parity((des_cblock *)data);
+ des_set_key((des_cblock *)data,ks);
+ des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
+ (int32_t)sizeof(key),ks,(des_cblock *)data);
+ des_set_odd_parity((des_cblock *)key);
+ des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
+ (int32_t)sizeof(key),ks,(des_cblock *)data);
+
+ bcopy(key,ret,sizeof(key));
+ bzero(key,sizeof(key));
+ bzero(ks,sizeof(ks));
+ }