A few more macros for long symbols.
[openssl.git] / crypto / asn1 / a_bitstr.c
index 63331b2e1e97a53b7b101d376234eed54fb40ba5..34179960b87aed426902213ab2640ec6f4998d58 100644 (file)
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 
-int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, size_t len)
-       { return M_ASN1_BIT_STRING_set(x, d, len); }
+int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
+{ return M_ASN1_BIT_STRING_set(x, d, len); }
 
 int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
        {
-       int ret,j,bits;
-       size_t len;
+       int ret,j,bits,len;
        unsigned char *p,*d;
 
        if (a == NULL) return(0);
@@ -115,7 +114,7 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
        }
 
 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
-                                    const unsigned char **pp, size_t len)
+       const unsigned char **pp, long len)
        {
        ASN1_BIT_STRING *ret=NULL;
        const unsigned char *p;
@@ -145,13 +144,13 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
 
        if (len-- > 1) /* using one because of the bits left byte */
                {
-               s=OPENSSL_malloc(len);
+               s=(unsigned char *)OPENSSL_malloc((int)len);
                if (s == NULL)
                        {
                        i=ERR_R_MALLOC_FAILURE;
                        goto err;
                        }
-               memcpy(s,p,len);
+               memcpy(s,p,(int)len);
                s[len-1]&=(0xff<<i);
                p+=len;
                }
@@ -174,10 +173,9 @@ err:
 
 /* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
  */
-int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, size_t n, int value)
+int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
        {
-       int v,iv;
-       size_t w;
+       int w,v,iv;
        unsigned char *c;
 
        w=n/8;
@@ -194,9 +192,11 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, size_t n, int value)
                {
                if (!value) return(1); /* Don't need to set */
                if (a->data == NULL)
-                       c=OPENSSL_malloc(w+1);
+                       c=(unsigned char *)OPENSSL_malloc(w+1);
                else
-                       c=OPENSSL_realloc_clean(a->data, a->length, w+1);
+                       c=(unsigned char *)OPENSSL_realloc_clean(a->data,
+                                                                a->length,
+                                                                w+1);
                if (c == NULL)
                        {
                        ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT,ERR_R_MALLOC_FAILURE);
@@ -212,7 +212,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, size_t n, int value)
        return(1);
        }
 
-int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, size_t n)
+int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
        {
        int w,v;
 
@@ -230,7 +230,7 @@ int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, size_t n)
  * 'len' is the length of 'flags'.
  */
 int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
-                         unsigned char *flags, size_t flags_len)
+                         unsigned char *flags, int flags_len)
        {
        int i, ok;
        /* Check if there is one bit set at all. */