From 9e4c5edc6ef46b4c182379eab46abb45e5d2022f Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sat, 22 Aug 2015 17:47:22 -0400 Subject: Add hal_ecdsa_verify(). Move hashing out of ECDSA routines. Clean up a few bits that didn't pass self-review. --- asn1.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'asn1.c') diff --git a/asn1.c b/asn1.c index f4b3610..cfbd319 100644 --- a/asn1.c +++ b/asn1.c @@ -144,6 +144,11 @@ hal_error_t hal_asn1_encode_integer(fp_int *bn, return HAL_OK; } +/* + * Parse tag and length of an ASN.1 object. Tag must match value + * specified by the caller. On success, sets hlen and vlen to lengths + * of header and value, respectively. + */ hal_error_t hal_asn1_decode_header(const uint8_t tag, const uint8_t * const der, size_t der_max, @@ -176,6 +181,12 @@ hal_error_t hal_asn1_decode_header(const uint8_t tag, return HAL_OK; } +/* + * Decode an ASN.1 INTEGER into a libtfm bignum. Since we only + * support (or need to support, or expect to see) unsigned integers, + * we return failure if the sign bit is set in the ASN.1 INTEGER. + */ + hal_error_t hal_asn1_decode_integer(fp_int *bn, const uint8_t * const der, size_t *der_len, const size_t der_max) { -- cgit v1.2.3