Module: CcipherFactory::SymKeySigner::SymKeyAttVerify

Includes:
Common, Compression::CompressionHelper
Defined in:
lib/ccipher_factory/symkey_cipher/symkey_att_verify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Compression::CompressionHelper

#compress_data_if_active, #compression_off, #compression_on, #compressor, #decompress_data_if_active, #decompressor, #decompressor_from_encoded, #encode_null_compressor, #is_compression_on?, #logger

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

#verification_keyObject

Returns the value of attribute verification_key.



11
12
13
# File 'lib/ccipher_factory/symkey_cipher/symkey_att_verify.rb', line 11

def verification_key
  @verification_key
end

Instance Method Details

#att_verify_finalObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ccipher_factory/symkey_cipher/symkey_att_verify.rb', line 66

def att_verify_final
  res = @ver.verify_final 

  if res
    intOutputFile.rewind
    while not intOutputFile.eof?
      write_to_output(intOutputFile.read)
    end

    disposeOutput(intOutputFile)
  end

  res

end

#att_verify_init(opts = { }, &block) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ccipher_factory/symkey_cipher/symkey_att_verify.rb', line 12

def att_verify_init(opts = {  }, &block)

  @params = opts

  raise SymKeySignerError, "Please provide output for attached verify" if not is_output_given?

  if block
    instance_eval(&block)
    att_verify_final
  else
    self
  end

end

#att_verify_update(val) ⇒ Object



27
28
29
30
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
57
58
59
60
61
62
63
64
# File 'lib/ccipher_factory/symkey_cipher/symkey_att_verify.rb', line 27

def att_verify_update(val)

  if @ver.nil?
    intOutputBuf.write(val)
    begin
      Encoding.extract_meta(intOutputBuf) do |meta, bal|

        ts = BinStruct.instance.struct_from_bin(meta)

        vmeta = ts.symkey_signature
        compression = ts.compression

        cts = BinStruct.instance.struct_from_bin(compression)
        if cts.oid == BTag.constant_value(:compression_zlib)
          compression_on
          decompressor.decompress_update_meta(compression)
        end

        @ver = SymKeySigner.verifier

        @ver.verification_key = @verification_key
        @ver.verify_init(@params)
        @ver.verify_update_meta(vmeta)

        att_verify_update(bal) if bal.length > 0

        intOutputBuf.rewind
        intOutputBuf = nil
      end
    rescue Encoding::InsufficientData
    end
  else
    res = decompress_data_if_active(val)
    @ver.verify_update_data(res)
    intOutputFile.write(res)
  end

end