Class: Ccrypto::Java::CrystalKyberKeyBundle
- Inherits:
-
Object
- Object
- Ccrypto::Java::CrystalKyberKeyBundle
show all
- Includes:
- DataConversion, KeyBundle, TR::CondUtils
- Defined in:
- lib/ccrypto/java/engines/crystal_kyber_engine.rb
Overview
Crystal-Kyber mainly for encryption via derivation
Instance Method Summary
collapse
#from_b64, #from_b64_mime, #from_hex, included, #logger, #to_b64, #to_b64_mime, #to_bin, #to_hex, #to_java_bytes, #to_str
Constructor Details
Returns a new instance of CrystalKyberKeyBundle.
157
158
159
160
|
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 157
def initialize(kp, params)
@nativeKeypair = kp
@nativeParam = params
end
|
Instance Method Details
#dec_derive(kem, &block) ⇒ Object
Also known as:
derive_dec_shared_secret
172
173
174
175
176
177
|
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 172
def dec_derive(kem, &block)
raise KeypairEngineException, "Native Keypair not available" if is_empty?(@nativeKeypair)
kemExt = KyberKEMExtractor.new(@nativeKeypair.getPrivate)
kemExt.(to_java_bytes(kem))
end
|
#enc_derive(pubKey, &block) ⇒ Object
Also known as:
derive_enc_shared_secret
162
163
164
165
166
167
168
169
|
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 162
def enc_derive(pubKey, &block)
raise KeypairEngineException, "Given public key to derive cannot be empty" if is_empty?(pubKey)
raise KeypairEngineException, "Given public key need to be a Crystal Kyber public key" if not pubKey.is_a?(CrystalKyberPublicKey)
rand = java.security.SecureRandom.getInstanceStrong()
kemGen = KyberKEMGenerator.new(rand)
CrystalKyberKEM.new(kemGen.generateEncapsulated(pubKey.native))
end
|
#private_key ⇒ Object
187
188
189
190
191
192
|
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 187
def private_key
if @_privKey.nil?
@_privKey = CrystalKyberPrivateKey.new(@nativeKeypair.getPrivate(), @nativeParam.param)
end
@_privKey
end
|
#public_key ⇒ Object
180
181
182
183
184
185
|
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 180
def public_key
if @_pubKey.nil?
@_pubKey = CrystalKyberPublicKey.new(@nativeKeypair.getPublic(), @nativeParam.param)
end
@_pubKey
end
|