diff options
Diffstat (limited to 'asn1_internal.h')
-rw-r--r-- | asn1_internal.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/asn1_internal.h b/asn1_internal.h index fe2f293..23d8a77 100644 --- a/asn1_internal.h +++ b/asn1_internal.h @@ -102,6 +102,9 @@ extern const size_t hal_asn1_oid_ecPublicKey_len; extern const uint8_t hal_asn1_oid_aesKeyWrap[]; extern const size_t hal_asn1_oid_aesKeyWrap_len; +extern const uint8_t hal_asn1_oid_mts_hashsig[]; +extern const size_t hal_asn1_oid_mts_hashsig_len; + /* * Transcoding functions. */ @@ -117,9 +120,21 @@ extern hal_error_t hal_asn1_decode_header(const uint8_t tag, extern hal_error_t hal_asn1_encode_integer(const fp_int * const bn, uint8_t *der, size_t *der_len, const size_t der_max); +extern hal_error_t hal_asn1_encode_uint32(const uint32_t n, + uint8_t *der, size_t *der_len, const size_t der_max); + +extern hal_error_t hal_asn1_encode_octet_string(const uint8_t * const data, const size_t data_len, + uint8_t *der, size_t *der_len, const size_t der_max); + extern hal_error_t hal_asn1_decode_integer(fp_int *bn, const uint8_t * const der, size_t *der_len, const size_t der_max); +extern hal_error_t hal_asn1_decode_uint32(uint32_t *np, + const uint8_t * const der, size_t *der_len, const size_t der_max); + +extern hal_error_t hal_asn1_decode_octet_string(uint8_t *data, const size_t data_len, + const uint8_t * const der, size_t *der_len, const size_t der_max); + extern hal_error_t hal_asn1_encode_spki(const uint8_t * const alg_oid, const size_t alg_oid_len, const uint8_t * const curve_oid, const size_t curve_oid_len, const uint8_t * const pubkey, const size_t pubkey_len, @@ -151,6 +166,16 @@ extern hal_error_t hal_asn1_decode_pkcs8_encryptedprivatekeyinfo(const uint8_t * extern hal_error_t hal_asn1_guess_key_type(hal_key_type_t *type, hal_curve_name_t *curve, const uint8_t *const der, const size_t der_len); +/* + * Peek ahead for an OPTIONAL attribute. + */ + +static inline int hal_asn1_peek(const uint8_t tag, + const uint8_t * const der, size_t der_max) +{ + return der != NULL && der_max > 0 && der[0] == tag; +} + #endif /* _HAL_ASN1_INTERNAL_H_ */ /* |