Class: OpenSSLAEAD
- Inherits:
-
AbstractSymmetricCrypt
- Object
- AbstractSymmetricCrypt
- OpenSSLAEAD
- Defined in:
- lib/ruby-common/v5/OpenSSLAEAD.rb
Constant Summary collapse
- METHOD =
0x0201
Instance Method Summary collapse
- #decrypt_with_key(payload, key) ⇒ Object
-
#initialize(tag: 16, crypt_method: "AES-256-GCM") ⇒ OpenSSLAEAD
constructor
A new instance of OpenSSLAEAD.
Methods inherited from AbstractSymmetricCrypt
Constructor Details
#initialize(tag: 16, crypt_method: "AES-256-GCM") ⇒ OpenSSLAEAD
Returns a new instance of OpenSSLAEAD.
6 7 8 9 10 |
# File 'lib/ruby-common/v5/OpenSSLAEAD.rb', line 6 def initialize(tag: 16, crypt_method: "AES-256-GCM") @tag= tag @crypt_method = crypt_method @crypt_iv = CryptMethodConstans::CRYPT_METHODS[crypt_method] end |
Instance Method Details
#decrypt_with_key(payload, key) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby-common/v5/OpenSSLAEAD.rb', line 12 def decrypt_with_key(payload, key) lengths = {"iv" => @crypt_iv, "tag" => @tag} result = parse(payload, lengths) raise DecryptError, 'Unrecognized payload' if result.method != METHOD; return decode( result.data, key, result.byte_buffer_map['iv'], result.byte_buffer_map['tag'] ) end |