Skip to content

Commit

Permalink
add mocks for ECC pkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Dec 10, 2024
1 parent 5c491e5 commit a1390b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions lib/fog/aws/requests/kms/create_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ def create_key(*args)

self.data[:keys][key_id] = key

spec = key['KeySpec']
size = spec.split('_').last
spec = spec.split("_#{size}").first
case spec
size = key['KeySpec'].split('_').last
type = key['KeySpec'].split('_').first
case type
when 'ECC'
curve = {
'ECC_NIST_P256' => 'secp256k1',
'ECC_NIST_P384' => 'secp384r1',
'ECC_NIST_P521' => 'secp521r1',
'ECC_SECG_P256K1' => 'prime256v1'
}[key['KeySpec']]
self.data[:pkeys][key_id] = OpenSSL::PKey::EC.generate(curve)
when 'RSA'
self.data[:pkeys][key_id] = OpenSSL::PKey::RSA.generate(size.to_i)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aws/requests/kms/get_public_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_public_key(identifier, grant_tokens = nil)
end

class Mock
def get_public_key(identifier, grant_tokens = [])
def get_public_key(identifier, _grant_tokens = [])
response = Excon::Response.new
key = self.data[:keys][identifier]
pkey = self.data[:pkeys][identifier]
Expand Down

0 comments on commit a1390b5

Please sign in to comment.