class Botan::PK::Decrypt
Public Key Decrypt
Operation
See {Botan::PK::PrivateKey#decrypt} for a simpler interface.
Public Class Methods
destroy(ptr)
click to toggle source
@api private
# File lib/botan/pk/op/decrypt.rb, line 38 def self.destroy(ptr) LibBotan.botan_pk_op_decrypt_destroy(ptr) end
new(key:, padding: nil)
click to toggle source
@param key [Botan::PK::PrivateKey] the private key @param padding [String] the padding method name
# File lib/botan/pk/op/decrypt.rb, line 21 def initialize(key:, padding: nil) padding ||= Botan::DEFAULT_EME unless key.instance_of?(PrivateKey) raise Botan::Error, 'Decryption requires an instance of PrivateKey' end ptr = FFI::MemoryPointer.new(:pointer) flags = 0 Botan.call_ffi(:botan_pk_op_decrypt_create, ptr, key.ptr, padding, flags) ptr = ptr.read_pointer if ptr.null? raise Botan::Error, 'botan_pk_op_decrypt_create returned NULL' end @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy)) end
Public Instance Methods
decrypt(msg)
click to toggle source
Decrypts the provided data.
@param msg [String] the data @return [String] the decrypted data
# File lib/botan/pk/op/decrypt.rb, line 46 def decrypt(msg) msg_buf = FFI::MemoryPointer.from_data(msg) Botan.call_ffi_with_buffer(lambda { |b, bl| LibBotan.botan_pk_op_decrypt(@ptr, b, bl, msg_buf, msg_buf.size) }) end
inspect()
click to toggle source
# File lib/botan/pk/op/decrypt.rb, line 53 def inspect Botan.inspect_ptr(self) end