/*
* Returns: Number of bytes scanned. This may differ from the value returned via
- * bn_bytes because the latter does not include the ASN.1 prefix and a leading
- * zero is not considered as an additional byte for bn_bytes.
+ * bitsp because the latter does not include the ASN.1 prefix and a leading
+ * zero is not considered as an additional byte for the number of bits.
*/
static int read_bignum(unsigned char *start, unsigned char *end, gcry_mpi_t *bn,
- int *bn_bytes)
+ unsigned *bitsp)
{
int i, bn_size;
gcry_error_t gret;
cp++;
bn_size--;
}
- if (bn_bytes)
- *bn_bytes = bn_size;
+ if (bitsp)
+ *bitsp = bn_size * 8;
cp += bn_size;
// unsigned char *buf;
// gcry_mpi_aprint(GCRYMPI_FMT_HEX, &buf, NULL, *bn);
gcry_mpi_t n = NULL, e = NULL, d = NULL, p = NULL, q = NULL,
u = NULL;
unsigned char *blob, *cp, *end;
- int ret, n_size;
+ int ret;
+ unsigned bits;
gcry_error_t gret;
size_t erroff, blob_size;
gcry_sexp_t sexp;
PARA_INFO_LOG("reading RSA params at offset %d\n", ret);
cp = blob + ret;
- ret = read_bignum(cp, end, &n, &n_size);
+ ret = read_bignum(cp, end, &n, &bits);
if (ret < 0)
goto free_blob;
cp += ret;
key = para_malloc(sizeof(*key));
key->sexp = sexp;
*result = key;
- ret = n_size * 8;
+ ret = bits;
PARA_INFO_LOG("succesfully read %d bit private key\n", ret);
release_u:
gcry_mpi_release(u);