Class: Botan::PK::Sign
- Inherits:
-
Object
- Object
- Botan::PK::Sign
- Defined in:
- lib/botan/pk/op/sign.rb
Overview
Public Key Sign Operation
See PrivateKey#sign for a simpler interface.
Class Method Summary collapse
- .destroy(ptr) ⇒ Object private
Instance Method Summary collapse
-
#finish(rng = Botan::RNG.new) ⇒ String
Finalizes the signature operation.
-
#initialize(key:, padding: nil) ⇒ Sign
constructor
A new instance of Sign.
- #inspect ⇒ Object
-
#update(msg) ⇒ self
(also: #<<)
Adds data to the message currently being signed.
Constructor Details
#initialize(key:, padding: nil) ⇒ Sign
Returns a new instance of Sign.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/botan/pk/op/sign.rb', line 22 def initialize(key:, padding: nil) padding ||= Botan::DEFAULT_EMSA[key.algo] unless key.instance_of?(PrivateKey) raise Botan::Error, 'Signing requires an instance of PrivateKey' end ptr = FFI::MemoryPointer.new(:pointer) flags = 0 Botan.call_ffi(:botan_pk_op_sign_create, ptr, key.ptr, padding, flags) ptr = ptr.read_pointer raise Botan::Error, 'botan_pk_op_sign_create returned NULL' if ptr.null? @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy)) end |
Class Method Details
.destroy(ptr) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/botan/pk/op/sign.rb', line 36 def self.destroy(ptr) LibBotan.botan_pk_op_sign_destroy(ptr) end |
Instance Method Details
#finish(rng = Botan::RNG.new) ⇒ String
Finalizes the signature operation.
54 55 56 57 58 |
# File 'lib/botan/pk/op/sign.rb', line 54 def finish(rng = Botan::RNG.new) Botan.call_ffi_with_buffer(lambda { |b, bl| LibBotan.botan_pk_op_sign_finish(@ptr, rng.ptr, b, bl) }) end |
#inspect ⇒ Object
60 61 62 |
# File 'lib/botan/pk/op/sign.rb', line 60 def inspect Botan.inspect_ptr(self) end |