[Cryptech-Commits] [user/sra/libhal] 13/17: Helps to set the return value when reading a key, doh.

git at cryptech.is git at cryptech.is
Fri Jun 19 17:56:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository user/sra/libhal.

commit 30e821659ae85e76082932074cc7463e80bc59b9
Author: Rob Austein <sra at hactrn.net>
Date:   Thu Jun 18 16:50:20 2015 -0400

    Helps to set the return value when reading a key, doh.
---
 rsa.c            | 2 ++
 tests/test-rsa.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/rsa.c b/rsa.c
index 8ea5f74..9fe2c47 100644
--- a/rsa.c
+++ b/rsa.c
@@ -748,6 +748,8 @@ hal_error_t hal_rsa_key_from_der(hal_rsa_key_t *key_,
   if (fp_cmp_d(&version, 0) != FP_EQ)
     return HAL_ERROR_ASN1_PARSE_FAILED;
 
+  key_->key = key;
+
   return HAL_OK;
 }
 
diff --git a/tests/test-rsa.c b/tests/test-rsa.c
index ef60eb9..9b346b5 100644
--- a/tests/test-rsa.c
+++ b/tests/test-rsa.c
@@ -87,8 +87,8 @@ static int test_decrypt(const char * const kind, const rsa_tc_t * const tc)
   printf("%s test for %lu-bit RSA key\n", kind, (unsigned long) tc->size);
 
   uint8_t keybuf[hal_rsa_key_t_size];
+  hal_rsa_key_t key = { NULL };
   hal_error_t err = HAL_OK;
-  hal_rsa_key_t key;
 
   if ((err = hal_rsa_key_load(HAL_RSA_PRIVATE, &key,
                               keybuf, sizeof(keybuf),
@@ -129,8 +129,8 @@ static int test_gen(const char * const kind, const rsa_tc_t * const tc)
 
   char fn[sizeof("test-rsa-key-xxxxxx.der")];
   uint8_t keybuf1[hal_rsa_key_t_size], keybuf2[hal_rsa_key_t_size];
+  hal_rsa_key_t key1 = { NULL }, key2 = { NULL };
   hal_error_t err = HAL_OK;
-  hal_rsa_key_t key1, key2;
   FILE *f;
 
   if ((err = hal_rsa_key_gen(&key1, keybuf1, sizeof(keybuf1), bitsToBytes(tc->size), 0x010001)) != HAL_OK) {



More information about the Commits mailing list