42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/ccrypto/provider.rb', line 42
def self.algo_instance(*args, &block)
config = args.first
if config.is_a?(Class) or config.is_a?(Module)
if config == Ccrypto::ECCConfig
ECCEngine
elsif config == Ccrypto::RSAConfig
RSAEngine
elsif config == Ccrypto::ECCKeyBundle
ECCKeyBundle
elsif config == Ccrypto::RSAKeyBundle
RSAKeyBundle
elsif config == Ccrypto::DigestConfig
DigestEngine
elsif config == Ccrypto::SecureRandomConfig
SecureRandomEngine
elsif config == Ccrypto::CipherConfig
CipherEngine
elsif config == Ccrypto::ECCPublicKey
Ccrypto::Java::ECCPublicKey
elsif config == Ccrypto::KeyConfig
SecretKeyEngine
elsif config == SecretSharingConfig
SecretSharingEngine
else
raise CcryptoProviderException, "Config class '#{config}' is not supported for provider '#{self.provider_name}'"
end
else
case config
when Ccrypto::ECCConfig
ECCEngine.new(*args, &block)
when Ccrypto::RSAConfig
RSAEngine.new(*args, &block)
when Ccrypto::DigestConfig
DigestEngine.instance(*args, &block)
when Ccrypto::X509::CertProfile
X509Engine.new(*args,&block)
when Ccrypto::ScryptConfig
ScryptEngine.new(*args,&block)
when Ccrypto::HKDFConfig
HKDFEngine.new(*args,&block)
when Ccrypto::PBKDF2Config
PBKDF2Engine.new(*args,&block)
when Ccrypto::CipherConfig
CipherEngine.new(*args, &block)
when Ccrypto::HMACConfig
HMACEngine.new(*args, &block)
when Ccrypto::SecretSharingConfig
SecretSharingEngine.new(*args,&block)
when Ccrypto::PKCS7Config
PKCS7Engine.new(*args, &block)
else
raise CcryptoProviderException, "Config instance '#{config}' is not supported for provider '#{self.provider_name}'"
end
end
end
|