Sha256: 17d434c77bb43fad213d0fa29327772665dce38b0525fa2b466c896db6f0e1d7

Contents?: true

Size: 868 Bytes

Versions: 3

Compression:

Stored size: 868 Bytes

Contents

# encoding: binary
# typed: false
# frozen_string_literal: true

module Paseto
  module Sodium
    module Stream
      class XChaCha20Xor < Paseto::Sodium::Stream::Base
        extend RbNaCl::Sodium
        sodium_type :stream

        sodium_primitive :xchacha20

        sodium_constant :KEYBYTES
        sodium_constant :NONCEBYTES
        sodium_constant :MESSAGEBYTES_MAX

        sodium_function :stream_xchacha20_xor,
                        :crypto_stream_xchacha20_xor,
                        %i[pointer pointer ulong_long pointer pointer]

        private

        sig { override.params(ciphertext: String, nonce: String, message: T.nilable(String)).returns(T::Boolean) }
        def do_encrypt(ciphertext, nonce, message)
          self.class.stream_xchacha20_xor(ciphertext, message, data_len(message), nonce, key)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-paseto-0.1.2 lib/paseto/sodium/stream/x_cha_cha20_xor.rb
ruby-paseto-0.1.1 lib/paseto/sodium/stream/x_cha_cha20_xor.rb
ruby-paseto-0.1.0 lib/paseto/sodium/stream/x_cha_cha20_xor.rb