Sha256: b3c3368d049376565b8881d58ad416789406a0b743ff5e4ae06a85603a2aa797

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

# encoding: binary
# typed: strict
# frozen_string_literal: true

module Paseto
  module Operations
    class Wrap
      extend T::Sig

      DOMAIN_SEPARATOR_AUTH = "\x81"
      DOMAIN_SEPARATOR_ENCRYPT = "\x80"

      sig { params(wrapping_key: SymmetricKey, paserk: [String, String, String, String]).returns(Interface::Key) }
      def self.unwrap(wrapping_key, paserk)
        case paserk
        in [_, _, String => protocol, _] if protocol == 'pie'
          Wrappers::PIE.new(wrapping_key).decode(paserk)
        else
          raise UnknownProtocol, protocol
        end
      end

      sig { params(key: Interface::Key, wrapping_key: SymmetricKey, nonce: T.nilable(String)).returns(String) }
      def self.wrap(key, wrapping_key:, nonce: nil)
        Wrappers::PIE.new(wrapping_key).encode(key, nonce: nonce)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-paseto-0.1.2 lib/paseto/operations/wrap.rb
ruby-paseto-0.1.1 lib/paseto/operations/wrap.rb
ruby-paseto-0.1.0 lib/paseto/operations/wrap.rb