summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_asn1.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/ossl_asn1.c')
-rw-r--r--ext/openssl/ossl_asn1.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index b348c03a73..671bac14c1 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -33,7 +33,7 @@ asn1time_to_time(ASN1_TIME *time)
switch (time->type) {
case V_ASN1_UTCTIME:
- if (sscanf(time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
+ if (sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
ossl_raise(rb_eTypeError, "bad UTCTIME format");
}
@@ -44,7 +44,7 @@ asn1time_to_time(ASN1_TIME *time)
}
break;
case V_ASN1_GENERALIZEDTIME:
- if (sscanf(time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
+ if (sscanf((const char *)time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" );
}
@@ -80,7 +80,7 @@ time_to_time_t(VALUE time)
VALUE
asn1str_to_str(ASN1_STRING *str)
{
- return rb_str_new(str->data, str->length);
+ return rb_str_new((const char *)str->data, str->length);
}
/*
@@ -214,7 +214,7 @@ obj_to_asn1bstr(VALUE obj, long unused_bits)
StringValue(obj);
if(!(bstr = ASN1_BIT_STRING_new()))
ossl_raise(eASN1Error, NULL);
- ASN1_BIT_STRING_set(bstr, RSTRING_PTR(obj), RSTRING_LEN(obj));
+ ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LEN(obj));
bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
@@ -307,7 +307,7 @@ static VALUE
decode_bool(unsigned char* der, int length)
{
int bool;
- unsigned char *p;
+ const unsigned char *p;
p = der;
if((bool = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0)
@@ -320,7 +320,7 @@ static VALUE
decode_int(unsigned char* der, int length)
{
ASN1_INTEGER *ai;
- unsigned char *p;
+ const unsigned char *p;
VALUE ret;
int status = 0;
@@ -339,7 +339,7 @@ static VALUE
decode_bstr(unsigned char* der, int length, long *unused_bits)
{
ASN1_BIT_STRING *bstr;
- unsigned char *p, *buf;
+ const unsigned char *p;
long len;
VALUE ret;
@@ -350,7 +350,7 @@ decode_bstr(unsigned char* der, int length, long *unused_bits)
*unused_bits = 0;
if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT)
*unused_bits = bstr->flags & 0x07;
- ret = rb_str_new(bstr->data, len);
+ ret = rb_str_new((const char *)bstr->data, len);
ASN1_BIT_STRING_free(bstr);
return ret;
@@ -360,7 +360,7 @@ static VALUE
decode_enum(unsigned char* der, int length)
{
ASN1_ENUMERATED *ai;
- unsigned char *p;
+ const unsigned char *p;
VALUE ret;
int status = 0;
@@ -379,7 +379,7 @@ static VALUE
decode_null(unsigned char* der, int length)
{
ASN1_NULL *null;
- unsigned char *p;
+ const unsigned char *p;
p = der;
if(!(null = d2i_ASN1_NULL(NULL, &p, length)))
@@ -393,7 +393,7 @@ static VALUE
decode_obj(unsigned char* der, int length)
{
ASN1_OBJECT *obj;
- unsigned char *p;
+ const unsigned char *p;
VALUE ret;
int nid;
BIO *bio;
@@ -422,7 +422,7 @@ static VALUE
decode_time(unsigned char* der, int length)
{
ASN1_TIME *time;
- unsigned char *p;
+ const unsigned char *p;
VALUE ret;
int status = 0;
@@ -697,7 +697,7 @@ ossl_asn1data_to_der(VALUE self)
if((length = ASN1_object_size(1, RSTRING_LEN(value), tag)) <= 0)
ossl_raise(eASN1Error, NULL);
der = rb_str_new(0, length);
- p = RSTRING_PTR(der);
+ p = (unsigned char *)RSTRING_PTR(der);
ASN1_put_object(&p, is_cons, RSTRING_LEN(value), tag, tag_class);
memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
p += RSTRING_LEN(value);
@@ -711,6 +711,7 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
int once, int yield)
{
unsigned char *start, *p;
+ const unsigned char *p0;
long len, off = *offset;
int hlen, tag, tc, j;
VALUE ary, asn1data, value, tag_class;
@@ -719,7 +720,9 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
p = *pp;
while(length > 0){
start = p;
- j = ASN1_get_object(&p, &len, &tag, &tc, length);
+ p0 = p;
+ j = ASN1_get_object(&p0, &len, &tag, &tc, length);
+ p = (unsigned char *)p0;
if(j & 0x80) ossl_raise(eASN1Error, NULL);
hlen = p - start;
if(yield){
@@ -754,7 +757,7 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
else value = ossl_asn1_decode0(&p, len, &off, depth+1, 0, yield);
}
else{
- value = rb_str_new(p, len);
+ value = rb_str_new((const char *)p, len);
p += len;
off += len;
}
@@ -819,7 +822,7 @@ ossl_asn1_traverse(VALUE self, VALUE obj)
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
- p = RSTRING_PTR(tmp);
+ p = (unsigned char *)RSTRING_PTR(tmp);
ossl_asn1_decode0(&p, RSTRING_LEN(tmp), &offset, 0, 0, 1);
return Qnil;
@@ -835,7 +838,7 @@ ossl_asn1_decode(VALUE self, VALUE obj)
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
- p = RSTRING_PTR(tmp);
+ p = (unsigned char *)RSTRING_PTR(tmp);
ary = ossl_asn1_decode0(&p, RSTRING_LEN(tmp), &offset, 0, 1, 0);
ret = rb_ary_entry(ary, 0);
@@ -852,7 +855,7 @@ ossl_asn1_decode_all(VALUE self, VALUE obj)
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
- p = RSTRING_PTR(tmp);
+ p = (unsigned char *)RSTRING_PTR(tmp);
ret = ossl_asn1_decode0(&p, RSTRING_LEN(tmp), &offset, 0, 0, 0);
return ret;
@@ -947,7 +950,7 @@ ossl_asn1prim_to_der(VALUE self)
ossl_ASN1_TYPE_free(asn1);
reallen = p - buf;
assert(reallen <= len);
- str = ossl_buf2str(buf, reallen); /* buf will be free in ossl_buf2str */
+ str = ossl_buf2str((char *)buf, reallen); /* buf will be free in ossl_buf2str */
return str;
}
@@ -969,7 +972,7 @@ ossl_asn1cons_to_der(VALUE self)
seq_len = ASN1_object_size(1, RSTRING_LEN(value), tag);
length = ASN1_object_size(1, seq_len, tn);
str = rb_str_new(0, length);
- p = RSTRING_PTR(str);
+ p = (unsigned char *)RSTRING_PTR(str);
if(tc == V_ASN1_UNIVERSAL)
ASN1_put_object(&p, 1, RSTRING_LEN(value), tn, tc);
else{