Module: CcipherFactory::CompositeCipher::SignEncryptor
- Includes:
- CcipherFactory::Common, CcipherFactory::Compression::CompressionHelper, TR::CondUtils
- Defined in:
- lib/ccipher_factory/composite_cipher/sign_encryptor.rb
Instance Attribute Summary collapse
-
#encryption_key ⇒ Object
Returns the value of attribute encryption_key.
-
#sender_keypair ⇒ Object
Returns the value of attribute sender_keypair.
-
#signing_key ⇒ Object
Returns the value of attribute signing_key.
Instance Method Summary collapse
- #sign_encrypt_final ⇒ Object
- #sign_encrypt_init(opts = { }, &block) ⇒ Object
- #sign_encrypt_update(data) ⇒ Object
Methods included from CcipherFactory::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 CcipherFactory::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
#encryption_key ⇒ Object
Returns the value of attribute encryption_key.
14 15 16 |
# File 'lib/ccipher_factory/composite_cipher/sign_encryptor.rb', line 14 def encryption_key @encryption_key end |
#sender_keypair ⇒ Object
Returns the value of attribute sender_keypair.
14 15 16 |
# File 'lib/ccipher_factory/composite_cipher/sign_encryptor.rb', line 14 def sender_keypair @sender_keypair end |
#signing_key ⇒ Object
Returns the value of attribute signing_key.
14 15 16 |
# File 'lib/ccipher_factory/composite_cipher/sign_encryptor.rb', line 14 def signing_key @signing_key end |
Instance Method Details
#sign_encrypt_final ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ccipher_factory/composite_cipher/sign_encryptor.rb', line 78 def sign_encrypt_final = @signer.att_sign_final @signingBuf.rewind while not @signingBuf.eof? @enc.encrypt_update(@signingBuf.read) end = @enc.encrypt_final ts = BinStruct.instance.struct(:sign_encrypt_cipher) ts.signer_config = ts.cipher_config = ts.encoded end |
#sign_encrypt_init(opts = { }, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 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 65 66 67 68 69 70 71 72 |
# File 'lib/ccipher_factory/composite_cipher/sign_encryptor.rb', line 16 def sign_encrypt_init(opts = { }, &block) sKey = @signing_key eKey = @encryption_key sender = @sender_keypair compress = opts[:compress] || false raise CompositeCipherError, "Signing key is required" if is_empty?(sKey) raise CompositeCipherError, "Encryption key is required" if is_empty?(eKey) raise CompositeCipherError, "Output is required" if not is_output_given? @signingBuf = Tempfile.new @signingBuf.binmode case sKey when SymKey @signer = SymKeySigner.att_signer @signer.output(@signingBuf) @signer.compression_on if is_compression_on? @signer.signing_key = sKey @signer.att_sign_init when AsymKey @signer = AsymKeySigner.att_signer @signer.output(@signingBuf) @signer.compression_on if is_compression_on? @signer.signing_key = sKey @signer.att_sign_init else raise CompositeCipherError, "Unknown signing key type '#{sKey.class}'" end # Encryption Key case eKey when SymKey @enc = SymKeyCipher.encryptor @enc.output(@output) @enc.key = eKey @enc.encrypt_init when AsymKey, Ccrypto::PublicKey #, OpenSSL::PKey::EC::Point @enc = AsymKeyCipher.encryptor @enc.output(@output) @enc.recipient_key = eKey @enc.sender_keypair = sender if not_empty?(sender) @enc.encrypt_init else raise CompositeCipherError, "Unknown encryption key type '#{eKey.class}'" end if block instance_eval(&block) sign_encrypt_final else self end end |
#sign_encrypt_update(data) ⇒ Object
74 75 76 |
# File 'lib/ccipher_factory/composite_cipher/sign_encryptor.rb', line 74 def sign_encrypt_update(data) @signer.att_sign_update(data) end |