Module: CcipherFactory::CompositeCipher::DecryptVerifier
- Includes:
- CcipherFactory::Common, TR::CondUtils, TeLogger::TeLogHelper
- Defined in:
- lib/ccipher_factory/composite_cipher/decrypt_verifier.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#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/composite_cipher/decrypt_verifier.rb', line 15
def decryption_key
@decryption_key
end
|
#verification_key ⇒ Object
Returns the value of attribute verification_key.
15
16
17
|
# File 'lib/ccipher_factory/composite_cipher/decrypt_verifier.rb', line 15
def verification_key
@verification_key
end
|
Instance Method Details
#decrypt_verify_final ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/ccipher_factory/composite_cipher/decrypt_verifier.rb', line 96
def decrypt_verify_final
@cipher.decrypt_final
intOutputFile.rewind
while not intOutputFile.eof?
@verifier.att_verify_update(intOutputFile.read)
end
@verifier.att_verify_final
end
|
#decrypt_verify_init(opts = { }, &block) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/ccipher_factory/composite_cipher/decrypt_verifier.rb', line 16
def decrypt_verify_init(opts = { }, &block)
raise CompositeCipherError, "Decryption key is required" if is_empty?(@decryption_key)
raise CompositeCipherError, "Output is required" if not is_output_given?
if block
instance_eval(&block)
decrypt_verify_final
else
self
end
end
|
#decrypt_verify_update_cipher(cipher) ⇒ Object
90
91
92
93
94
|
# File 'lib/ccipher_factory/composite_cipher/decrypt_verifier.rb', line 90
def decrypt_verify_update_cipher(cipher)
raise CompositeCipherError, "Please call update_meta() before calling update_cipher()" if is_empty?(@cipher)
@cipher.decrypt_update_cipher(cipher)
end
|
33
34
35
36
37
38
39
40
41
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
|
# File 'lib/ccipher_factory/composite_cipher/decrypt_verifier.rb', line 33
def decrypt_verify_update_meta(meta)
intOutputBuf.write(meta)
begin
Encoding.(intOutputBuf) do |meta, bal|
ts = BinStruct.instance.struct_from_bin(meta)
ccBin = ts.cipher_config
cc = BinStruct.instance.struct_from_bin(ccBin)
scBin = ts.signer_config
sc = BinStruct.instance.struct_from_bin(scBin)
case BTag.value_constant(cc.oid)
when :symkey_cipher
@cipher = CcipherFactory::SymKeyCipher.decryptor
@cipher.output(intOutputFile)
@cipher.key = @decryption_key
@cipher.decrypt_init
@cipher.decrypt_update_meta(ccBin)
when :ecc_cipher
@cipher = CcipherFactory::AsymKeyCipher.decryptor
@cipher.output(intOutputFile)
@cipher.decryption_key = @decryption_key
@cipher.decrypt_init
@cipher.decrypt_update_meta(ccBin)
else
raise CompositeCipherError, "Unknown envelope type '#{cc.id}'"
end
case BTag.value_constant(sc.oid)
when :ecc_att_sign
@verifier = AsymKeySigner.att_verifier
@verifier.output(@output)
when :symkey_att_sign
@verifier = SymKeySigner.att_verifier
@verifier.output(@output)
@verifier.verification_key = @verification_key
@verifier.att_verify_init
else
raise CompositeCipherError, "Unknown signer type '#{sc.id}'"
end
decrypt_verify_update_cipher(bal) if bal.length > 0
disposeOutput(intOutputBuf)
end
rescue Encoding::InsufficientData
end
end
|
#embedded_signer ⇒ Object
109
110
111
|
# File 'lib/ccipher_factory/composite_cipher/decrypt_verifier.rb', line 109
def embedded_signer
@verifier.embedded_signer if not_empty?(@verifier) and @verifier.respond_to?(:embedded_signer)
end
|