Sha256: 205fac5693e5d8ec25be8732bd1039a773dd69f52f1002be25bc51152b73cbc0

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

# typed: strict
# frozen_string_literal: true

module Paseto
  module Interface
    module PBKD
      extend T::Sig
      extend T::Helpers

      include Kernel

      abstract!

      module ClassMethods
        extend T::Sig
        extend T::Helpers

        interface!

        sig { abstract.returns(Interface::Version) }
        def protocol; end
      end

      mixes_in_class_methods(ClassMethods)

      sig do
        abstract.params(
          header: String,
          pre_key: String,
          salt: String,
          nonce: String,
          edk: String,
          params: T::Hash[Symbol, Integer]
        ).returns([String, String])
      end
      def authenticate(header:, pre_key:, salt:, nonce:, edk:, params:); end  # rubocop:disable Metrics/ParameterLists

      sig(:final) { params(payload: String, key: String, nonce: String).returns(String) }
      def crypt(payload:, key:, nonce:)
        ek = protocol.digest("#{Operations::PBKW::DOMAIN_SEPARATOR_ENCRYPT}#{key}", digest_size: 32)

        protocol.crypt(key: ek, nonce: nonce, payload: payload)
      end

      sig do
        abstract.params(payload: String).returns(
          {
            salt: String,
            nonce: String,
            edk: String,
            tag: String,
            params: T::Hash[Symbol, Integer]
          }
        )
      end
      def decode(payload); end

      sig { abstract.params(salt: String, params: T::Hash[Symbol, Integer]).returns(String) }
      def pre_key(salt:, params:); end

      sig(:final) { returns(String) }
      def paserk_version
        protocol.paserk_version
      end

      sig(:final) { returns(Interface::Version) }
      def protocol
        self.class.protocol
      end

      sig { abstract.returns(String) }
      def random_nonce; end

      sig { abstract.returns(String) }
      def random_salt; end

      sig(:final) { returns(String) }
      def version
        protocol.version
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-paseto-0.1.2 lib/paseto/interface/pbkd.rb
ruby-paseto-0.1.1 lib/paseto/interface/pbkd.rb
ruby-paseto-0.1.0 lib/paseto/interface/pbkd.rb