1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
module SignKeyFixtureHelper
def shared_secret
'shared-secret'
end
def pem_file(file_name)
File.new pem_file_path(file_name)
end
def pem_file_path(file_name)
File.join(
File.dirname(__FILE__),
"../fixtures/#{file_name}.pem"
)
end
def der_file_path(file_name)
File.join(
File.dirname(__FILE__),
"../fixtures/#{file_name}.der"
)
end
def private_key(algorithm = :rsa, options = {})
case algorithm
when :rsa
OpenSSL::PKey::RSA.new(
pem_file("#{algorithm}/private_key"),
'pass-phrase'
)
when :ecdsa
OpenSSL::PKey::EC.new(
pem_file("#{algorithm}/#{options[:digest_length] || 256}/private_key")
)
end
end
def public_key(algorithm = :rsa, options = {})
case algorithm
when :rsa
OpenSSL::PKey::RSA.new(
pem_file("#{algorithm}/public_key")
)
when :ecdsa
OpenSSL::PKey::EC.new(
pem_file("#{algorithm}/#{options[:digest_length] || 256}/public_key")
)
end
end
end
include SignKeyFixtureHelper
|