Since there's no continuation, the ; can go as well :-)
[oweals/openssl.git] / crypto / asn1 / a_bytes.c
index 8cde69580402baf2a7d1ce2d7d9322518495a7ee..bb88660f58cf16464e43f771109fc9c08438123e 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include <openssl/asn1_mac.h>
-
-static unsigned long tag2bit[32]={
-0,     0,      0,      B_ASN1_BIT_STRING,      /* tags  0 -  3 */
-B_ASN1_OCTET_STRING,   0,      0,              B_ASN1_UNKNOWN,/* tags  4- 7 */
-B_ASN1_UNKNOWN,        B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN,/* tags  8-11 */
-B_ASN1_UTF8STRING,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,/* tags 12-15 */
-0,     0,      B_ASN1_NUMERICSTRING,B_ASN1_PRINTABLESTRING,
-B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
-0,B_ASN1_GRAPHICSTRING,B_ASN1_ISO64STRING,B_ASN1_GENERALSTRING,
-B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
-       };
+#include <openssl/asn1.h>
 
 static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
 /* type is a 'bitmap' of acceptable string types.
@@ -92,7 +81,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
                i=ASN1_R_TAG_VALUE_TOO_HIGH;;
                goto err;
                }
-       if (!(tag2bit[tag] & type))
+       if (!(ASN1_tag2bit(tag) & type))
                {
                i=ASN1_R_WRONG_TYPE;
                goto err;
@@ -111,7 +100,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
 
        if (len != 0)
                {
-               s=(unsigned char *)Malloc((int)len+1);
+               s=(unsigned char *)OPENSSL_malloc((int)len+1);
                if (s == NULL)
                        {
                        i=ERR_R_MALLOC_FAILURE;
@@ -124,7 +113,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
        else
                s=NULL;
 
-       if (ret->data != NULL) Free(ret->data);
+       if (ret->data != NULL) OPENSSL_free(ret->data);
        ret->length=(int)len;
        ret->data=s;
        ret->type=tag;
@@ -218,8 +207,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
                        {
                        if ((ret->length < len) || (ret->data == NULL))
                                {
-                               if (ret->data != NULL) Free(ret->data);
-                               s=(unsigned char *)Malloc((int)len + 1);
+                               if (ret->data != NULL) OPENSSL_free(ret->data);
+                               s=(unsigned char *)OPENSSL_malloc((int)len + 1);
                                if (s == NULL)
                                        {
                                        i=ERR_R_MALLOC_FAILURE;
@@ -235,7 +224,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
                else
                        {
                        s=NULL;
-                       if (ret->data != NULL) Free(ret->data);
+                       if (ret->data != NULL) OPENSSL_free(ret->data);
                        }
 
                ret->length=(int)len;
@@ -310,14 +299,14 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
        if (!asn1_Finish(c)) goto err;
 
        a->length=num;
-       if (a->data != NULL) Free(a->data);
+       if (a->data != NULL) OPENSSL_free(a->data);
        a->data=(unsigned char *)b.data;
        if (os != NULL) ASN1_STRING_free(os);
        return(1);
 err:
        ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE,c->error);
        if (os != NULL) ASN1_STRING_free(os);
-       if (b.data != NULL) Free(b.data);
+       if (b.data != NULL) OPENSSL_free(b.data);
        return(0);
        }