Mercurial > dropbear
comparison mtest/mtest.c @ 190:d8254fc979e9 libtommath-orig LTM_0.35
Initial import of libtommath 0.35
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 06 May 2005 08:59:30 +0000 |
parents | d29b64170cf0 |
children |
comparison
equal
deleted
inserted
replaced
142:d29b64170cf0 | 190:d8254fc979e9 |
---|---|
44 void rand_num(mp_int *a) | 44 void rand_num(mp_int *a) |
45 { | 45 { |
46 int n, size; | 46 int n, size; |
47 unsigned char buf[2048]; | 47 unsigned char buf[2048]; |
48 | 48 |
49 size = 1 + ((fgetc(rng)<<8) + fgetc(rng)) % 1031; | 49 size = 1 + ((fgetc(rng)<<8) + fgetc(rng)) % 101; |
50 buf[0] = (fgetc(rng)&1)?1:0; | 50 buf[0] = (fgetc(rng)&1)?1:0; |
51 fread(buf+1, 1, size, rng); | 51 fread(buf+1, 1, size, rng); |
52 while (buf[1] == 0) buf[1] = fgetc(rng); | 52 while (buf[1] == 0) buf[1] = fgetc(rng); |
53 mp_read_raw(a, buf, 1+size); | 53 mp_read_raw(a, buf, 1+size); |
54 } | 54 } |
56 void rand_num2(mp_int *a) | 56 void rand_num2(mp_int *a) |
57 { | 57 { |
58 int n, size; | 58 int n, size; |
59 unsigned char buf[2048]; | 59 unsigned char buf[2048]; |
60 | 60 |
61 size = 10 + ((fgetc(rng)<<8) + fgetc(rng)) % 97; | 61 size = 10 + ((fgetc(rng)<<8) + fgetc(rng)) % 101; |
62 buf[0] = (fgetc(rng)&1)?1:0; | 62 buf[0] = (fgetc(rng)&1)?1:0; |
63 fread(buf+1, 1, size, rng); | 63 fread(buf+1, 1, size, rng); |
64 while (buf[1] == 0) buf[1] = fgetc(rng); | 64 while (buf[1] == 0) buf[1] = fgetc(rng); |
65 mp_read_raw(a, buf, 1+size); | 65 mp_read_raw(a, buf, 1+size); |
66 } | 66 } |