Bug #4344 ยป fix_bn_cmp.diff
ruby/ext/openssl/ossl_bn.c (working copy) | ||
---|---|---|
GetBN(obj, bn);
|
||
} else switch (TYPE(obj)) {
|
||
case T_FIXNUM:
|
||
case T_BIGNUM:
|
||
obj = rb_String(obj);
|
||
if (!BN_dec2bn(&bn, StringValuePtr(obj))) {
|
||
ossl_raise(eBNError, NULL);
|
||
}
|
||
WrapBN(cBN, obj, bn); /* Handle potencial mem leaks */
|
||
break;
|
||
case T_NIL:
|
||
break;
|
||
default:
|
||
ossl_raise(rb_eTypeError, "Cannot convert into OpenSSL::BN");
|
||
}
|
ruby/test/openssl/test_bn.rb (working copy) | ||
---|---|---|
OpenSSL::BN.new((2 ** 107 - 1).to_s(16), 16).prime?
|
||
OpenSSL::BN.new((2 ** 127 - 1).to_s(16), 16).prime?(1)
|
||
end
|
||
def test_cmp_nil
|
||
bn = OpenSSL::BN.new('1')
|
||
bn == nil
|
||
bn != nil
|
||
end
|
||
end
|
||
end
|