Unwind ASN1_PRIMITIVE_FUNCS.
This was used to register custom primitive types, namely some INTEGER
variations. We have since removed them all.
Change-Id: Id3f5b15058bc3be1cef5e0f989d2e7e6db392712
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/43891
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c
index 1512bfc..ecedd3b 100644
--- a/crypto/asn1/tasn_dec.c
+++ b/crypto/asn1/tasn_dec.c
@@ -797,12 +797,12 @@
ASN1_STRING *stmp;
ASN1_TYPE *typ = NULL;
int ret = 0;
- const ASN1_PRIMITIVE_FUNCS *pf;
ASN1_INTEGER **tint;
- pf = it->funcs;
- if (pf && pf->prim_c2i)
- return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
+ /* Historically, |it->funcs| for primitive types contained an
+ * |ASN1_PRIMITIVE_FUNCS| table of callbacks. */
+ assert(it->funcs == NULL);
+
/* If ANY type clear type and set pointer to internal value */
if (it->utype == V_ASN1_ANY) {
if (!*pval) {
diff --git a/crypto/asn1/tasn_enc.c b/crypto/asn1/tasn_enc.c
index c02f3c5..5ef1828 100644
--- a/crypto/asn1/tasn_enc.c
+++ b/crypto/asn1/tasn_enc.c
@@ -496,10 +496,10 @@
const unsigned char *cont;
unsigned char c;
int len;
- const ASN1_PRIMITIVE_FUNCS *pf;
- pf = it->funcs;
- if (pf && pf->prim_i2c)
- return pf->prim_i2c(pval, cout, putype, it);
+
+ /* Historically, |it->funcs| for primitive types contained an
+ * |ASN1_PRIMITIVE_FUNCS| table of callbacks. */
+ assert(it->funcs == NULL);
/* Should type be omitted? */
if ((it->itype != ASN1_ITYPE_PRIMITIVE)
diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c
index 78d6626..a1e7315 100644
--- a/crypto/asn1/tasn_fre.c
+++ b/crypto/asn1/tasn_fre.c
@@ -56,6 +56,8 @@
#include <openssl/asn1.h>
+#include <assert.h>
+
#include <openssl/asn1t.h>
#include <openssl/mem.h>
@@ -182,14 +184,9 @@
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
{
int utype;
- if (it) {
- const ASN1_PRIMITIVE_FUNCS *pf;
- pf = it->funcs;
- if (pf && pf->prim_free) {
- pf->prim_free(pval, it);
- return;
- }
- }
+ /* Historically, |it->funcs| for primitive types contained an
+ * |ASN1_PRIMITIVE_FUNCS| table of calbacks. */
+ assert(it == NULL || it->funcs == NULL);
/* Special case: if 'it' is NULL free contents of ASN1_TYPE */
if (!it) {
ASN1_TYPE *typ = (ASN1_TYPE *)*pval;
diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c
index 139a044..3e8beb7 100644
--- a/crypto/asn1/tasn_new.c
+++ b/crypto/asn1/tasn_new.c
@@ -308,11 +308,9 @@
if (!it)
return 0;
- if (it->funcs) {
- const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
- if (pf->prim_new)
- return pf->prim_new(pval, it);
- }
+ /* Historically, |it->funcs| for primitive types contained an
+ * |ASN1_PRIMITIVE_FUNCS| table of calbacks. */
+ assert(it->funcs == NULL);
if (it->itype == ASN1_ITYPE_MSTRING)
utype = -1;
@@ -355,14 +353,9 @@
static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
{
int utype;
- if (it && it->funcs) {
- const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
- if (pf->prim_clear)
- pf->prim_clear(pval, it);
- else
- *pval = NULL;
- return;
- }
+ /* Historically, |it->funcs| for primitive types contained an
+ * |ASN1_PRIMITIVE_FUNCS| table of calbacks. */
+ assert(it == NULL || it->funcs == NULL);
if (!it || (it->itype == ASN1_ITYPE_MSTRING))
utype = -1;
else
diff --git a/include/openssl/asn1t.h b/include/openssl/asn1t.h
index 0af1195..deea9ec 100644
--- a/include/openssl/asn1t.h
+++ b/include/openssl/asn1t.h
@@ -552,10 +552,6 @@
int indent, const char *fname,
const ASN1_PCTX *pctx);
-typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
-typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
-typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
-
typedef struct ASN1_EXTERN_FUNCS_st {
void *app_data;
ASN1_ex_new_func *asn1_ex_new;
@@ -567,17 +563,6 @@
ASN1_ex_print_func *asn1_ex_print;
} ASN1_EXTERN_FUNCS;
-typedef struct ASN1_PRIMITIVE_FUNCS_st {
- void *app_data;
- unsigned long flags;
- ASN1_ex_new_func *prim_new;
- ASN1_ex_free_func *prim_free;
- ASN1_ex_free_func *prim_clear;
- ASN1_primitive_c2i *prim_c2i;
- ASN1_primitive_i2c *prim_i2c;
- ASN1_primitive_print *prim_print;
-} ASN1_PRIMITIVE_FUNCS;
-
/* This is the ASN1_AUX structure: it handles various
* miscellaneous requirements. For example the use of
* reference counts and an informational callback.