Sha256: 802d719ef9f758557da1aac7c691fbb6123c217541e1df8833757c7c9cd3da8a
Contents?: true
Size: 811 Bytes
Versions: 17
Compression:
Stored size: 811 Bytes
Contents
module Xmlenc module Algorithms class RsaOaepMgf1p DIGEST_METHODS = %w(http://www.w3.org/2000/09/xmldsig#sha1) def initialize(key) @key = key end def decrypt(cipher_value, options = {}) verify_algorithm(options[:node]) if options[:node] @key.private_decrypt(cipher_value, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING) end def encrypt(data) @key.public_encrypt(data, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING) end private def verify_algorithm(node) digest_method = node.at_xpath('./ds:DigestMethod', NAMESPACES)['Algorithm'] unless DIGEST_METHODS.include? digest_method raise UnsupportedError.new("RSA OEAP MGF1P unsupported digest method #{digest_method}") end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems