@@ -3,13 +3,16 @@ class Epics::Client
3
3
4
4
attr_accessor :passphrase , :url , :host_id , :user_id , :partner_id , :keys , :keys_content , :current_order_id
5
5
attr_reader :version
6
+ attr_accessor :signature_version
6
7
attr_writer :iban , :bic , :name
7
8
attr_accessor :locale
8
9
9
10
def_delegators :connection , :post
10
11
11
12
VERSION_H3 = 'H003'
12
13
VERSION_H4 = 'H004'
14
+ VERSION_A5 = 'A005'
15
+ VERSION_A6 = 'A006'
13
16
14
17
VERSIONS = [ VERSION_H3 , VERSION_H4 ]
15
18
@@ -26,6 +29,7 @@ def initialize(keys_content, passphrase, url, host_id, user_id, partner_id)
26
29
self . locale = :de
27
30
self . current_order_id = 0
28
31
self . version = VERSION_H4
32
+ self . signature_version = VERSION_A6
29
33
30
34
yield self if block_given?
31
35
end
@@ -65,10 +69,6 @@ def encryption_key
65
69
keys [ encryption_version ]
66
70
end
67
71
68
- def signature_version
69
- 'A006'
70
- end
71
-
72
72
def signature_key
73
73
keys [ signature_version ]
74
74
end
@@ -108,7 +108,12 @@ def order_types
108
108
def self . setup ( passphrase , url , host_id , user_id , partner_id , keysize = 2048 , &block )
109
109
client = new ( nil , passphrase , url , host_id , user_id , partner_id , &block )
110
110
client . keys = [ client . signature_version , client . authentication_version , client . encryption_version ] . each_with_object ( { } ) do |type , memo |
111
- memo [ type ] = Epics ::Key . new ( OpenSSL ::PKey ::RSA . generate ( keysize ) )
111
+ memo [ type ] = case type
112
+ when VERSION_A6
113
+ Epics ::SignatureAlgorithm ::RsaPss . new ( OpenSSL ::PKey ::RSA . generate ( keysize ) )
114
+ else
115
+ Epics ::SignatureAlgorithm ::RsaPkcs1 . new ( OpenSSL ::PKey ::RSA . generate ( keysize ) )
116
+ end
112
117
end
113
118
114
119
client
@@ -164,7 +169,12 @@ def HPB
164
169
165
170
bank = OpenSSL ::PKey ::RSA . new ( OpenSSL ::ASN1 ::Sequence ( sequence ) . to_der )
166
171
167
- self . keys [ "#{ host_id . upcase } .#{ type } " ] = Epics ::Key . new ( bank )
172
+ self . keys [ "#{ host_id . upcase } .#{ type } " ] = case type
173
+ when VERSION_A6
174
+ Epics ::SignatureAlgorithm ::RsaPss . new ( bank )
175
+ else
176
+ Epics ::SignatureAlgorithm ::RsaPkcs1 . new ( bank )
177
+ end
168
178
end
169
179
170
180
[ bank_authentication_key , bank_encryption_key ]
@@ -324,7 +334,7 @@ def download_and_unzip(order_type, *args, **options)
324
334
end
325
335
326
336
def connection
327
- @connection ||= Faraday . new ( headers : { 'Content-Type' => 'text/xml' , user_agent : USER_AGENT } , ssl : { verify : verify_ssl? } ) do |faraday |
337
+ @connection ||= Faraday . new ( headers : { 'Content-Type' => 'text/xml' , user_agent : USER_AGENT } , ssl : { verify : verify_ssl? } ) do |faraday |
328
338
faraday . use Epics ::XMLSIG , { client : self }
329
339
faraday . use Epics ::ParseEbics , { client : self }
330
340
# faraday.use MyAdapter
@@ -334,7 +344,12 @@ def connection
334
344
335
345
def extract_keys
336
346
JSON . load ( self . keys_content ) . each_with_object ( { } ) do |( type , key ) , memo |
337
- memo [ type ] = Epics ::Key . new ( decrypt ( key ) ) if key
347
+ memo [ type ] = case type
348
+ when VERSION_A6
349
+ Epics ::SignatureAlgorithm ::RsaPss . new ( decrypt ( key ) )
350
+ else
351
+ Epics ::SignatureAlgorithm ::RsaPkcs1 . new ( decrypt ( key ) )
352
+ end if key
338
353
end
339
354
end
340
355
0 commit comments