aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-12-21 16:22:20 -0500
committerRob Austein <sra@hactrn.net>2015-12-21 16:22:20 -0500
commit36f9b6627d41f72af38be1d819f37c20a11f43c5 (patch)
tree15287c76d9da007c0488ab3a68ea831a4f11739b
parent905db64f075752de96c80eb4e3bd431342bb9700 (diff)
Fix names of private key DER functions.
-rw-r--r--GNUmakefile2
-rw-r--r--ecdsa.c12
-rw-r--r--hal.h20
-rw-r--r--rpc_pkey.c12
-rw-r--r--rsa.c12
-rw-r--r--tests/test-ecdsa.c8
-rw-r--r--tests/test-rsa.c6
7 files changed, 36 insertions, 36 deletions
diff --git a/GNUmakefile b/GNUmakefile
index e0b4730..dc7fe50 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -94,5 +94,5 @@ distclean: clean
tags: TAGS
-TAGS: *.[ch] tests/*.[ch]
+TAGS: *.[ch] tests/*.[ch] utils/*.[ch]
etags $^
diff --git a/ecdsa.c b/ecdsa.c
index c568a74..b547712 100644
--- a/ecdsa.c
+++ b/ecdsa.c
@@ -1103,8 +1103,8 @@ hal_error_t hal_ecdsa_key_from_ecpoint(hal_ecdsa_key_t **key_,
* probably be using an ASN.1 compiler like asn1c instead.
*/
-hal_error_t hal_ecdsa_key_to_der(const hal_ecdsa_key_t * const key,
- uint8_t *der, size_t *der_len, const size_t der_max)
+hal_error_t hal_ecdsa_private_key_to_der(const hal_ecdsa_key_t * const key,
+ uint8_t *der, size_t *der_len, const size_t der_max)
{
if (key == NULL || key->type != HAL_KEY_TYPE_EC_PRIVATE)
return HAL_ERROR_BAD_ARGUMENTS;
@@ -1195,7 +1195,7 @@ hal_error_t hal_ecdsa_key_to_der(const hal_ecdsa_key_t * const key,
size_t hal_ecdsa_key_to_der_len(const hal_ecdsa_key_t * const key)
{
size_t len;
- return hal_ecdsa_key_to_der(key, NULL, &len, 0) == HAL_OK ? len : 0;
+ return hal_ecdsa_private_key_to_der(key, NULL, &len, 0) == HAL_OK ? len : 0;
}
/*
@@ -1205,9 +1205,9 @@ size_t hal_ecdsa_key_to_der_len(const hal_ecdsa_key_t * const key)
* probably be using an ASN.1 compiler like asn1c instead.
*/
-hal_error_t hal_ecdsa_key_from_der(hal_ecdsa_key_t **key_,
- void *keybuf, const size_t keybuf_len,
- const uint8_t * const der, const size_t der_len)
+hal_error_t hal_ecdsa_private_key_from_der(hal_ecdsa_key_t **key_,
+ void *keybuf, const size_t keybuf_len,
+ const uint8_t * const der, const size_t der_len)
{
hal_ecdsa_key_t *key = keybuf;
diff --git a/hal.h b/hal.h
index 3fcf813..36c56b7 100644
--- a/hal.h
+++ b/hal.h
@@ -422,14 +422,14 @@ extern hal_error_t hal_rsa_key_gen(const hal_core_t *core,
const unsigned key_length,
const uint8_t * const public_exponent, const size_t public_exponent_len);
-extern hal_error_t hal_rsa_key_to_der(const hal_rsa_key_t * const key,
- uint8_t *der, size_t *der_len, const size_t der_max);
+extern hal_error_t hal_rsa_private_key_to_der(const hal_rsa_key_t * const key,
+ uint8_t *der, size_t *der_len, const size_t der_max);
extern size_t hal_rsa_key_to_der_len(const hal_rsa_key_t * const key);
-extern hal_error_t hal_rsa_key_from_der(hal_rsa_key_t **key,
- void *keybuf, const size_t keybuf_len,
- const uint8_t * const der, const size_t der_len);
+extern hal_error_t hal_rsa_private_key_from_der(hal_rsa_key_t **key,
+ void *keybuf, const size_t keybuf_len,
+ const uint8_t * const der, const size_t der_len);
/*
* ECDSA.
@@ -471,14 +471,14 @@ extern hal_error_t hal_ecdsa_key_gen(const hal_core_t *core,
void *keybuf, const size_t keybuf_len,
const hal_curve_name_t curve);
-extern hal_error_t hal_ecdsa_key_to_der(const hal_ecdsa_key_t * const key,
- uint8_t *der, size_t *der_len, const size_t der_max);
+extern hal_error_t hal_ecdsa_private_key_to_der(const hal_ecdsa_key_t * const key,
+ uint8_t *der, size_t *der_len, const size_t der_max);
extern size_t hal_ecdsa_key_to_der_len(const hal_ecdsa_key_t * const key);
-extern hal_error_t hal_ecdsa_key_from_der(hal_ecdsa_key_t **key,
- void *keybuf, const size_t keybuf_len,
- const uint8_t * const der, const size_t der_len);
+extern hal_error_t hal_ecdsa_private_key_from_der(hal_ecdsa_key_t **key,
+ void *keybuf, const size_t keybuf_len,
+ const uint8_t * const der, const size_t der_len);
extern hal_error_t hal_ecdsa_key_to_ecpoint(const hal_ecdsa_key_t * const key,
uint8_t *der, size_t *der_len, const size_t der_max);
diff --git a/rpc_pkey.c b/rpc_pkey.c
index d286497..d9ee53c 100644
--- a/rpc_pkey.c
+++ b/rpc_pkey.c
@@ -296,7 +296,7 @@ static hal_error_t generate_rsa(const hal_rpc_client_handle_t client,
uint8_t der[hal_rsa_key_to_der_len(key)];
size_t der_len;
- if ((err = hal_rsa_key_to_der(key, der, &der_len, sizeof(der))) == HAL_OK)
+ if ((err = hal_rsa_private_key_to_der(key, der, &der_len, sizeof(der))) == HAL_OK)
err = hal_ks_store(HAL_KEY_TYPE_RSA_PRIVATE, HAL_CURVE_NONE, flags,
name, name_len, der, der_len, &slot->ks_hint);
@@ -347,7 +347,7 @@ static hal_error_t generate_ec(const hal_rpc_client_handle_t client,
uint8_t der[hal_ecdsa_key_to_der_len(key)];
size_t der_len;
- if ((err = hal_ecdsa_key_to_der(key, der, &der_len, sizeof(der))) == HAL_OK)
+ if ((err = hal_ecdsa_private_key_to_der(key, der, &der_len, sizeof(der))) == HAL_OK)
err = hal_ks_store(HAL_KEY_TYPE_EC_PRIVATE, curve, flags,
name, name_len, der, der_len, &slot->ks_hint);
@@ -486,7 +486,7 @@ static hal_error_t sign_rsa(uint8_t *keybuf, const size_t keybuf_len,
assert(signature != NULL && signature_len != NULL);
assert((hash.handle == hal_rpc_hash_handle_none.handle) != (input == NULL || input_len == 0));
- if ((err = hal_rsa_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK ||
+ if ((err = hal_rsa_private_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK ||
(err = hal_rsa_key_get_modulus(key, NULL, signature_len, 0)) != HAL_OK)
return err;
@@ -518,7 +518,7 @@ static hal_error_t sign_ecdsa(uint8_t *keybuf, const size_t keybuf_len,
assert(signature != NULL && signature_len != NULL);
assert((hash.handle == hal_rpc_hash_handle_none.handle) != (input == NULL || input_len == 0));
- if ((err = hal_ecdsa_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK)
+ if ((err = hal_ecdsa_private_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK)
return err;
if (input == NULL) {
@@ -607,7 +607,7 @@ static hal_error_t verify_rsa(uint8_t *keybuf, const size_t keybuf_len,
assert(signature != NULL && signature_len > 0);
assert((hash.handle == hal_rpc_hash_handle_none.handle) != (input == NULL || input_len == 0));
- if ((err = hal_rsa_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK)
+ if ((err = hal_rsa_private_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK)
return err;
if (input == NULL) {
@@ -643,7 +643,7 @@ static hal_error_t verify_ecdsa(uint8_t *keybuf, const size_t keybuf_len,
assert(signature != NULL && signature_len > 0);
assert((hash.handle == hal_rpc_hash_handle_none.handle) != (input == NULL || input_len == 0));
- if ((err = hal_ecdsa_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK)
+ if ((err = hal_ecdsa_private_key_from_der(&key, keybuf, keybuf_len, der, der_len)) != HAL_OK)
return err;
if (input == NULL) {
diff --git a/rsa.c b/rsa.c
index a901b24..e6d70db 100644
--- a/rsa.c
+++ b/rsa.c
@@ -687,8 +687,8 @@ hal_error_t hal_rsa_key_gen(const hal_core_t *core,
_(key->dQ); \
_(key->u);
-hal_error_t hal_rsa_key_to_der(const hal_rsa_key_t * const key,
- uint8_t *der, size_t *der_len, const size_t der_max)
+hal_error_t hal_rsa_private_key_to_der(const hal_rsa_key_t * const key,
+ uint8_t *der, size_t *der_len, const size_t der_max)
{
hal_error_t err = HAL_OK;
@@ -736,12 +736,12 @@ hal_error_t hal_rsa_key_to_der(const hal_rsa_key_t * const key,
size_t hal_rsa_key_to_der_len(const hal_rsa_key_t * const key)
{
size_t len = 0;
- return hal_rsa_key_to_der(key, NULL, &len, 0) == HAL_OK ? len : 0;
+ return hal_rsa_private_key_to_der(key, NULL, &len, 0) == HAL_OK ? len : 0;
}
-hal_error_t hal_rsa_key_from_der(hal_rsa_key_t **key_,
- void *keybuf, const size_t keybuf_len,
- const uint8_t *der, const size_t der_len)
+hal_error_t hal_rsa_private_key_from_der(hal_rsa_key_t **key_,
+ void *keybuf, const size_t keybuf_len,
+ const uint8_t *der, const size_t der_len)
{
if (key_ == NULL || keybuf == NULL || keybuf_len < sizeof(hal_rsa_key_t) || der == NULL)
return HAL_ERROR_BAD_ARGUMENTS;
diff --git a/tests/test-ecdsa.c b/tests/test-ecdsa.c
index 98b3d70..d88aeb2 100644
--- a/tests/test-ecdsa.c
+++ b/tests/test-ecdsa.c
@@ -133,14 +133,14 @@ static int test_against_static_vectors(const ecdsa_tc_t * const tc)
uint8_t keyder[tc->key_len];
size_t keyder_len;
- if ((err = hal_ecdsa_key_to_der(key1, keyder, &keyder_len, sizeof(keyder))) != HAL_OK)
- return printf("hal_ecdsa_key_to_der() failed: %s\n", hal_error_string(err)), 0;
+ if ((err = hal_ecdsa_private_key_to_der(key1, keyder, &keyder_len, sizeof(keyder))) != HAL_OK)
+ return printf("hal_ecdsa_private_key_to_der() failed: %s\n", hal_error_string(err)), 0;
uint8_t keybuf2[hal_ecdsa_key_t_size];
hal_ecdsa_key_t *key2 = NULL;
- if ((err = hal_ecdsa_key_from_der(&key2, keybuf2, sizeof(keybuf2), keyder, keyder_len)) != HAL_OK)
- return printf("hal_ecdsa_key_from_der() failed: %s\n", hal_error_string(err)), 0;
+ if ((err = hal_ecdsa_private_key_from_der(&key2, keybuf2, sizeof(keybuf2), keyder, keyder_len)) != HAL_OK)
+ return printf("hal_ecdsa_private_key_from_der() failed: %s\n", hal_error_string(err)), 0;
if (memcmp(key1, key2, hal_ecdsa_key_t_size) != 0)
return printf("Private key mismatch after read/write cycle\n"), 0;
diff --git a/tests/test-rsa.c b/tests/test-rsa.c
index e7e831e..2872250 100644
--- a/tests/test-rsa.c
+++ b/tests/test-rsa.c
@@ -148,19 +148,19 @@ static int test_gen(const hal_core_t *core,
size_t der_len = 0;
- if ((err = hal_rsa_key_to_der(key1, NULL, &der_len, 0)) != HAL_OK) {
+ if ((err = hal_rsa_private_key_to_der(key1, NULL, &der_len, 0)) != HAL_OK) {
printf("Getting DER length of RSA key failed: %s\n", hal_error_string(err));
return 0;
}
uint8_t der[der_len];
- if ((err = hal_rsa_key_to_der(key1, der, &der_len, sizeof(der))) != HAL_OK) {
+ if ((err = hal_rsa_private_key_to_der(key1, der, &der_len, sizeof(der))) != HAL_OK) {
printf("Converting RSA key to DER failed: %s\n", hal_error_string(err));
return 0;
}
- if ((err = hal_rsa_key_from_der(&key2, keybuf2, sizeof(keybuf2), der, sizeof(der))) != HAL_OK) {
+ if ((err = hal_rsa_private_key_from_der(&key2, keybuf2, sizeof(keybuf2), der, sizeof(der))) != HAL_OK) {
printf("Converting RSA key back from DER failed: %s\n", hal_error_string(err));
return 0;
}