Class: OnePass::Opdata
- Inherits:
-
Object
- Object
- OnePass::Opdata
- Defined in:
- lib/OnePass.rb
Defined Under Namespace
Classes: InvalidException
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(buf, key, mac) ⇒ Opdata
constructor
A new instance of Opdata.
Constructor Details
#initialize(buf, key, mac) ⇒ Opdata
Returns a new instance of Opdata.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/OnePass.rb', line 18 def initialize(buf, key, mac) if buf[0..7] != "opdata01" raise OnePass::Opdata::InvalidException.new("Header was incorrect") end @length = buf[8..15].unpack("Q<")[0] @mac = buf[-32..-1] if OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, mac, buf[0..-33]) != @mac raise OnePass::VerifyException.new("MAC doesn't match; verify failed. Check your encryption/mac keys.") end @data = decrypt(buf[16..-33], key)[-1*@length..-1] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/OnePass.rb', line 13 def data @data end |