summaryrefslogtreecommitdiff
path: root/sys/src/cmd/unix/drawterm/libsec/genrandom.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2013-11-23 01:05:33 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2013-11-23 01:05:33 +0100
commit2f9ae0f8ac8610e13ced184847b57b87fe5db580 (patch)
treef9ad2223d518585a2cfe9ea1c73e1e37d07bf637 /sys/src/cmd/unix/drawterm/libsec/genrandom.c
parentea5797c0731203c09ec5fb7172e77eab2750f1a9 (diff)
removing (outdated) drawterm
drawterm is much better maintained by russ cox, so removing this outdated copy. for a more recent version, go to: http://swtch.com/drawterm/
Diffstat (limited to 'sys/src/cmd/unix/drawterm/libsec/genrandom.c')
-rw-r--r--sys/src/cmd/unix/drawterm/libsec/genrandom.c62
1 files changed, 0 insertions, 62 deletions
diff --git a/sys/src/cmd/unix/drawterm/libsec/genrandom.c b/sys/src/cmd/unix/drawterm/libsec/genrandom.c
deleted file mode 100644
index 2cbaeb8c4..000000000
--- a/sys/src/cmd/unix/drawterm/libsec/genrandom.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "os.h"
-#include <mp.h>
-#include <libsec.h>
-
-typedef struct State{
- QLock lock;
- int seeded;
- uvlong seed;
- DES3state des3;
-} State;
-static State x917state;
-
-static void
-X917(uchar *rand, int nrand)
-{
- int i, m, n8;
- uvlong I, x;
-
- /* 1. Compute intermediate value I = Ek(time). */
- I = nsec();
- triple_block_cipher(x917state.des3.expanded, (uchar*)&I, 0); /* two-key EDE */
-
- /* 2. x[i] = Ek(I^seed); seed = Ek(x[i]^I); */
- m = (nrand+7)/8;
- for(i=0; i<m; i++){
- x = I ^ x917state.seed;
- triple_block_cipher(x917state.des3.expanded, (uchar*)&x, 0);
- n8 = (nrand>8) ? 8 : nrand;
- memcpy(rand, (uchar*)&x, n8);
- rand += 8;
- nrand -= 8;
- x ^= I;
- triple_block_cipher(x917state.des3.expanded, (uchar*)&x, 0);
- x917state.seed = x;
- }
-}
-
-static void
-X917init(void)
-{
- int n;
- uchar mix[128];
- uchar key3[3][8];
- ulong *ulp;
-
- ulp = (ulong*)key3;
- for(n = 0; n < sizeof(key3)/sizeof(ulong); n++)
- ulp[n] = truerand();
- setupDES3state(&x917state.des3, key3, nil);
- X917(mix, sizeof mix);
- x917state.seeded = 1;
-}
-
-void
-genrandom(uchar *p, int n)
-{
- qlock(&x917state.lock);
- if(x917state.seeded == 0)
- X917init();
- X917(p, n);
- qunlock(&x917state.lock);
-}