Mercurial > dropbear
comparison random.c @ 351:e66eec4dcba7 debug-unrandom
some more debugging output
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 08 Aug 2006 15:31:38 +0000 |
parents | 381834084475 |
children | c61bd8f9e32d |
comparison
equal
deleted
inserted
replaced
348:cd14c94fe89c | 351:e66eec4dcba7 |
---|---|
69 void genrandom(unsigned char* buf, unsigned int len) { | 69 void genrandom(unsigned char* buf, unsigned int len) { |
70 | 70 |
71 hash_state hs; | 71 hash_state hs; |
72 unsigned char hash[SHA1_HASH_SIZE]; | 72 unsigned char hash[SHA1_HASH_SIZE]; |
73 unsigned int copylen; | 73 unsigned int copylen; |
74 const unsigned int total_len = len; | |
75 unsigned char* start_buf = buf; | |
74 | 76 |
75 if (!donerandinit) { | 77 if (!donerandinit) { |
76 dropbear_exit("seedrandom not done"); | 78 dropbear_exit("seedrandom not done"); |
77 } | 79 } |
78 | 80 |
91 memcpy(buf, hash, copylen); | 93 memcpy(buf, hash, copylen); |
92 len -= copylen; | 94 len -= copylen; |
93 buf += copylen; | 95 buf += copylen; |
94 } | 96 } |
95 m_burn(hash, sizeof(hash)); | 97 m_burn(hash, sizeof(hash)); |
98 printhex("genrandom", start_buf, total_len); | |
96 } | 99 } |
97 | 100 |
98 /* Generates a random mp_int. | 101 /* Generates a random mp_int. |
99 * max is a *mp_int specifying an upper bound. | 102 * max is a *mp_int specifying an upper bound. |
100 * rand must be an initialised *mp_int for the result. | 103 * rand must be an initialised *mp_int for the result. |