class Botan::PK::Verify
Public Key Verify
Operation
See {Botan::PK::PublicKey#verify} for a simpler interface.
Public Class Methods
destroy(ptr)
click to toggle source
@api private
# File lib/botan/pk/op/verify.rb, line 38 def self.destroy(ptr) LibBotan.botan_pk_op_verify_destroy(ptr) end
new(key:, padding: nil)
click to toggle source
@param key [Botan::PK::PublicKey] the public key @param padding [String] the padding method name
# File lib/botan/pk/op/verify.rb, line 21 def initialize(key:, padding: nil) padding ||= Botan::DEFAULT_EMSA[key.algo] unless key.instance_of?(PublicKey) raise Botan::Error, 'Verify requires an instance of PublicKey' end ptr = FFI::MemoryPointer.new(:pointer) flags = 0 Botan.call_ffi(:botan_pk_op_verify_create, ptr, key.ptr, padding, flags) ptr = ptr.read_pointer if ptr.null? raise Botan::Error, 'botan_pk_op_verify_create returned NULL' end @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy)) end
Public Instance Methods
check_signature(signature)
click to toggle source
Checks the signature against the previously-provided data.
@param signature [String] the signature to check @return [Boolean] true if the signature is valid
# File lib/botan/pk/op/verify.rb, line 56 def check_signature(signature) sig_buf = FFI::MemoryPointer.from_data(signature) # workaround 2.2.0 release bug if LibBotan::LIB_VERSION == [2, 2, 0] rc = LibBotan.botan_pk_op_verify_finish(@ptr, sig_buf, sig_buf.size) raise Botan::Error, 'FFI call unexpectedly failed' \ unless [0, -1].include?(rc) else rc = Botan.call_ffi_rc(:botan_pk_op_verify_finish, @ptr, sig_buf, sig_buf.size) end rc.zero? end
inspect()
click to toggle source
# File lib/botan/pk/op/verify.rb, line 70 def inspect Botan.inspect_ptr(self) end
update(msg)
click to toggle source
Adds more data to the message currently being verified.
@param msg [String] the data to add @return [self]
# File lib/botan/pk/op/verify.rb, line 46 def update(msg) msg_buf = FFI::MemoryPointer.from_data(msg) Botan.call_ffi(:botan_pk_op_verify_update, @ptr, msg_buf, msg_buf.size) self end
Also aliased as: <<