aboutsummaryrefslogtreecommitdiff
path: root/asn1_internal.h
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-09-02 18:35:36 -0400
committerRob Austein <sra@hactrn.net>2015-09-02 18:35:36 -0400
commit12ed3abeb24bbd5d59b760640a35ead0874fd3fe (patch)
tree1dcc0db3d543e7b740238ea911b7f448c704e70b /asn1_internal.h
parent55116cc564649433cf4a8515d4a37cbf00dd6199 (diff)
Clean up excessively complicated handling of opaque types in hash and
RSA code; use simpler model (pointer to incomplete structure) used in ECDSA code. Refactor RSA code to use shared ASN.1 routines.
Diffstat (limited to 'asn1_internal.h')
-rw-r--r--asn1_internal.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/asn1_internal.h b/asn1_internal.h
index 9d5ab4d..f6e470f 100644
--- a/asn1_internal.h
+++ b/asn1_internal.h
@@ -68,6 +68,23 @@
#define ASN1_EXPLICIT_0 (ASN1_EXPLICIT_CONTEXT + 0)
#define ASN1_EXPLICIT_1 (ASN1_EXPLICIT_CONTEXT + 1)
+/*
+ * Functions to strip const qualifiers from arguments to libtfm calls
+ * in a relatively type-safe manner. These don't really have anything
+ * to do with ASN.1 per se, but all the code that needs them reads
+ * this header file, so this is the simplest place to put them.
+ */
+
+static inline fp_int *unconst_fp_int(const fp_int * const arg)
+{
+ return (fp_int *) arg;
+}
+
+static inline uint8_t *unconst_uint8_t(const uint8_t * const arg)
+{
+ return (uint8_t *) arg;
+}
+
extern hal_error_t hal_asn1_encode_header(const uint8_t tag,
const size_t value_len,
uint8_t *der, size_t *der_len, const size_t der_max);
@@ -76,7 +93,7 @@ extern 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);
-extern hal_error_t hal_asn1_encode_integer(fp_int *bn,
+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_decode_integer(fp_int *bn,