xmldsig 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/xmldsig/signature.rb +7 -4
- data/lib/xmldsig/version.rb +1 -1
- data/spec/lib/xmldsig/signature_spec.rb +4 -2
- metadata +2 -2
data/lib/xmldsig/signature.rb
CHANGED
@@ -66,7 +66,7 @@ module Xmldsig
|
|
66
66
|
if private_key
|
67
67
|
private_key.sign(signature_method.new, canonicalized_signed_info)
|
68
68
|
else
|
69
|
-
yield(canonicalized_signed_info)
|
69
|
+
yield(canonicalized_signed_info, signature_algorithm)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -85,9 +85,12 @@ module Xmldsig
|
|
85
85
|
Base64.encode64(digest_value).chomp
|
86
86
|
end
|
87
87
|
|
88
|
+
def signature_algorithm
|
89
|
+
signed_info.at_xpath("descendant::ds:SignatureMethod", NAMESPACES).get_attribute("Algorithm")
|
90
|
+
end
|
91
|
+
|
88
92
|
def signature_method
|
89
|
-
algorithm =
|
90
|
-
algorithm = algorithm && algorithm =~ /sha(.*?)$/i && $1.to_i
|
93
|
+
algorithm = signature_algorithm && signature_algorithm =~ /sha(.*?)$/i && $1.to_i
|
91
94
|
case algorithm
|
92
95
|
when 256 then
|
93
96
|
OpenSSL::Digest::SHA256
|
@@ -115,7 +118,7 @@ module Xmldsig
|
|
115
118
|
signature_valid = if certificate
|
116
119
|
certificate.public_key.verify(signature_method.new, signature_value, canonicalized_signed_info)
|
117
120
|
else
|
118
|
-
yield(signature_value, canonicalized_signed_info)
|
121
|
+
yield(signature_value, canonicalized_signed_info, signature_algorithm)
|
119
122
|
end
|
120
123
|
|
121
124
|
unless signature_valid
|
data/lib/xmldsig/version.rb
CHANGED
@@ -61,7 +61,8 @@ describe Xmldsig::Signature do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "accepts a block" do
|
64
|
-
signature.sign do |data|
|
64
|
+
signature.sign do |data, signature_algorithm|
|
65
|
+
signature_algorithm.should == "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
65
66
|
private_key.sign(OpenSSL::Digest::SHA256.new, data)
|
66
67
|
end
|
67
68
|
signature.signature_value.should == Base64.decode64("
|
@@ -103,7 +104,8 @@ describe Xmldsig::Signature do
|
|
103
104
|
end
|
104
105
|
|
105
106
|
it "accepts a block" do
|
106
|
-
signature.valid? do |signature_value, data|
|
107
|
+
signature.valid? do |signature_value, data, signature_algorithm|
|
108
|
+
signature_algorithm.should == "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
107
109
|
certificate.public_key.verify(OpenSSL::Digest::SHA256.new, signature_value, data)
|
108
110
|
end
|
109
111
|
signature.errors.should be_empty
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmldsig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|