Sha256: 953c29270af696c63146588aed18daac993f9a32a1cadfb6c13e77555ba96b2a

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

require 'xml/kit/templatable'

module Xml
  module Kit
    # An implementation of the EncryptedKey element.
    # https://www.w3.org/TR/xmlenc-core1/#sec-EncryptedKey
    #
    # @since 0.3.0
    class EncryptedKey
      include ::Xml::Kit::Templatable
      attr_reader :id
      attr_reader :asymmetric_cipher, :symmetric_cipher
      attr_accessor :key_info

      def initialize(
        id: Id.generate,
        asymmetric_cipher:,
        symmetric_cipher: Xml::Kit::Crypto::SymmetricCipher.new,
        key_info: nil
      )
        @id = id
        @asymmetric_cipher = asymmetric_cipher
        @symmetric_cipher = symmetric_cipher
        @key_info = key_info
      end

      def cipher_value
        Base64.strict_encode64(asymmetric_cipher.encrypt(symmetric_cipher.key))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xml-kit-0.3.1 lib/xml/kit/encrypted_key.rb