Remove ASN1_OP_I2D_* callbacks.

These are a little odd with the ASN1_ENCODING paths. And there were some
bugs previously around CHOICE types. Nothing defines them, inside or
outside BoringSSL, so remove them.

Change-Id: Id2954fef8ee9637f36f7511b51dc0adc2557e3ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/49352
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/asn1/tasn_enc.c b/crypto/asn1/tasn_enc.c
index 7abd34b..4ccacab 100644
--- a/crypto/asn1/tasn_enc.c
+++ b/crypto/asn1/tasn_enc.c
@@ -174,10 +174,6 @@
             OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
             return -1;
         }
-        const ASN1_AUX *aux = it->funcs;
-        ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
-        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
-            return -1;
         i = asn1_get_choice_selector(pval, it);
         if (i < 0 || i >= it->tcount) {
             OPENSSL_PUT_ERROR(ASN1, ASN1_R_NO_MATCHING_CHOICE_TYPE);
@@ -189,12 +185,7 @@
             return -1;
         }
         ASN1_VALUE **pchval = asn1_get_field_ptr(pval, chtt);
-        int ret = asn1_template_ex_i2d(pchval, out, chtt, -1, aclass);
-        if (ret < 0 ||
-            (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))) {
-            return -1;
-        }
-        return ret;
+        return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass);
     }
 
     case ASN1_ITYPE_EXTERN: {
@@ -228,10 +219,6 @@
             aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
                 | V_ASN1_UNIVERSAL;
         }
-        const ASN1_AUX *aux = it->funcs;
-        ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
-        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
-            return -1;
         /* First work out sequence content length */
         for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
             const ASN1_TEMPLATE *seqtt;
@@ -263,8 +250,6 @@
                 return -1;
             }
         }
-        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
-            return -1;
         return seqlen;
     }
 
diff --git a/include/openssl/asn1t.h b/include/openssl/asn1t.h
index 20c1e95..45302ef 100644
--- a/include/openssl/asn1t.h
+++ b/include/openssl/asn1t.h
@@ -595,8 +595,8 @@
 #define ASN1_OP_FREE_POST	3
 #define ASN1_OP_D2I_PRE		4
 #define ASN1_OP_D2I_POST	5
-#define ASN1_OP_I2D_PRE		6
-#define ASN1_OP_I2D_POST	7
+/* ASN1_OP_I2D_PRE and ASN1_OP_I2D_POST are not supported. We leave the
+ * constants undefined so code relying on them does not accidentally compile. */
 #define ASN1_OP_PRINT_PRE	8
 #define ASN1_OP_PRINT_POST	9
 #define ASN1_OP_STREAM_PRE	10