Class: CryptoToolchain::DiffieHellman::Messages::Datum

Inherits:
Object
  • Object
show all
Defined in:
lib/crypto_toolchain/diffie_hellman/messages.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(peer:, contents:, initial: false) ⇒ Datum

Returns a new instance of Datum.



37
38
39
40
41
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 37

def initialize(peer: , contents: , initial: false)
  @peer = peer
  @contents = contents
  @initial = initial
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



48
49
50
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 48

def contents
  @contents
end

#initialObject (readonly) Also known as: initial?

Returns the value of attribute initial.



48
49
50
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 48

def initial
  @initial
end

#peerObject (readonly)

Returns the value of attribute peer.



48
49
50
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 48

def peer
  @peer
end

Instance Method Details

#decrypt(key:) ⇒ Object



43
44
45
46
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 43

def decrypt(key: )
  iv = contents[0..15]
  contents[16..-1].decrypt_cbc(key: key, iv: iv)
end