1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
13 Convert data from a specific radix to binary.
18 Convert data from a specific radix to binary
20 The default MPI descriptors #ltm_desc, #tfm_desc and #gmp_desc
21 have the following restrictions on parameters:
23 \p in - NUL-terminated char buffer
28 @param radix The radix of the input
29 @param out The output buffer
30 @param len [in/out] The length of the output buffer
32 @return CRYPT_OK on success.
34 int radix_to_bin(const void *in, int radix, void *out, unsigned long *len)
40 LTC_ARGCHK(in != NULL);
41 LTC_ARGCHK(len != NULL);
43 if ((err = mp_init(&mpi)) != CRYPT_OK) return err;
44 if ((err = mp_read_radix(mpi, in, radix)) != CRYPT_OK) goto LBL_ERR;
46 if ((l = mp_unsigned_bin_size(mpi)) > *len) {
48 err = CRYPT_BUFFER_OVERFLOW;
53 if ((err = mp_to_unsigned_bin(mpi, out)) != CRYPT_OK) goto LBL_ERR;
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */