Class: Rnp::Sign
- Inherits:
-
Object
- Object
- Rnp::Sign
- Defined in:
- lib/rnp/op/sign.rb
Overview
Signing operation
Instance Method Summary collapse
-
#add_signer(signer, opts = {}) ⇒ self
Add a signer.
-
#armored=(armored) ⇒ Object
Set whether the output will be ASCII-armored.
-
#compression=(compression) ⇒ Object
Set the compression algorithm and level.
-
#creation_time=(creation_time) ⇒ Object
Set the creation time for signatures.
-
#execute ⇒ void
Execute the operation.
-
#expiration_time=(expiration_time) ⇒ Object
Set the expiration time for signatures.
-
#hash=(hash) ⇒ Object
Set the hash algorithm used for the signatures.
- #inspect ⇒ Object
-
#options=(opts) ⇒ Object
Set a group of options.
Instance Method Details
#add_signer(signer, opts = {}) ⇒ self
Note:
The optional (per-signature) options here are not supported by RNP internally at the time of this writing.
Add a signer.
43 44 45 46 47 48 49 50 51 |
# File 'lib/rnp/op/sign.rb', line 43 def add_signer(signer, opts = {}) pptr = FFI::MemoryPointer.new(:pointer) Rnp.call_ffi(:rnp_op_sign_add_signature, @ptr, signer.ptr, pptr) psig = pptr.read_pointer self.class.( psig, **opts, ) end |
#armored=(armored) ⇒ Object
Set whether the output will be ASCII-armored.
72 73 74 |
# File 'lib/rnp/op/sign.rb', line 72 def armored=(armored) Rnp.call_ffi(:rnp_op_sign_set_armor, @ptr, armored) end |
#compression=(compression) ⇒ Object
Set the compression algorithm and level.
83 84 85 86 87 88 89 90 |
# File 'lib/rnp/op/sign.rb', line 83 def compression=(compression) if !compression.is_a?(Hash) || Set.new(compression.keys) != Set.new(%i[algorithm level]) raise ArgumentError, 'Compression option must be of the form: {algorithm: \'zlib\', level: 5}' end Rnp.call_ffi(:rnp_op_sign_set_compression, @ptr, compression[:algorithm], compression[:level]) end |
#creation_time=(creation_time) ⇒ Object
Set the creation time for signatures.
104 105 106 107 |
# File 'lib/rnp/op/sign.rb', line 104 def creation_time=(creation_time) creation_time = creation_time.to_i if creation_time.is_a?(::Time) Rnp.call_ffi(:rnp_op_sign_set_creation_time, @ptr, creation_time) end |
#execute ⇒ void
This method returns an undefined value.
Execute the operation.
This should only be called once.
123 124 125 |
# File 'lib/rnp/op/sign.rb', line 123 def execute Rnp.call_ffi(:rnp_op_sign_execute, @ptr) end |
#expiration_time=(expiration_time) ⇒ Object
Set the expiration time for signatures.
114 115 116 |
# File 'lib/rnp/op/sign.rb', line 114 def expiration_time=(expiration_time) Rnp.call_ffi(:rnp_op_sign_set_expiration_time, @ptr, expiration_time) end |
#hash=(hash) ⇒ Object
Set the hash algorithm used for the signatures.
95 96 97 |
# File 'lib/rnp/op/sign.rb', line 95 def hash=(hash) Rnp.call_ffi(:rnp_op_sign_set_hash, @ptr, hash) end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/rnp/op/sign.rb', line 28 def inspect Rnp.inspect_ptr(self) end |
#options=(opts) ⇒ Object
Set a group of options.
61 62 63 64 65 66 |
# File 'lib/rnp/op/sign.rb', line 61 def (opts) %i{armored compression hash creation_time expiration_time}.each do |prop| value = opts[prop] send("#{prop}=", value) unless value.nil? end end |