mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/openssl/ossl.c: surpress warning: shorten-64-to-32.
* ext/openssl/ossl.h: ditto. * ext/openssl/ossl_asn1.c: ditto. * ext/openssl/ossl_bio.c: ditto. * ext/openssl/ossl_bn.c: ditto. * ext/openssl/ossl_cipher.c: ditto. * ext/openssl/ossl_hmac.c: ditto. * ext/openssl/ossl_ns_spki.c: ditto. * ext/openssl/ossl_ocsp.c: ditto. * ext/openssl/ossl_pkcs5.c: ditto. * ext/openssl/ossl_pkey.c: ditto. * ext/openssl/ossl_pkey_dh.c: ditto. * ext/openssl/ossl_pkey_dsa.c: ditto. * ext/openssl/ossl_pkey_ec.c: ditto. * ext/openssl/ossl_pkey_rsa.c: ditto. * ext/openssl/ossl_rand.c: ditto. * ext/openssl/ossl_ssl.c: ditto. * ext/openssl/ossl_x509ext.c: ditto. * ext/openssl/ossl_x509name.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
643f90d8db
commit
3a16cc24e8
20 changed files with 110 additions and 71 deletions
40
ChangeLog
40
ChangeLog
|
@ -1,3 +1,43 @@
|
|||
Thu Mar 24 14:45:57 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* ext/openssl/ossl.c: surpress warning: shorten-64-to-32.
|
||||
|
||||
* ext/openssl/ossl.h: ditto.
|
||||
|
||||
* ext/openssl/ossl_asn1.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_bio.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_bn.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_cipher.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_hmac.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_ns_spki.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_ocsp.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_pkcs5.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_pkey.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_pkey_dh.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_pkey_dsa.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_pkey_ec.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_pkey_rsa.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_rand.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_ssl.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_x509ext.c: ditto.
|
||||
|
||||
* ext/openssl/ossl_x509name.c: ditto.
|
||||
|
||||
Thu Mar 24 11:48:19 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* ext/openssl/ossl_rand.c (ossl_rand_egd_bytes): use NUM2INT because
|
||||
|
|
|
@ -170,7 +170,7 @@ ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
|
|||
rflag = flag ? Qtrue : Qfalse;
|
||||
pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
|
||||
if (status) return -1; /* exception was raised. */
|
||||
len = RSTRING_LEN(pass);
|
||||
len = RSTRING_LENINT(pass);
|
||||
if (len < 4) { /* 4 is OpenSSL hardcoded limit */
|
||||
rb_warning("password must be longer than 4 bytes");
|
||||
continue;
|
||||
|
@ -302,7 +302,7 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
|
|||
}
|
||||
ERR_clear_error();
|
||||
|
||||
if(len > BUFSIZ) len = strlen(buf);
|
||||
if(len > BUFSIZ) len = rb_long2int(strlen(buf));
|
||||
return rb_exc_new(exc, buf, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,8 +126,8 @@ VALUE ossl_x509crl_sk2ary(STACK_OF(X509_CRL) *crl);
|
|||
VALUE ossl_buf2str(char *buf, int len);
|
||||
#define ossl_str_adjust(str, p) \
|
||||
do{\
|
||||
int len = RSTRING_LEN(str);\
|
||||
int newlen = (p) - (unsigned char*)RSTRING_PTR(str);\
|
||||
int len = RSTRING_LENINT(str);\
|
||||
int newlen = rb_long2int((p) - (unsigned char*)RSTRING_PTR(str));\
|
||||
assert(newlen <= len);\
|
||||
rb_str_set_len((str), newlen);\
|
||||
}while(0)
|
||||
|
|
|
@ -223,7 +223,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, (unsigned char *)RSTRING_PTR(obj), RSTRING_LEN(obj));
|
||||
ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LENINT(obj));
|
||||
bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
|
||||
bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
|
||||
|
||||
|
@ -238,7 +238,7 @@ obj_to_asn1str(VALUE obj)
|
|||
StringValue(obj);
|
||||
if(!(str = ASN1_STRING_new()))
|
||||
ossl_raise(eASN1Error, NULL);
|
||||
ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LEN(obj));
|
||||
ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ obj_to_asn1derstr(VALUE obj)
|
|||
str = ossl_to_der(obj);
|
||||
if(!(a1str = ASN1_STRING_new()))
|
||||
ossl_raise(eASN1Error, NULL);
|
||||
ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LENINT(str));
|
||||
|
||||
return a1str;
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ ossl_asn1_get_asn1type(VALUE obj)
|
|||
VALUE value, rflag;
|
||||
void *ptr;
|
||||
void (*free_func)();
|
||||
long tag, flag;
|
||||
int tag, flag;
|
||||
|
||||
tag = ossl_asn1_default_tag(obj);
|
||||
value = ossl_asn1_get_value(obj);
|
||||
|
@ -709,11 +709,11 @@ ossl_asn1data_to_der(VALUE self)
|
|||
is_cons = 2;
|
||||
tmp_cons = 2;
|
||||
}
|
||||
if((length = ASN1_object_size(tmp_cons, RSTRING_LEN(value), tag)) <= 0)
|
||||
if((length = ASN1_object_size(tmp_cons, RSTRING_LENINT(value), tag)) <= 0)
|
||||
ossl_raise(eASN1Error, NULL);
|
||||
der = rb_str_new(0, length);
|
||||
p = (unsigned char *)RSTRING_PTR(der);
|
||||
ASN1_put_object(&p, is_cons, RSTRING_LEN(value), tag, tag_class);
|
||||
ASN1_put_object(&p, is_cons, RSTRING_LENINT(value), tag, tag_class);
|
||||
memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
|
||||
p += RSTRING_LEN(value);
|
||||
ossl_str_adjust(der, p);
|
||||
|
@ -739,7 +739,7 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
|
|||
j = ASN1_get_object(&p0, &len, &tag, &tc, length);
|
||||
p = (unsigned char *)p0;
|
||||
if(j & 0x80) ossl_raise(eASN1Error, NULL);
|
||||
hlen = p - start;
|
||||
hlen = rb_long2int(p - start);
|
||||
if(yield){
|
||||
VALUE arg = rb_ary_new();
|
||||
rb_ary_push(arg, LONG2NUM(depth));
|
||||
|
@ -784,28 +784,29 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
|
|||
VALUE klass = *ossl_asn1_info[tag].klass;
|
||||
long flag = 0;
|
||||
if(!rb_obj_is_kind_of(value, rb_cArray)){
|
||||
int l = rb_long2int(hlen + len);
|
||||
switch(tag){
|
||||
case V_ASN1_BOOLEAN:
|
||||
value = decode_bool(start, hlen+len);
|
||||
value = decode_bool(start, l);
|
||||
break;
|
||||
case V_ASN1_INTEGER:
|
||||
value = decode_int(start, hlen+len);
|
||||
value = decode_int(start, l);
|
||||
break;
|
||||
case V_ASN1_BIT_STRING:
|
||||
value = decode_bstr(start, hlen+len, &flag);
|
||||
value = decode_bstr(start, l, &flag);
|
||||
break;
|
||||
case V_ASN1_NULL:
|
||||
value = decode_null(start, hlen+len);
|
||||
value = decode_null(start, l);
|
||||
break;
|
||||
case V_ASN1_ENUMERATED:
|
||||
value = decode_enum(start, hlen+len);
|
||||
value = decode_enum(start, l);
|
||||
break;
|
||||
case V_ASN1_OBJECT:
|
||||
value = decode_obj(start, hlen+len);
|
||||
value = decode_obj(start, l);
|
||||
break;
|
||||
case V_ASN1_UTCTIME: /* FALLTHROUGH */
|
||||
case V_ASN1_GENERALIZEDTIME:
|
||||
value = decode_time(start, hlen+len);
|
||||
value = decode_time(start, l);
|
||||
break;
|
||||
default:
|
||||
/* use original value */
|
||||
|
@ -1008,7 +1009,7 @@ ossl_asn1prim_to_der(VALUE self)
|
|||
ossl_ASN1_TYPE_free(asn1);
|
||||
reallen = p - buf;
|
||||
assert(reallen <= len);
|
||||
str = ossl_buf2str((char *)buf, reallen); /* buf will be free in ossl_buf2str */
|
||||
str = ossl_buf2str((char *)buf, rb_long2int(reallen)); /* buf will be free in ossl_buf2str */
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -1017,8 +1018,8 @@ static VALUE
|
|||
ossl_asn1cons_to_der(VALUE self)
|
||||
{
|
||||
int tag, tn, tc, explicit, constructed = 1;
|
||||
int found_prim = 0;
|
||||
long seq_len, length;
|
||||
int found_prim = 0, seq_len;
|
||||
long length;
|
||||
unsigned char *p;
|
||||
VALUE value, str, inf_length, ary, example;
|
||||
|
||||
|
@ -1060,19 +1061,19 @@ ossl_asn1cons_to_der(VALUE self)
|
|||
explicit = ossl_asn1_is_explicit(self);
|
||||
value = join_der(ossl_asn1_get_value(self));
|
||||
|
||||
seq_len = ASN1_object_size(constructed, RSTRING_LEN(value), tag);
|
||||
seq_len = ASN1_object_size(constructed, RSTRING_LENINT(value), tag);
|
||||
length = ASN1_object_size(constructed, seq_len, tn);
|
||||
str = rb_str_new(0, length);
|
||||
p = (unsigned char *)RSTRING_PTR(str);
|
||||
if(tc == V_ASN1_UNIVERSAL)
|
||||
ASN1_put_object(&p, constructed, RSTRING_LEN(value), tn, tc);
|
||||
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
|
||||
else{
|
||||
if(explicit){
|
||||
ASN1_put_object(&p, constructed, seq_len, tn, tc);
|
||||
ASN1_put_object(&p, constructed, RSTRING_LEN(value), tag, V_ASN1_UNIVERSAL);
|
||||
ASN1_put_object(&p, constructed, seq_len, tn, tc);
|
||||
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tag, V_ASN1_UNIVERSAL);
|
||||
}
|
||||
else{
|
||||
ASN1_put_object(&p, constructed, RSTRING_LEN(value), tn, tc);
|
||||
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
|
||||
}
|
||||
}
|
||||
memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
|
||||
|
|
|
@ -39,7 +39,7 @@ ossl_obj2bio(VALUE obj)
|
|||
}
|
||||
else {
|
||||
StringValue(obj);
|
||||
bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LEN(obj));
|
||||
bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LENINT(obj));
|
||||
if (!bio) ossl_raise(eOSSLError, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,12 +133,12 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
switch (base) {
|
||||
case 0:
|
||||
if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str), bn)) {
|
||||
if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
|
||||
ossl_raise(eBNError, NULL);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!BN_bin2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str), bn)) {
|
||||
if (!BN_bin2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
|
||||
ossl_raise(eBNError, NULL);
|
||||
}
|
||||
break;
|
||||
|
@ -198,11 +198,11 @@ ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
|
|||
break;
|
||||
case 10:
|
||||
if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL);
|
||||
str = ossl_buf2str(buf, strlen(buf));
|
||||
str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
|
||||
break;
|
||||
case 16:
|
||||
if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL);
|
||||
str = ossl_buf2str(buf, strlen(buf));
|
||||
str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
|
||||
break;
|
||||
default:
|
||||
ossl_raise(rb_eArgError, "invalid radix %d", base);
|
||||
|
|
|
@ -217,7 +217,7 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
|
|||
else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
|
||||
}
|
||||
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
|
||||
(unsigned char *)RSTRING_PTR(pass), RSTRING_LEN(pass), 1, key, NULL);
|
||||
(unsigned char *)RSTRING_PTR(pass), RSTRING_LENINT(pass), 1, key, NULL);
|
||||
p_key = key;
|
||||
p_iv = iv;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
|
|||
digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
|
||||
GetCipher(self, ctx);
|
||||
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
|
||||
(unsigned char *)RSTRING_PTR(vpass), RSTRING_LEN(vpass), iter, key, iv);
|
||||
(unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);
|
||||
if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
|
||||
ossl_raise(eCipherError, NULL);
|
||||
OPENSSL_cleanse(key, sizeof key);
|
||||
|
@ -330,7 +330,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
StringValue(data);
|
||||
in = (unsigned char *)RSTRING_PTR(data);
|
||||
if ((in_len = RSTRING_LEN(data)) == 0)
|
||||
if ((in_len = RSTRING_LENINT(data)) == 0)
|
||||
rb_raise(rb_eArgError, "data must not be empty");
|
||||
GetCipher(self, ctx);
|
||||
out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
|
||||
|
|
|
@ -70,7 +70,7 @@ ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
|
|||
|
||||
StringValue(key);
|
||||
GetHMAC(self, ctx);
|
||||
HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LEN(key),
|
||||
HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
|
||||
GetDigestPtr(digest), NULL);
|
||||
|
||||
return self;
|
||||
|
@ -198,7 +198,7 @@ ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
|
|||
|
||||
StringValue(key);
|
||||
StringValue(data);
|
||||
buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LEN(key),
|
||||
buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
|
||||
(unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
|
||||
|
||||
return rb_str_new((const char *)buf, buf_len);
|
||||
|
@ -220,7 +220,7 @@ ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
|
|||
StringValue(key);
|
||||
StringValue(data);
|
||||
|
||||
buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LEN(key),
|
||||
buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
|
||||
(unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
|
||||
if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * (int)buf_len) {
|
||||
ossl_raise(eHMACError, "Cannot convert buf to hexbuf");
|
||||
|
|
|
@ -106,7 +106,7 @@ ossl_spki_to_pem(VALUE self)
|
|||
if (!(data = NETSCAPE_SPKI_b64_encode(spki))) {
|
||||
ossl_raise(eSPKIError, NULL);
|
||||
}
|
||||
str = ossl_buf2str(data, strlen(data));
|
||||
str = ossl_buf2str(data, rb_long2int(strlen(data)));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ ossl_spki_set_challenge(VALUE self, VALUE str)
|
|||
StringValue(str);
|
||||
GetSPKI(self, spki);
|
||||
if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING_PTR(str),
|
||||
RSTRING_LEN(str))) {
|
||||
RSTRING_LENINT(str))) {
|
||||
ossl_raise(eSPKIError, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
|
|||
else{
|
||||
StringValue(val);
|
||||
GetOCSPReq(self, req);
|
||||
ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LEN(val));
|
||||
ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
|
||||
}
|
||||
if(!ret) ossl_raise(eOCSPError, NULL);
|
||||
|
||||
|
@ -440,7 +440,7 @@ ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self)
|
|||
else{
|
||||
StringValue(val);
|
||||
GetOCSPBasicRes(self, bs);
|
||||
ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LEN(val));
|
||||
ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
|
||||
}
|
||||
if(!ret) ossl_raise(eOCSPError, NULL);
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ ossl_pkcs5_pbkdf2_hmac_sha1(VALUE self, VALUE pass, VALUE salt, VALUE iter, VALU
|
|||
|
||||
str = rb_str_new(0, len);
|
||||
|
||||
if (PKCS5_PBKDF2_HMAC_SHA1(RSTRING_PTR(pass), RSTRING_LEN(pass),
|
||||
(const unsigned char *)RSTRING_PTR(salt), RSTRING_LEN(salt), NUM2INT(iter),
|
||||
if (PKCS5_PBKDF2_HMAC_SHA1(RSTRING_PTR(pass), RSTRING_LENINT(pass),
|
||||
(const unsigned char *)RSTRING_PTR(salt), RSTRING_LENINT(salt), NUM2INT(iter),
|
||||
len, (unsigned char *)RSTRING_PTR(str)) != 1)
|
||||
ossl_raise(ePKCS5, "PKCS5_PBKDF2_HMAC_SHA1");
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
|
|||
StringValue(sig);
|
||||
StringValue(data);
|
||||
EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
|
||||
switch (EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LEN(sig), pkey)) {
|
||||
switch (EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey)) {
|
||||
case 0:
|
||||
return Qfalse;
|
||||
case 1:
|
||||
|
|
|
@ -473,8 +473,8 @@ ossl_create_dh(unsigned char *p, size_t plen, unsigned char *g, size_t glen)
|
|||
DH *dh;
|
||||
|
||||
if ((dh = DH_new()) == NULL) ossl_raise(eDHError, NULL);
|
||||
dh->p = BN_bin2bn(p, plen, NULL);
|
||||
dh->g = BN_bin2bn(g, glen, NULL);
|
||||
dh->p = BN_bin2bn(p, rb_long2int(plen), NULL);
|
||||
dh->g = BN_bin2bn(g, rb_long2int(glen), NULL);
|
||||
if (dh->p == NULL || dh->g == NULL){
|
||||
DH_free(dh);
|
||||
ossl_raise(eDHError, NULL);
|
||||
|
|
|
@ -396,7 +396,7 @@ ossl_dsa_sign(VALUE self, VALUE data)
|
|||
ossl_raise(eDSAError, "Private DSA key needed!");
|
||||
}
|
||||
str = rb_str_new(0, ossl_dsa_buf_size(pkey));
|
||||
if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data),
|
||||
if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
|
||||
(unsigned char *)RSTRING_PTR(str),
|
||||
&buf_len, pkey->pkey.dsa)) { /* type is ignored (0) */
|
||||
ossl_raise(eDSAError, NULL);
|
||||
|
@ -421,8 +421,8 @@ ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
|
|||
StringValue(digest);
|
||||
StringValue(sig);
|
||||
/* type is ignored (0) */
|
||||
ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LEN(digest),
|
||||
(unsigned char *)RSTRING_PTR(sig), RSTRING_LEN(sig), pkey->pkey.dsa);
|
||||
ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LENINT(digest),
|
||||
(unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey->pkey.dsa);
|
||||
if (ret < 0) {
|
||||
ossl_raise(eDSAError, NULL);
|
||||
}
|
||||
|
|
|
@ -671,7 +671,7 @@ static VALUE ossl_ec_key_dsa_sign_asn1(VALUE self, VALUE data)
|
|||
ossl_raise(eECError, "Private EC key needed!");
|
||||
|
||||
str = rb_str_new(0, ECDSA_size(ec) + 16);
|
||||
if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LEN(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)
|
||||
if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)
|
||||
ossl_raise(eECError, "ECDSA_sign");
|
||||
|
||||
rb_str_resize(str, buf_len);
|
||||
|
@ -693,7 +693,7 @@ static VALUE ossl_ec_key_dsa_verify_asn1(VALUE self, VALUE data, VALUE sig)
|
|||
StringValue(data);
|
||||
StringValue(sig);
|
||||
|
||||
switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LEN(data), (unsigned char *) RSTRING_PTR(sig), RSTRING_LEN(sig), ec)) {
|
||||
switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(sig), (int)RSTRING_LEN(sig), ec)) {
|
||||
case 1: return Qtrue;
|
||||
case 0: return Qfalse;
|
||||
default: break;
|
||||
|
@ -965,7 +965,7 @@ static VALUE ossl_s_builtin_curves(VALUE self)
|
|||
{
|
||||
EC_builtin_curve *curves = NULL;
|
||||
int n;
|
||||
int crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
int crv_len = rb_long2int(EC_get_builtin_curves(NULL, 0));
|
||||
VALUE ary, ret;
|
||||
|
||||
curves = ALLOCA_N(EC_builtin_curve, crv_len);
|
||||
|
|
|
@ -323,7 +323,7 @@ ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self)
|
|||
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
|
||||
StringValue(buffer);
|
||||
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
|
||||
buf_len = RSA_public_encrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
buf_len = RSA_public_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
(unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
|
||||
pad);
|
||||
if (buf_len < 0) ossl_raise(eRSAError, NULL);
|
||||
|
@ -352,7 +352,7 @@ ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
|
|||
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
|
||||
StringValue(buffer);
|
||||
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
|
||||
buf_len = RSA_public_decrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
buf_len = RSA_public_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
(unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
|
||||
pad);
|
||||
if (buf_len < 0) ossl_raise(eRSAError, NULL);
|
||||
|
@ -384,7 +384,7 @@ ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
|
|||
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
|
||||
StringValue(buffer);
|
||||
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
|
||||
buf_len = RSA_private_encrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
buf_len = RSA_private_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
(unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
|
||||
pad);
|
||||
if (buf_len < 0) ossl_raise(eRSAError, NULL);
|
||||
|
@ -416,7 +416,7 @@ ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self)
|
|||
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
|
||||
StringValue(buffer);
|
||||
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
|
||||
buf_len = RSA_private_decrypt(RSTRING_LEN(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
buf_len = RSA_private_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
|
||||
(unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
|
||||
pad);
|
||||
if (buf_len < 0) ossl_raise(eRSAError, NULL);
|
||||
|
|
|
@ -37,7 +37,7 @@ static VALUE
|
|||
ossl_rand_seed(VALUE self, VALUE str)
|
||||
{
|
||||
StringValue(str);
|
||||
RAND_seed(RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
RAND_seed(RSTRING_PTR(str), RSTRING_LENINT(str));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ static VALUE
|
|||
ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
|
||||
{
|
||||
StringValue(str);
|
||||
RAND_add(RSTRING_PTR(str), RSTRING_LEN(str), NUM2DBL(entropy));
|
||||
RAND_add(RSTRING_PTR(str), RSTRING_LENINT(str), NUM2DBL(entropy));
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -232,13 +232,12 @@ ossl_call_client_cert_cb(VALUE obj)
|
|||
static int
|
||||
ossl_client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
{
|
||||
VALUE obj;
|
||||
int status, success;
|
||||
VALUE obj, success;
|
||||
|
||||
obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
|
||||
success = rb_protect((VALUE(*)_((VALUE)))ossl_call_client_cert_cb,
|
||||
obj, &status);
|
||||
if (status || !success) return 0;
|
||||
obj, NULL);
|
||||
if (!RTEST(success)) return 0;
|
||||
*x509 = DupX509CertPtr(ossl_ssl_get_x509(obj));
|
||||
*pkey = DupPKeyPtr(ossl_ssl_get_key(obj));
|
||||
|
||||
|
@ -267,15 +266,14 @@ ossl_call_tmp_dh_callback(VALUE *args)
|
|||
static DH*
|
||||
ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
|
||||
{
|
||||
VALUE args[3];
|
||||
int status, success;
|
||||
VALUE args[3], success;
|
||||
|
||||
args[0] = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
|
||||
args[1] = INT2FIX(is_export);
|
||||
args[2] = INT2FIX(keylength);
|
||||
success = rb_protect((VALUE(*)_((VALUE)))ossl_call_tmp_dh_callback,
|
||||
(VALUE)args, &status);
|
||||
if (status || !success) return NULL;
|
||||
(VALUE)args, NULL);
|
||||
if (!RTEST(success)) return NULL;
|
||||
|
||||
return GetPKeyPtr(ossl_ssl_get_tmp_dh(args[0]))->pkey.dh;
|
||||
}
|
||||
|
@ -640,7 +638,7 @@ ossl_sslctx_setup(VALUE self)
|
|||
if (!NIL_P(val)){
|
||||
StringValue(val);
|
||||
if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val),
|
||||
RSTRING_LEN(val))){
|
||||
RSTRING_LENINT(val))){
|
||||
ossl_raise(eSSLError, "SSL_CTX_set_session_id_context:");
|
||||
}
|
||||
}
|
||||
|
@ -1233,7 +1231,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
|
|||
if(!nonblock && SSL_pending(ssl) <= 0)
|
||||
rb_thread_wait_fd(FPTR_TO_FD(fptr));
|
||||
for (;;){
|
||||
nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
|
||||
switch(ssl_get_error(ssl, nread)){
|
||||
case SSL_ERROR_NONE:
|
||||
goto end;
|
||||
|
@ -1313,7 +1311,7 @@ ossl_ssl_write_internal(VALUE self, VALUE str, int nonblock)
|
|||
|
||||
if (ssl) {
|
||||
for (;;){
|
||||
nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
|
||||
switch(ssl_get_error(ssl, nwrite)){
|
||||
case SSL_ERROR_NONE:
|
||||
goto end;
|
||||
|
|
|
@ -340,7 +340,7 @@ ossl_x509ext_set_value(VALUE self, VALUE data)
|
|||
OPENSSL_free(s);
|
||||
ossl_raise(eX509ExtError, NULL);
|
||||
}
|
||||
if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LEN(data))){
|
||||
if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LENINT(data))){
|
||||
OPENSSL_free(s);
|
||||
ASN1_OCTET_STRING_free(asn1s);
|
||||
ossl_raise(eX509ExtError, NULL);
|
||||
|
|
|
@ -167,7 +167,7 @@ VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
|
|||
if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
|
||||
GetX509Name(self, name);
|
||||
if (!X509_NAME_add_entry_by_txt(name, RSTRING_PTR(oid), NUM2INT(type),
|
||||
(const unsigned char *)RSTRING_PTR(value), RSTRING_LEN(value), -1, 0)) {
|
||||
(const unsigned char *)RSTRING_PTR(value), RSTRING_LENINT(value), -1, 0)) {
|
||||
ossl_raise(eX509NameError, NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue