diff options
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 042af0893..949c0e430 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -407,6 +407,7 @@ GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
407 | * | 407 | * |
408 | * @param buf the buffer where the private key data is stored | 408 | * @param buf the buffer where the private key data is stored |
409 | * @param len the length of the data in 'buffer' | 409 | * @param len the length of the data in 'buffer' |
410 | * @return NULL on error | ||
410 | */ | 411 | */ |
411 | struct GNUNET_CRYPTO_RsaPrivateKey * | 412 | struct GNUNET_CRYPTO_RsaPrivateKey * |
412 | GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | 413 | GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) |
@@ -423,8 +424,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
423 | gcry_mpi_t u; | 424 | gcry_mpi_t u; |
424 | int rc; | 425 | int rc; |
425 | size_t size; | 426 | size_t size; |
426 | int pos; | 427 | size_t pos; |
427 | uint16_t enc_len; | 428 | uint16_t enc_len; |
429 | size_t erroff; | ||
428 | 430 | ||
429 | enc_len = ntohs (encoding->len); | 431 | enc_len = ntohs (encoding->len); |
430 | if (len != enc_len) | 432 | if (len != enc_len) |
@@ -530,7 +532,7 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
530 | 532 | ||
531 | if ((NULL != p) && (NULL != q) && (NULL != u)) | 533 | if ((NULL != p) && (NULL != q) && (NULL != u)) |
532 | { | 534 | { |
533 | rc = gcry_sexp_build (&res, &size, /* erroff */ | 535 | rc = gcry_sexp_build (&res, &erroff, |
534 | "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)(u %m)))", | 536 | "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)(u %m)))", |
535 | n, e, d, p, q, u); | 537 | n, e, d, p, q, u); |
536 | } | 538 | } |
@@ -538,13 +540,13 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
538 | { | 540 | { |
539 | if ((NULL != p) && (NULL != q)) | 541 | if ((NULL != p) && (NULL != q)) |
540 | { | 542 | { |
541 | rc = gcry_sexp_build (&res, &size, /* erroff */ | 543 | rc = gcry_sexp_build (&res, &erroff, |
542 | "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)))", | 544 | "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)))", |
543 | n, e, d, p, q); | 545 | n, e, d, p, q); |
544 | } | 546 | } |
545 | else | 547 | else |
546 | { | 548 | { |
547 | rc = gcry_sexp_build (&res, &size, /* erroff */ | 549 | rc = gcry_sexp_build (&res, &erroff, |
548 | "(private-key(rsa(n %m)(e %m)(d %m)))", n, e, d); | 550 | "(private-key(rsa(n %m)(e %m)(d %m)))", n, e, d); |
549 | } | 551 | } |
550 | } | 552 | } |
@@ -561,7 +563,7 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) | |||
561 | if (0 != rc) | 563 | if (0 != rc) |
562 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 564 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
563 | #if EXTRA_CHECKS | 565 | #if EXTRA_CHECKS |
564 | if (gcry_pk_testkey (res)) | 566 | if (0 != (rc = gcry_pk_testkey (res))) |
565 | { | 567 | { |
566 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 568 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
567 | return NULL; | 569 | return NULL; |
@@ -1111,7 +1113,7 @@ GNUNET_CRYPTO_rsa_key_create_stop (struct GNUNET_CRYPTO_RsaKeyGenerationContext | |||
1111 | * @param cfg_name name of the configuration file to use | 1113 | * @param cfg_name name of the configuration file to use |
1112 | */ | 1114 | */ |
1113 | void | 1115 | void |
1114 | GNUNET_CRYPTO_setup_hostkey (const char *cfg_name) | 1116 | GNUNET_CRYPTO_rsa_setup_hostkey (const char *cfg_name) |
1115 | { | 1117 | { |
1116 | struct GNUNET_CONFIGURATION_Handle *cfg; | 1118 | struct GNUNET_CONFIGURATION_Handle *cfg; |
1117 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | 1119 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; |