diff options
author | Rob Austein <sra@hactrn.net> | 2018-05-20 18:18:40 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2018-05-20 18:18:40 -0400 |
commit | e6bdf57820121b6eac9f35c8ef53a4e7a76205e1 (patch) | |
tree | b8701157fa06ea8f873b1c330d9599e4eb7384cf /asn1.c | |
parent | 76edd86d940956eb42ced93ccd4ee5f1d95bd01f (diff) |
Better hal_core_alloc() semantics, assert() and printf() cleanup.
Various fixes extracted from the abandoned(-for-now?) reuse-cores
branch, principally:
* Change hal_core_alloc*() to support core reuse and to pick the
least-recently-used core of a particular type otherwise;
* Replace assert() and printf() calls with hal_assert() and hal_log(),
respectively. assert() is particularly useless on the HSM, since it
sends its error message into hyperspace then hangs the HSM.
Diffstat (limited to 'asn1.c')
-rw-r--r-- | asn1.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -164,7 +164,7 @@ hal_error_t hal_asn1_encode_integer(const fp_int * const bn, if (der == NULL || err != HAL_OK) return err; - assert(hlen + vlen <= der_max); + hal_assert(hlen + vlen <= der_max); der += hlen; if (leading_zero) @@ -250,8 +250,8 @@ hal_error_t hal_asn1_encode_spki(const uint8_t * const alg_oid, const size_t a *d++ = 0x00; d += pubkey_len; /* pubkey handled early, above. */ - assert(d == der + hlen_spki + vlen); - assert(d <= der + der_max); + hal_assert(d == der + hlen_spki + vlen); + hal_assert(d <= der + der_max); return HAL_OK; } @@ -342,8 +342,8 @@ hal_error_t hal_asn1_encode_pkcs8_privatekeyinfo(const uint8_t * const alg_oid, d += hlen; d += privkey_len; /* privkey handled early, above. */ - assert(d == der_end); - assert(d <= der + der_max); + hal_assert(d == der_end); + hal_assert(d <= der + der_max); return HAL_OK; } @@ -410,8 +410,8 @@ hal_error_t hal_asn1_encode_pkcs8_encryptedprivatekeyinfo(const uint8_t * const d += data_len; /* data handled early, above. */ - assert(d == der + hlen_pkcs8 + vlen); - assert(d <= der + der_max); + hal_assert(d == der + hlen_pkcs8 + vlen); + hal_assert(d <= der + der_max); return HAL_OK; } @@ -427,7 +427,7 @@ hal_error_t hal_asn1_decode_header(const uint8_t tag, const uint8_t * const der, size_t der_max, size_t *hlen, size_t *vlen) { - assert(der != NULL && hlen != NULL && vlen != NULL); + hal_assert(der != NULL && hlen != NULL && vlen != NULL); if (der_max < 2 || der[0] != tag) return HAL_ERROR_ASN1_PARSE_FAILED; |