projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Preliminary streaming ASN1 encode support.
[openssl.git]
/
crypto
/
asn1
/
asn1t.h
diff --git
a/crypto/asn1/asn1t.h
b/crypto/asn1/asn1t.h
index 7d01df06749e7061490133a441807ab742f187ac..83e8213ea54348af2e5f6ca2e8cbf52530d33b21 100644
(file)
--- a/
crypto/asn1/asn1t.h
+++ b/
crypto/asn1/asn1t.h
@@
-74,7
+74,7
@@
extern "C" {
#endif
#endif
-#ifndef
ASN1_ITEM_FUNCTIONS
+#ifndef
OPENSSL_EXPORT_VAR_AS_FUNCTION
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
@@
-166,6
+166,9
@@
extern "C" {
#stname \
ASN1_ITEM_end(tname)
#stname \
ASN1_ITEM_end(tname)
+#define ASN1_NDEF_SEQUENCE(tname) \
+ ASN1_SEQUENCE(tname)
+
#define ASN1_SEQUENCE_cb(tname, cb) \
const static ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
ASN1_SEQUENCE(tname)
#define ASN1_SEQUENCE_cb(tname, cb) \
const static ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
ASN1_SEQUENCE(tname)
@@
-182,6
+185,18
@@
extern "C" {
const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
ASN1_SEQUENCE(tname)
const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
ASN1_SEQUENCE(tname)
+#define ASN1_NDEF_SEQUENCE_END(tname) \
+ ;\
+ ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_NDEF_SEQUENCE,\
+ V_ASN1_SEQUENCE,\
+ tname##_seq_tt,\
+ sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
+ NULL,\
+ sizeof(tname),\
+ #tname \
+ ASN1_ITEM_end(tname)
+
#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
@@
-287,7
+302,7
@@
extern "C" {
/* Any defined by macros: the field used is in the table itself */
/* Any defined by macros: the field used is in the table itself */
-#ifndef
ASN1_ITEM_FUNCTIONS
+#ifndef
OPENSSL_EXPORT_VAR_AS_FUNCTION
#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#else
#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#else
@@
-353,12
+368,16
@@
extern "C" {
#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
+/* EXPLICIT OPTIONAL using indefinite length constructed form */
+#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
+ ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
+
/* Macros for the ASN1_ADB structure */
#define ASN1_ADB(name) \
const static ASN1_ADB_TABLE name##_adbtbl[]
/* Macros for the ASN1_ADB structure */
#define ASN1_ADB(name) \
const static ASN1_ADB_TABLE name##_adbtbl[]
-#ifndef
ASN1_ITEM_FUNCTIONS
+#ifndef
OPENSSL_EXPORT_VAR_AS_FUNCTION
#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
;\
#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
;\
@@
-518,6
+537,13
@@
struct ASN1_ADB_TABLE_st {
#define ASN1_TFLG_COMBINE (0x1<<10)
#define ASN1_TFLG_COMBINE (0x1<<10)
+/* This flag when present in a SEQUENCE OF, SET OF
+ * or EXPLICIT causes indefinite length constructed
+ * encoding to be used if required.
+ */
+
+#define ASN1_TFLG_NDEF (0x1<<11)
+
/* This is the actual ASN1 item itself */
struct ASN1_ITEM_st {
/* This is the actual ASN1 item itself */
struct ASN1_ITEM_st {
@@
-570,19
+596,25
@@
const char *sname; /* Structure name */
* has a special meaning, it is used as a mask
* of acceptable types using the B_ASN1 constants.
*
* has a special meaning, it is used as a mask
* of acceptable types using the B_ASN1 constants.
*
+ * NDEF_SEQUENCE is the same as SEQUENCE except
+ * that it will use indefinite length constructed
+ * encoding if requested.
+ *
*/
*/
-#define ASN1_ITYPE_PRIMITIVE 0x0
+#define ASN1_ITYPE_PRIMITIVE
0x0
-#define ASN1_ITYPE_SEQUENCE 0x1
+#define ASN1_ITYPE_SEQUENCE
0x1
-#define ASN1_ITYPE_CHOICE 0x2
+#define ASN1_ITYPE_CHOICE
0x2
-#define ASN1_ITYPE_COMPAT 0x3
+#define ASN1_ITYPE_COMPAT
0x3
-#define ASN1_ITYPE_EXTERN 0x4
+#define ASN1_ITYPE_EXTERN
0x4
-#define ASN1_ITYPE_MSTRING 0x5
+#define ASN1_ITYPE_MSTRING 0x5
+
+#define ASN1_ITYPE_NDEF_SEQUENCE 0x6
/* Cache for ASN1 tag and length, so we
* don't keep re-reading it for things
/* Cache for ASN1 tag and length, so we
* don't keep re-reading it for things
@@
-767,6
+799,12
@@
typedef struct ASN1_AUX_st {
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
}
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
}
+#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
+ int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
+ { \
+ return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
+ }
+
/* This includes evil casts to remove const: they will go away when full
* ASN1 constification is done.
*/
/* This includes evil casts to remove const: they will go away when full
* ASN1 constification is done.
*/
@@
-780,6
+818,12
@@
typedef struct ASN1_AUX_st {
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
}
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
}
+#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
+ stname * stname##_dup(stname *x) \
+ { \
+ return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
+ }
+
#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)