Sha256: 2c5bca30f6f73618dd6f89b8159556543c49df3834104cce56fa90b52319d9d6
Contents?: true
Size: 978 Bytes
Versions: 3
Compression:
Stored size: 978 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: nil, symmetric_cipher: nil, key_info: nil) @id = id @asymmetric_cipher = asymmetric_cipher || key_info.try(:asymmetric_cipher) @symmetric_cipher = symmetric_cipher || key_info.try(:symmetric_cipher) || Xml::Kit::Crypto::SymmetricCipher.new @key_info = key_info end def cipher_value Base64.strict_encode64(asymmetric_cipher.encrypt(symmetric_cipher.key)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
xml-kit-0.6.0 | lib/xml/kit/encrypted_key.rb |
xml-kit-0.5.0 | lib/xml/kit/encrypted_key.rb |
xml-kit-0.4.0 | lib/xml/kit/encrypted_key.rb |