-
Notifications
You must be signed in to change notification settings - Fork 82
to_der on ASN1Data should convert ruby strings into java strings before encoding #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,36 @@ def test_null | |
} | ||
end | ||
|
||
def test_encode_asn1_data | ||
ai = OpenSSL::ASN1::ASN1Data.new(i = "bla", 0, :APPLICATION) | ||
ai2 = OpenSSL::ASN1.decode(ai.to_der) | ||
assert_equal :APPLICATION, ai2.tag_class | ||
assert_equal 0, ai2.tag | ||
assert_equal i, ai2.value | ||
|
||
ai = OpenSSL::ASN1::ASN1Data.new(i = "bla", 4, :UNIVERSAL) | ||
ai2 = OpenSSL::ASN1.decode(ai.to_der) | ||
assert_equal :UNIVERSAL, ai2.tag_class | ||
assert_equal 4, ai2.tag | ||
assert_equal i, ai2.value | ||
|
||
ai = OpenSSL::ASN1::ASN1Data.new(i = ["bla"], 0, :APPLICATION) | ||
ai2 = OpenSSL::ASN1.decode(ai.to_der) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still need to check with OpenSSL 1.x but recent Ruby versions do not support decoding the array:
it's a bit of an edge case and I am happy to leave it as is ( |
||
assert_equal :APPLICATION, ai2.tag_class | ||
assert_equal 0, ai2.tag | ||
assert_equal "bla", ai2.value | ||
|
||
ai = OpenSSL::ASN1::ASN1Data.new(i = ["bla", "bla"], 0, :APPLICATION) | ||
ai2 = OpenSSL::ASN1.decode(ai.to_der) | ||
assert_equal :APPLICATION, ai2.tag_class | ||
assert_equal 0, ai2.tag | ||
assert_equal "blabla", ai2.value | ||
|
||
assert_raise(ArgumentError) { OpenSSL::ASN1::ASN1Data.new(1).to_der } | ||
assert_raise("no implicit conversion of Integer into String") { OpenSSL::ASN1::ASN1Data.new(1, 0, :APPLICATION).to_der } | ||
assert_raise("no implicit conversion of Integer into String") { OpenSSL::ASN1::ASN1Data.new(1, 0, :CONTEXT_SPECIFIC).to_der } | ||
end | ||
|
||
def test_encode_nil | ||
#Primitives raise TypeError, Constructives NoMethodError | ||
|
||
|
Unchanged files with check annotations Beta
def test_dup | ||
key = Fixtures.pkey("dsa1024") | ||
key2 = key.dup | ||
assert_equal key.params, key2.params | ||
Check failure on line 30 in src/test/ruby/dsa/test_dsa.rb
|
||
# PKey is immutable in OpenSSL >= 3.0 | ||
#if !openssl?(3, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems a bit unusual, is there a reason why we have to resort to the exception as flow control?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't make the decoding of
"@\x03bla"
work in any other way (see the respective unit test, it fails with " unexpected implicit primitive encoding" without this). Do you know of a better alternative?