comparison tim_exptmod.c @ 143:5d99163f7e32 libtomcrypt-orig

import of libtomcrypt 0.99
author Matt Johnston <matt@ucc.asn.au>
date Sun, 19 Dec 2004 11:34:45 +0000
parents 6362d3854bb4
children
comparison
equal deleted inserted replaced
15:6362d3854bb4 143:5d99163f7e32
32 if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) { 32 if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) {
33 return err; 33 return err;
34 } 34 }
35 35
36 /* pick random r */ 36 /* pick random r */
37 rtmp = XMALLOC(MAX_RSA_SIZE/8); 37 rlen = mp_unsigned_bin_size(n);
38 rtmp = XMALLOC(rlen);
38 if (rtmp == NULL) { 39 if (rtmp == NULL) {
39 return CRYPT_MEM; 40 return CRYPT_MEM;
40 } 41 }
41 42
42 43 /* read in random value "r" */
43 rlen = mp_unsigned_bin_size(n);
44 if (prng_descriptor[prng_idx].read(rtmp, rlen, prng) != rlen) { 44 if (prng_descriptor[prng_idx].read(rtmp, rlen, prng) != rlen) {
45 XFREE(rtmp); 45 XFREE(rtmp);
46 return CRYPT_ERROR_READPRNG; 46 return CRYPT_ERROR_READPRNG;
47 } 47 }
48 48