Module: CcipherFactory::AsymKeyCipher::ECCDecrypt
- Includes:
- Common, TR::CondUtils
- Defined in:
- lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb
Defined Under Namespace
Classes: ECCCipherError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Common
#attach_mode, #cleanup_intOutputBuf, #cleanup_intOutputFile, #detach_mode, #disposeOutput, #intOutputBuf, #intOutputFile, #is_attach_mode?, #is_output_given?, #output, #output_obj, #sanitize_symbol, #write_to_output
Instance Attribute Details
#decryption_key ⇒ Object
Returns the value of attribute decryption_key.
15
16
17
|
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb', line 15
def decryption_key
@decryption_key
end
|
Instance Method Details
#decrypt_final ⇒ Object
64
65
66
67
68
|
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb', line 64
def decrypt_final
@cipher.decrypt_final
end
|
#decrypt_init(opts = { }, &block) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb', line 16
def decrypt_init(opts = { }, &block)
if block
instance_eval(&block)
decrypt_final
else
self
end
end
|
#decrypt_update_cipher(cipher) ⇒ Object
58
59
60
61
62
|
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb', line 58
def decrypt_update_cipher(cipher)
raise ECCCipherError, "Please update meta first before update cipher" if is_empty?(@cipher)
@cipher.decrypt_update_cipher(cipher)
end
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb', line 31
def decrypt_update_meta(meta)
raise ECCCipherError, "Output is required" if not is_output_given?
ts = BinStruct.instance.struct_from_bin(meta)
senderPub = ts.sender_public
cipherConf = ts.cipher_config
keyConf = ts.key_config
sender = Ccrypto::AlgoFactory.engine(Ccrypto::ECCPublicKey).to_key(senderPub)
derived = @decryption_key.derive_dh_shared_secret(sender)
sessKey = DerivedSymKey.from_encoded(keyConf) do |ops|
case ops
when :password
derived
end
end
@cipher = SymKeyCipher.decryptor
@cipher.output(@output)
@cipher.key = sessKey
@cipher.decrypt_init
@cipher.decrypt_update_meta(cipherConf)
end
|
#logger ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_decrypt.rb', line 70
def logger
if @logger.nil?
@logger = Tlogger.new
@logger.tag = :ecc_dec
end
@logger
end
|