correctly for interger smaller than <32 bit.
memcpy(tmp, key_data, 4);
SILC_GET32_MSB(e_len, tmp);
- if (e_len > key_len) {
+ if (!e_len || e_len > key_len) {
silc_mp_uninit(&key->e);
silc_mp_uninit(&key->n);
return 0;
memcpy(tmp, key_data + 4 + e_len, 4);
SILC_GET32_MSB(n_len, tmp);
- if (e_len + n_len > key_len) {
+ if (!n_len || e_len + n_len > key_len) {
silc_mp_uninit(&key->e);
silc_mp_uninit(&key->n);
return 0;
size_t silc_mp_sizeinbase(SilcMPInt *mp, int base)
{
- size_t sib = mp_radix_size(mp, base);
+ size_t sib = mp_unsigned_octet_size(mp);
+ sib = s_mp_outlen(sib * CHAR_BIT, base);
if (sib > 2)
- sib -= 2; /* XXX This is actually wrong since
- this might produce wrong balue.
- But, it looks like MPI always returns
- correct value plus one, whereas
- GMP returns always the right value. */
+ sib -= 2; /* Looks like MPI returns extra zero
+ bytes for C-strings. */
return sib;
}
SILC_LOG_DEBUG(("Creating random number"));
/* Get the random number as string */
- string = silc_rng_get_rn_data(ske->rng, (len / 8));
+ string = silc_rng_get_rn_data(ske->rng, ((len - 1) / 8));
if (!string)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
/* Decode the string into a MP integer */
- silc_mp_bin2mp(string, (len / 8), rnd);
+ silc_mp_bin2mp(string, ((len - 1) / 8), rnd);
silc_mp_mod_2exp(rnd, rnd, len);
/* Checks */
if (silc_mp_cmp_ui(rnd, 1) < 0)
status = SILC_SKE_STATUS_ERROR;
-
if (silc_mp_cmp(rnd, n) >= 0)
status = SILC_SKE_STATUS_ERROR;
* SYNOPSIS
*
* typedef int (*SilcConfigCallback)(SilcConfigType type, const char *name,
- * SilcUInt32 line, void *val, void *context);
+ * SilcUInt32 line, void *val,
+ * void *context);
* DESCRIPTION
*
* This is the callback prototype for the options handler. The pointer
*
* SYNOPSIS
*
- * typedef struct { ... } SilcConfigFile;
+ * typedef struct SilcConfigFileObject SilcConfigFile;
*
* DESCRIPTION
*
*
* SYNOPSIS
*
- * typedef struct { ... } SilcConfigEntity;
+ * typedef struct SilcConfigEntityObject *SilcConfigEntity;
*
* DESCRIPTION
*