Sha256: a3d23d8d6225272bc4b536043aab10b4d45accfa3435d447f184621d5a476369
Contents?: true
Size: 1.87 KB
Versions: 6
Compression:
Stored size: 1.87 KB
Contents
# encoding: binary # frozen_string_literal: true module RbNaCl module AEAD # This class contains wrappers for the IETF implementation of # Authenticated Encryption with Additional Data using ChaCha20-Poly1305 class ChaCha20Poly1305IETF < RbNaCl::AEAD::Base extend Sodium if Sodium::Version.supported_version?("1.0.9") sodium_type :aead sodium_primitive :chacha20poly1305_ietf sodium_constant :KEYBYTES sodium_constant :NPUBBYTES sodium_constant :ABYTES sodium_function :aead_chacha20poly1305_ietf_encrypt, :crypto_aead_chacha20poly1305_ietf_encrypt, %i[pointer pointer pointer ulong_long pointer ulong_long pointer pointer pointer] sodium_function :aead_chacha20poly1305_ietf_decrypt, :crypto_aead_chacha20poly1305_ietf_decrypt, %i[pointer pointer pointer pointer ulong_long pointer ulong_long pointer pointer] private def do_encrypt(ciphertext, ciphertext_len, nonce, message, additional_data) self.class.aead_chacha20poly1305_ietf_encrypt(ciphertext, ciphertext_len, message, data_len(message), additional_data, data_len(additional_data), nil, nonce, @key) end def do_decrypt(message, message_len, nonce, ciphertext, additional_data) self.class.aead_chacha20poly1305_ietf_decrypt(message, message_len, nil, ciphertext, data_len(ciphertext), additional_data, data_len(additional_data), nonce, @key) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems