Skip to content

Commit 317b5c0

Browse files
committed
kms: mocks - cleanup signopts, support both raw and digest signing
1 parent 0c1ae2f commit 317b5c0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/fog/aws/requests/kms/sign.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def sign(identifier, message, algorithm, options = {})
2424
end
2525

2626
class Mock
27-
def sign(identifier, message, algorithm, _options = {})
27+
def sign(identifier, message, algorithm, options = {})
2828
response = Excon::Response.new
2929
pkey = self.data[:pkeys][identifier]
3030
unless pkey
@@ -34,11 +34,13 @@ def sign(identifier, message, algorithm, _options = {})
3434

3535
# FIXME: SM2 support?
3636
sha = "SHA#{algorithm.split('_SHA_').last}"
37+
signopts = {}
38+
signopts[:rsa_padding_mode] = 'pss' if algorithm.start_with?('RSASSA_PSS')
3739

38-
signature = if algorithm.start_with?('RSASSA_PSS')
39-
pkey.sign_pss(sha, message, salt_length: :max, mgf1_hash: sha)
40+
signature = if options['MessageType'] == 'RAW'
41+
pkey.sign_raw(sha, message, signopts)
4042
else
41-
pkey.sign(sha, message)
43+
pkey.sign(sha, message, signopts)
4244
end
4345

4446
response.body = {

0 commit comments

Comments
 (0)