Since there's no continuation, the ; can go as well :-)
[oweals/openssl.git] / crypto / asn1 / asn1_mac.h
index 6edbf06a7d63937095e4486802c724b46ba573ac..a48649ceeb32f2e3d6fe04be9ec82b3c16891d8d 100644 (file)
 #ifndef HEADER_ASN1_MAC_H
 #define HEADER_ASN1_MAC_H
 
+#include <openssl/asn1.h>
+
 #ifdef  __cplusplus
 extern "C" {
 #endif
 
-#include <openssl/asn1.h>
-#include <openssl/x509.h>
-#include <openssl/pkcs7.h>
-
 #ifndef ASN1_MAC_ERR_LIB
 #define ASN1_MAC_ERR_LIB       ERR_LIB_ASN1
 #endif 
 
 #define ASN1_MAC_H_err(f,r,line) \
-       ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),ERR_file_name,(line))
+       ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
 
 #define M_ASN1_D2I_vars(a,type,func) \
        ASN1_CTX c; \
        type ret=NULL; \
        \
-       c.pp=pp; \
-       c.q= *pp; \
+       c.pp=(unsigned char **)pp; \
+       c.q= *(unsigned char **)pp; \
        c.error=ERR_R_NESTED_ASN1_ERROR; \
        if ((a == NULL) || ((*a) == NULL)) \
                { if ((ret=(type)func()) == NULL) \
@@ -87,13 +85,13 @@ extern "C" {
        else    ret=(*a);
 
 #define M_ASN1_D2I_Init() \
-       c.p= *pp; \
+       c.p= *(unsigned char **)pp; \
        c.max=(length == 0)?0:(c.p+length);
 
 #define M_ASN1_D2I_Finish_2(a) \
        if (!asn1_Finish(&c)) \
                { c.line=__LINE__; goto err; } \
-       *pp=c.p; \
+       *(unsigned char **)pp=c.p; \
        if (a != NULL) (*a)=ret; \
        return(ret);
 
@@ -101,13 +99,27 @@ extern "C" {
        M_ASN1_D2I_Finish_2(a); \
 err:\
        ASN1_MAC_H_err((e),c.error,c.line); \
-       asn1_add_error(*pp,(int)(c.q- *pp)); \
+       asn1_add_error(*(unsigned char **)pp,(int)(c.q- *pp)); \
        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
        return(NULL)
 
 #define M_ASN1_D2I_start_sequence() \
        if (!asn1_GetSequence(&c,&length)) \
                { c.line=__LINE__; goto err; }
+/* Begin reading ASN1 without a surrounding sequence */
+#define M_ASN1_D2I_begin() \
+       c.slen = length;
+
+/* End reading ASN1 with no check on length */
+#define M_ASN1_D2I_Finish_nolen(a, func, e) \
+       *pp=c.p; \
+       if (a != NULL) (*a)=ret; \
+       return(ret); \
+err:\
+       ASN1_MAC_H_err((e),c.error,c.line); \
+       asn1_add_error(*pp,(int)(c.q- *pp)); \
+       if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
+       return(NULL)
 
 #define M_ASN1_D2I_end_sequence() \
        (((c.inf&1) == 0)?(c.slen <= 0): \
@@ -163,6 +175,11 @@ err:\
                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
                { M_ASN1_D2I_get_set(r,func,free_func); }
 
+#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \
+       if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
+               V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
+               { M_ASN1_D2I_get_set_type(type,r,func,free_func); }
+
 #define M_ASN1_I2D_len_SET_opt(a,f) \
        if ((a != NULL) && (sk_num(a) != 0)) \
                M_ASN1_I2D_len_SET(a,f);
@@ -323,7 +340,7 @@ err:\
 
 /* New macros */
 #define M_ASN1_New_Malloc(ret,type) \
-       if ((ret=(type *)Malloc(sizeof(type))) == NULL) \
+       if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
                { c.line=__LINE__; goto err2; }
 
 #define M_ASN1_New(arg,func) \
@@ -352,6 +369,10 @@ err:\
 #define M_ASN1_I2D_len_SET(a,f) \
                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
 
+#define M_ASN1_I2D_len_SET_type(type,a,f) \
+               ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \
+                                           V_ASN1_UNIVERSAL,IS_SET);
+
 #define M_ASN1_I2D_len_SEQUENCE(a,f) \
                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
                                  IS_SEQUENCE);
@@ -444,6 +465,8 @@ err:\
 
 #define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\
                        V_ASN1_UNIVERSAL,IS_SET)
+#define M_ASN1_I2D_put_SET_type(type,a,f) \
+     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)
 #define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
                        V_ASN1_CONTEXT_SPECIFIC,IS_SET)
 #define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \