X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=gcrypt.c;h=abc3272a6490ca541f1385c992c6ee99d5ef7986;hb=71386e2530fa351d22f942ce3cf9d18eee99ce78;hp=9b05a9494c23503702f88b27716468942b15d805;hpb=686310d4b954efec5d5dcc8b4a143c294bb02739;p=paraslash.git diff --git a/gcrypt.c b/gcrypt.c index 9b05a949..abc3272a 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -205,11 +205,11 @@ static inline int get_long_form_num_length_bytes(unsigned char c) /* * 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; @@ -247,8 +247,8 @@ static int read_bignum(unsigned char *start, unsigned char *end, gcry_mpi_t *bn, 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); @@ -293,7 +293,8 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result) 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; @@ -310,7 +311,7 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result) 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; @@ -357,7 +358,7 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result) 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);