Class: Ccrypto::Java::Provider
- Inherits:
-
Object
- Object
- Ccrypto::Java::Provider
- Includes:
- TR::CondUtils
- Defined in:
- lib/ccrypto/provider.rb
Class Method Summary collapse
- .algo_instance(*args, &block) ⇒ Object
- .asn1_engine(*args, &block) ⇒ Object
- .convert_keystore(*args, &block) ⇒ Object
- .convert_keystore_file(*args, &block) ⇒ Object
- .load_keystore(*args, &block) ⇒ Object
- .load_keystore_file(*args, &block) ⇒ Object
- .load_x509(*args, &block) ⇒ Object
- .provider_info ⇒ Object
- .provider_name ⇒ Object
- .supported_keypair_config(*args, &block) ⇒ Object
- .supported_secret_key_config(&block) ⇒ Object
- .util_instance(*args, &block) ⇒ Object
Class Method Details
.algo_instance(*args, &block) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/ccrypto/provider.rb', line 123 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::ECCPrivateKey Ccrypto::Java::ECCPrivateKey elsif config == Ccrypto::KeyConfig SecretKeyEngine elsif config == SecretSharingConfig SecretSharingEngine elsif config == ED25519Config ED25519Engine elsif config == X25519Config X25519Engine elsif config == Ccrypto::X25519KeyBundle X25519KeyBundle elsif config == Ccrypto::X509::CertProfile X509Engine elsif config == Ccrypto::HMACConfig HMACEngine elsif config == Ccrypto::PBKDF2Config PBKDF2Engine elsif config == Ccrypto::HKDFConfig HKDFEngine elsif config == Ccrypto::CrystalKyberConfig CrystalKyberEngine elsif config == Ccrypto::CrystalKyberPublicKey CrystalKyberPublicKey elsif config == Ccrypto::CrystalKyberPrivateKey CrystalKyberPrivateKey elsif config == Ccrypto::CrystalDilithiumConfig CrystalDilithiumEngine elsif config == Ccrypto::CrystalDilithiumPublicKey CrystalDilithiumPublicKey elsif config == Ccrypto::CrystalDilithiumPrivateKey CrystalDilithiumPrivateKey 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::X509::CSRProfile X509CSREngine.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::Argon2Config Argon2Engine.new(*args, &block) when Ccrypto::BCryptConfig BCryptEngine.new(*args, &block) when Ccrypto::SecretSharingConfig SecretSharingEngine.new(*args,&block) when Ccrypto::PKCS7Config PKCS7Engine.new(*args, &block) when Ccrypto::ED25519Config ED25519Engine.new(*args, &block) when Ccrypto::X25519Config X25519Engine.new(*args, &block) when Ccrypto::CrystalKyberConfig CrystalKyberEngine.new(*args, &block) when Ccrypto::CrystalDilithiumConfig CrystalDilithiumEngine.new(*args, &block) else raise CcryptoProviderException, "Config instance '#{config}' is not supported for provider '#{self.provider_name}'" end end end |
.asn1_engine(*args, &block) ⇒ Object
238 239 240 |
# File 'lib/ccrypto/provider.rb', line 238 def self.asn1_engine(*args, &block) ASN1Engine end |
.convert_keystore(*args, &block) ⇒ Object
97 98 99 |
# File 'lib/ccrypto/provider.rb', line 97 def self.convert_keystore(*args, &block) Keystore.convert_keystore(*args, &block) end |
.convert_keystore_file(*args, &block) ⇒ Object
101 102 103 |
# File 'lib/ccrypto/provider.rb', line 101 def self.convert_keystore_file(*args, &block) Keystore.convert_keystore_file(*args, &block) end |
.load_keystore(*args, &block) ⇒ Object
89 90 91 |
# File 'lib/ccrypto/provider.rb', line 89 def self.load_keystore(*args, &block) Keystore.load_keystore(*args, &block) end |
.load_keystore_file(*args, &block) ⇒ Object
93 94 95 |
# File 'lib/ccrypto/provider.rb', line 93 def self.load_keystore_file(*args, &block) Keystore.load_keystore_file(*args, &block) end |
.load_x509(*args, &block) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ccrypto/provider.rb', line 105 def self.load_x509(*args, &block) cert = args.first certType = args[1] || :der case certType when :b64, :base64 ccert = from_b64(cert) when :hex ccert = from_hex(cert) else # binary ccert = cert end X509Engine.bin_to_cert(ccert) end |
.provider_info ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/ccrypto/provider.rb', line 60 def self.provider_info info = {} info[:ruby_version] = RbConfig::CONFIG["ruby_version"] info[:host] = RbConfig::CONFIG["host"] info[:openssl_version] = OpenSSL::VERSION info[:bouncycastle_info] = JCEProvider::DEFProv.getInfo info end |
.provider_name ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/ccrypto/provider.rb', line 50 def self.provider_name "Java-BC" #nm = [] #nm << "Java-BC : " #provider_info.each do |k,v| # nm << "#{k.to_s.capitalize} : #{v}" #end #nm.join("\n") end |
.supported_keypair_config(*args, &block) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ccrypto/provider.rb', line 69 def self.supported_keypair_config(*args, &block) purpose = args.first case purpose when :signing, :sign, :identity [Ccrypto::ECCConfig, Ccrypto::RSAConfig, Ccrypto::ED25519Config, Ccrypto::CrystalDilithiumConfig] when :cipher, :encryption, :enc [Ccrypto::ECCConfig, Ccrypto::RSAConfig, Ccrypto::X25519Config, Ccrypto::CrystalKyberConfig] when :sign_and_encrypt, :sign_and_enc, :sign_and_cipher [Ccrypto::ECCConfig, Ccrypto::RSAConfig] else # all keypair config returned [Ccrypto::ECCConfig, Ccrypto::RSAConfig, Ccrypto::ED25519Config, Ccrypto::CrystalDilithiumConfig, Ccrypto::X25519Config, Ccrypto::CrystalKyberConfig] #raise KeypairEngineException, "Unknown key purpose '#{purpose}'. Supported including: :signing, :cipher or :sign_and_cipher" end end |
.supported_secret_key_config(&block) ⇒ Object
85 86 87 |
# File 'lib/ccrypto/provider.rb', line 85 def self.supported_secret_key_config(&block) CipherEngine.supported_cipher_list end |
.util_instance(*args, &block) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/ccrypto/provider.rb', line 242 def self.util_instance(*args, &block) algo = args.first case algo when :comparator, :compare, :data_comparator ComparatorUtil when :data_conversion, :converter, :data_converter, :data_conv DataConversionEngine when :memory_buffer, :membuf, :buffer, :mem ManagedMemoryBuffer when :compression, :compressor Compression.new(*(args[1..-1]), &block) when :decompression Decompression.new(*(args[1..-1]), &block) when :native_helper NativeHelper else raise CcryptoProviderException, "Util #{algo} is not supported for provider #{self.provider_name}" end end |