Class: GPGME::Ctx
- Inherits:
-
Object
- Object
- GPGME::Ctx
- Defined in:
- lib/gpgme/ctx.rb,
lib/gpgme/compat.rb,
ext/gpgme/gpgme_n.c
Overview
A context within which all cryptographic operations are performed.
More operations can be done which are not available in the higher level API. Note how to create a new instance of this class in Ctx.new.
Class Method Summary collapse
-
.new(options = {}) ⇒ Object
Create a new instance from the given
options. - .pass_function(pass, uid_hint, passphrase_info, prev_was_bad, fd) ⇒ Object
Instance Method Summary collapse
-
#add_signer(*keys) ⇒ Object
Add keys to the list of signers.
-
#armor ⇒ Object
Return true if the output is ASCII armored.
-
#armor=(yes) ⇒ Object
Tell whether the output should be ASCII armored.
-
#clear_signers ⇒ Object
Remove the list of signers from this object.
-
#decrypt(cipher, plain = Data.new) ⇒ Object
Decrypt the ciphertext and return the plaintext.
- #decrypt_result ⇒ Object
- #decrypt_verify(cipher, plain = Data.new) ⇒ Object
-
#delete_key(key, allow_secret = false, force = false) ⇒ Object
(also: #delete)
Delete the key from the key ring.
-
#each_key(pattern = nil, secret_only = false, &block) ⇒ Object
(also: #each_keys)
Convenient method to iterate over keys.
-
#edit_card_key(key, editfunc, hook_value = nil, out = Data.new) ⇒ Object
(also: #edit_card, #card_edit)
Edit attributes of the key on the card.
-
#edit_key(key, editfunc, hook_value = nil, out = Data.new) ⇒ Object
(also: #edit)
Edit attributes of the key in the local key ring.
-
#encrypt(recp, plain, cipher = Data.new, flags = 0) ⇒ Object
Encrypt the plaintext in the data object for the recipients and return the ciphertext.
- #encrypt_result ⇒ Object
- #encrypt_sign(recp, plain, cipher = Data.new, flags = 0) ⇒ Object
-
#export_keys(recipients, keydata = Data.new, mode = 0) ⇒ Object
(also: #export)
Extract the public keys that match the
recipients. -
#generate_key(parms, pubkey = nil, seckey = nil) ⇒ Object
(also: #genkey)
Generate a new key pair.
-
#get_ctx_flag(flag_name) ⇒ Object
Get the value of the Ctx flag with the given name.
-
#get_key(fingerprint, secret = false) ⇒ Object
Get the key with the
fingerprint. -
#ignore_mdc_error ⇒ Object
Return true if the MDC integrity protection is disabled.
-
#ignore_mdc_error=(yes) ⇒ Object
This option ignores a MDC integrity protection failure.
-
#import_keys(keydata) ⇒ Object
(also: #import)
Add the keys in the data buffer to the key ring.
- #import_result ⇒ Object
- #inspect ⇒ Object
-
#keylist_end ⇒ Object
End a pending key list operation.
-
#keylist_mode ⇒ Object
Return the current key listing mode.
-
#keylist_mode=(mode) ⇒ Object
Change the default behaviour of the key listing functions.
-
#keylist_next ⇒ Object
Advance to the next key in the key listing operation.
-
#keylist_start(pattern = nil, secret_only = false) ⇒ Object
Initiate a key listing operation for given pattern.
-
#keys(pattern = nil, secret_only = nil) ⇒ Object
Returns the keys that match the
pattern, or all ifpatternis nil. -
#offline ⇒ Object
Return the current offline mode.
-
#offline=(mode) ⇒ Object
Change the default behaviour of the dirmngr that might require connections to external services.
-
#pinentry_mode ⇒ Object
Return the current pinentry mode.
-
#pinentry_mode=(mode) ⇒ Object
Change the default behaviour of the pinentry invocation.
-
#protocol ⇒ Object
Return the
protocolused within this context. -
#protocol=(proto) ⇒ Object
Set the
protocolused within this context. -
#random_bytes(size, mode = GPGME::RANDOM_MODE_NORMAL) ⇒ String
Generate cryptographically strong random bytes.
-
#random_value(limit) ⇒ Integer
Generate a cryptographically strong random unsigned integer value.
-
#release ⇒ Object
Releases the Ctx instance.
-
#rewind ⇒ Object
Set the data pointer to the beginning.
-
#set_ctx_flag(flag_name, val) ⇒ Object
Set the Ctx flag with the given name to the given value.
-
#set_passphrase_callback(passfunc, hook_value = nil) ⇒ Object
(also: #set_passphrase_cb)
Set the passphrase callback with given hook value.
-
#set_progress_callback(progfunc, hook_value = nil) ⇒ Object
(also: #set_progress_cb)
Set the progress callback with given hook value.
-
#set_status_callback(statusfunc, hook_value = nil) ⇒ Object
(also: #set_status_cb)
Set the status callback with given hook value.
-
#sign(plain, sig = Data.new, mode = GPGME::SIG_MODE_NORMAL) ⇒ Object
Create a signature for the text.
- #sign_result ⇒ Object
- #spawn(file, argv, datain, dataout, dataerr, flags = 0) ⇒ Object
-
#textmode ⇒ Object
Return true if canonical text mode is enabled.
-
#textmode=(yes) ⇒ Object
Tell whether canonical text mode should be used.
-
#verify(sig, signed_text = nil, plain = Data.new) ⇒ Object
Verify that the signature in the data object is a valid signature.
- #verify_result ⇒ Object
Class Method Details
.new(options = {}) ⇒ Object
Create a new instance from the given options. Must be released either executing the operations inside a block, or executing #release afterwards.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gpgme/ctx.rb', line 45 def self.new( = {}) rctx = [] err = GPGME::gpgme_new(rctx) exc = GPGME::error_to_exception(err) raise exc if exc ctx = rctx[0] ctx.protocol = [:protocol] if [:protocol] ctx.armor = [:armor] if [:armor] ctx.textmode = [:textmode] if [:textmode] ctx.keylist_mode = [:keylist_mode] if [:keylist_mode] ctx.pinentry_mode = [:pinentry_mode] if [:pinentry_mode] ctx.offline = [:offline] if [:offline] ctx.ignore_mdc_error = [:ignore_mdc_error] if [:ignore_mdc_error] if [:password] ctx.set_passphrase_callback GPGME::Ctx.method(:pass_function), [:password] else if [:passphrase_callback] ctx.set_passphrase_callback [:passphrase_callback], [:passphrase_callback_value] end end if [:progress_callback] ctx.set_progress_callback [:progress_callback], [:progress_callback_value] end if [:status_callback] ctx.set_status_callback [:status_callback], [:status_callback_value] end if block_given? GPGME.synchronize do begin yield ctx ensure GPGME::gpgme_release(ctx) end end else ctx end end |
.pass_function(pass, uid_hint, passphrase_info, prev_was_bad, fd) ⇒ Object
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/gpgme/ctx.rb', line 622 def self.pass_function(pass, uid_hint, passphrase_info, prev_was_bad, fd) # Write the passphrase directly using IO.for_fd. We set autoclose=false # to prevent Ruby from closing the fd (which belongs to GPGME/gpg-agent). # The IO object is used only within this method scope and not stored, # so we also ensure it isn't prematurely collected by keeping a strong # reference until we're done. io = IO.for_fd(fd, 'w') io.autoclose = false begin io.write "#{pass}\n" io.flush rescue => e # If the fd has become invalid (e.g. agent communication error), # re-raise as a more descriptive error. raise e end end |
Instance Method Details
#add_signer(*keys) ⇒ Object
Add keys to the list of signers.
532 533 534 535 536 537 538 |
# File 'lib/gpgme/ctx.rb', line 532 def add_signer(*keys) keys.each do |key| err = GPGME::gpgme_signers_add(self, key) exc = GPGME::error_to_exception(err) raise exc if exc end end |
#armor ⇒ Object
Return true if the output is ASCII armored.
167 168 169 |
# File 'lib/gpgme/ctx.rb', line 167 def armor GPGME::gpgme_get_armor(self) == 1 ? true : false end |
#armor=(yes) ⇒ Object
Tell whether the output should be ASCII armored.
161 162 163 164 |
# File 'lib/gpgme/ctx.rb', line 161 def armor=(yes) GPGME::gpgme_set_armor(self, yes ? 1 : 0) yes end |
#clear_signers ⇒ Object
Remove the list of signers from this object.
527 528 529 |
# File 'lib/gpgme/ctx.rb', line 527 def clear_signers GPGME::gpgme_signers_clear(self) end |
#decrypt(cipher, plain = Data.new) ⇒ Object
Decrypt the ciphertext and return the plaintext.
496 497 498 499 500 501 |
# File 'lib/gpgme/ctx.rb', line 496 def decrypt(cipher, plain = Data.new) err = GPGME::gpgme_op_decrypt(self, cipher, plain) exc = GPGME::error_to_exception(err) raise exc if exc plain end |
#decrypt_result ⇒ Object
510 511 512 |
# File 'lib/gpgme/ctx.rb', line 510 def decrypt_result GPGME::gpgme_op_decrypt_result(self) end |
#decrypt_verify(cipher, plain = Data.new) ⇒ Object
503 504 505 506 507 508 |
# File 'lib/gpgme/ctx.rb', line 503 def decrypt_verify(cipher, plain = Data.new) err = GPGME::gpgme_op_decrypt_verify(self, cipher, plain) exc = GPGME::error_to_exception(err) raise exc if exc plain end |
#delete_key(key, allow_secret = false, force = false) ⇒ Object Also known as: delete
Delete the key from the key ring. If allow_secret is false, only public keys are deleted, otherwise secret keys are deleted as well. If force is true, the confirmation dialog will not be displayed.
453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/gpgme/ctx.rb', line 453 def delete_key(key, allow_secret = false, force = false) err = nil if defined?(GPGME::gpgme_op_delete_ext) flag = 0 flag ^= GPGME::DELETE_ALLOW_SECRET if allow_secret flag ^= GPGME::DELETE_FORCE if force err = GPGME::gpgme_op_delete_ext(self, key, flag) else err = GPGME::gpgme_op_delete(self, key, allow_secret ? 1 : 0) end exc = GPGME::error_to_exception(err) raise exc if exc end |
#each_key(pattern = nil, secret_only = false, &block) ⇒ Object Also known as: each_keys
Convenient method to iterate over keys.
If pattern is nil, all available keys are returned. If secret_only is true, only secret keys are returned.
See Key.find for an example of how to use, or for an easier way to use.
361 362 363 364 365 366 367 368 369 370 |
# File 'lib/gpgme/ctx.rb', line 361 def each_key(pattern = nil, secret_only = false, &block) keylist_start(pattern, secret_only) begin loop { yield keylist_next } rescue EOFError # The last key in the list has already been returned. ensure keylist_end end end |
#edit_card_key(key, editfunc, hook_value = nil, out = Data.new) ⇒ Object Also known as: edit_card, card_edit
Edit attributes of the key on the card.
The callback receives (hook_value, status, args, fd) where status is a numeric status code (e.g., GPGME::GPGME_STATUS_GET_BOOL).
483 484 485 486 487 |
# File 'lib/gpgme/ctx.rb', line 483 def edit_card_key(key, editfunc, hook_value = nil, out = Data.new) err = GPGME::gpgme_op_card_edit(self, key, editfunc, hook_value, out) exc = GPGME::error_to_exception(err) raise exc if exc end |
#edit_key(key, editfunc, hook_value = nil, out = Data.new) ⇒ Object Also known as: edit
Edit attributes of the key in the local key ring.
The callback receives (hook_value, status, args, fd) where status is a numeric status code (e.g., GPGME::GPGME_STATUS_GET_BOOL).
472 473 474 475 476 |
# File 'lib/gpgme/ctx.rb', line 472 def edit_key(key, editfunc, hook_value = nil, out = Data.new) err = GPGME::gpgme_op_edit(self, key, editfunc, hook_value, out) exc = GPGME::error_to_exception(err) raise exc if exc end |
#encrypt(recp, plain, cipher = Data.new, flags = 0) ⇒ Object
Encrypt the plaintext in the data object for the recipients and return the ciphertext.
556 557 558 559 560 561 |
# File 'lib/gpgme/ctx.rb', line 556 def encrypt(recp, plain, cipher = Data.new, flags = 0) err = GPGME::gpgme_op_encrypt(self, recp, flags, plain, cipher) exc = GPGME::error_to_exception(err) raise exc if exc cipher end |
#encrypt_result ⇒ Object
563 564 565 |
# File 'lib/gpgme/ctx.rb', line 563 def encrypt_result GPGME::gpgme_op_encrypt_result(self) end |
#encrypt_sign(recp, plain, cipher = Data.new, flags = 0) ⇒ Object
567 568 569 570 571 572 |
# File 'lib/gpgme/ctx.rb', line 567 def encrypt_sign(recp, plain, cipher = Data.new, flags = 0) err = GPGME::gpgme_op_encrypt_sign(self, recp, flags, plain, cipher) exc = GPGME::error_to_exception(err) raise exc if exc cipher end |
#export_keys(recipients, keydata = Data.new, mode = 0) ⇒ Object Also known as: export
429 430 431 432 433 434 |
# File 'lib/gpgme/ctx.rb', line 429 def export_keys(recipients, keydata = Data.new, mode=0) err = GPGME::gpgme_op_export(self, recipients, mode, keydata) exc = GPGME::error_to_exception(err) raise exc if exc keydata end |
#generate_key(parms, pubkey = nil, seckey = nil) ⇒ Object Also known as: genkey
Generate a new key pair. parms is a string which looks like
<GnupgKeyParms format="internal">
Key-Type: DSA
Key-Length: 1024
Subkey-Type: ELG-E
Subkey-Length: 1024
Name-Real: Joe Tester
Name-Comment: with stupid passphrase
Name-Email: joe@foo.
Expire-Date: 0
Passphrase: abc
</GnupgKeyParms>
If pubkey and seckey are both set to nil, it stores the generated key pair into your key ring.
414 415 416 417 418 |
# File 'lib/gpgme/ctx.rb', line 414 def generate_key(parms, pubkey = nil, seckey = nil) err = GPGME::gpgme_op_genkey(self, parms, pubkey, seckey) exc = GPGME::error_to_exception(err) raise exc if exc end |
#get_ctx_flag(flag_name) ⇒ Object
Get the value of the Ctx flag with the given name.
Allowed flag names may include:
-
‘redraw’
-
‘full-status’
-
‘raw-description’
-
‘export-session-key’
-
‘override-session-key’
-
‘include-key-block’
-
‘auto-key-import’
-
‘auto-key-retrieve’
-
‘request-origin’
-
‘no-symkey-cache’
-
‘ignore-mdc-error’
-
‘auto-key-locate’
-
‘trust-model’
-
‘extended-edit’
-
‘cert-expire’
-
‘key-origin’
-
‘import-filter’
-
‘no-auto-check-trustdb’
Please consult the GPGPME documentation for more details
133 134 135 |
# File 'lib/gpgme/ctx.rb', line 133 def get_ctx_flag(flag_name) GPGME::gpgme_get_ctx_flag(self, flag_name.to_s) end |
#get_key(fingerprint, secret = false) ⇒ Object
Get the key with the fingerprint. If secret is true, secret key is returned.
385 386 387 388 389 390 391 |
# File 'lib/gpgme/ctx.rb', line 385 def get_key(fingerprint, secret = false) rkey = [] err = GPGME::gpgme_get_key(self, fingerprint, rkey, secret ? 1 : 0) exc = GPGME::error_to_exception(err) raise exc if exc rkey[0] end |
#ignore_mdc_error ⇒ Object
Return true if the MDC integrity protection is disabled.
183 184 185 |
# File 'lib/gpgme/ctx.rb', line 183 def ignore_mdc_error GPGME::gpgme_get_ignore_mdc_error(self) == 1 ? true : false end |
#ignore_mdc_error=(yes) ⇒ Object
This option ignores a MDC integrity protection failure. It is required to decrypt old messages which did not use an MDC. It may also be useful if a message is partially garbled, but it is necessary to get as much data as possible out of that garbled message. Be aware that a missing or failed MDC can be an indication of an attack. Use with great caution.
177 178 179 180 |
# File 'lib/gpgme/ctx.rb', line 177 def ignore_mdc_error=(yes) GPGME::gpgme_set_ignore_mdc_error(self, yes ? 1 : 0) yes end |
#import_keys(keydata) ⇒ Object Also known as: import
Add the keys in the data buffer to the key ring.
438 439 440 441 442 |
# File 'lib/gpgme/ctx.rb', line 438 def import_keys(keydata) err = GPGME::gpgme_op_import(self, keydata) exc = GPGME::error_to_exception(err) raise exc if exc end |
#import_result ⇒ Object
445 446 447 |
# File 'lib/gpgme/ctx.rb', line 445 def import_result GPGME::gpgme_op_import_result(self) end |
#inspect ⇒ Object
614 615 616 617 618 |
# File 'lib/gpgme/ctx.rb', line 614 def inspect "#<#{self.class} protocol=#{PROTOCOL_NAMES[protocol] || protocol}, \ armor=#{armor}, textmode=#{textmode}, \ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>" end |
#keylist_end ⇒ Object
End a pending key list operation.
Used by #each_key
348 349 350 351 352 |
# File 'lib/gpgme/ctx.rb', line 348 def keylist_end err = GPGME::gpgme_op_keylist_end(self) exc = GPGME::error_to_exception(err) raise exc if exc end |
#keylist_mode ⇒ Object
Return the current key listing mode.
205 206 207 |
# File 'lib/gpgme/ctx.rb', line 205 def keylist_mode GPGME::gpgme_get_keylist_mode(self) end |
#keylist_mode=(mode) ⇒ Object
Change the default behaviour of the key listing functions.
199 200 201 202 |
# File 'lib/gpgme/ctx.rb', line 199 def keylist_mode=(mode) GPGME::gpgme_set_keylist_mode(self, mode) mode end |
#keylist_next ⇒ Object
Advance to the next key in the key listing operation.
Used by #each_key
337 338 339 340 341 342 343 |
# File 'lib/gpgme/ctx.rb', line 337 def keylist_next rkey = [] err = GPGME::gpgme_op_keylist_next(self, rkey) exc = GPGME::error_to_exception(err) raise exc if exc rkey[0] end |
#keylist_start(pattern = nil, secret_only = false) ⇒ Object
Initiate a key listing operation for given pattern. If pattern is nil, all available keys are returned. If secret_only< is true, only secret keys are returned.
Used by #each_key
328 329 330 331 332 |
# File 'lib/gpgme/ctx.rb', line 328 def keylist_start(pattern = nil, secret_only = false) err = GPGME::gpgme_op_keylist_start(self, pattern, secret_only ? 1 : 0) exc = GPGME::error_to_exception(err) raise exc if exc end |
#keys(pattern = nil, secret_only = nil) ⇒ Object
Returns the keys that match the pattern, or all if pattern is nil. Returns only secret keys if secret_only is true.
375 376 377 378 379 380 381 |
# File 'lib/gpgme/ctx.rb', line 375 def keys(pattern = nil, secret_only = nil) keys = [] each_key(pattern, secret_only) do |key| keys << key end keys end |
#offline ⇒ Object
Return the current offline mode.
228 229 230 |
# File 'lib/gpgme/ctx.rb', line 228 def offline GPGME::gpgme_get_offline(self) end |
#offline=(mode) ⇒ Object
Change the default behaviour of the dirmngr that might require connections to external services.
222 223 224 225 |
# File 'lib/gpgme/ctx.rb', line 222 def offline=(mode) GPGME::gpgme_set_offline(self, mode) mode end |
#pinentry_mode ⇒ Object
Return the current pinentry mode.
216 217 218 |
# File 'lib/gpgme/ctx.rb', line 216 def pinentry_mode GPGME::gpgme_get_pinentry_mode(self) end |
#pinentry_mode=(mode) ⇒ Object
Change the default behaviour of the pinentry invocation.
210 211 212 213 |
# File 'lib/gpgme/ctx.rb', line 210 def pinentry_mode=(mode) GPGME::gpgme_set_pinentry_mode(self, mode) mode end |
#protocol ⇒ Object
Return the protocol used within this context.
156 157 158 |
# File 'lib/gpgme/ctx.rb', line 156 def protocol GPGME::gpgme_get_protocol(self) end |
#protocol=(proto) ⇒ Object
Set the protocol used within this context. See new for possible values.
148 149 150 151 152 153 |
# File 'lib/gpgme/ctx.rb', line 148 def protocol=(proto) err = GPGME::gpgme_set_protocol(self, proto) exc = GPGME::error_to_exception(err) raise exc if exc proto end |
#random_bytes(size, mode = GPGME::RANDOM_MODE_NORMAL) ⇒ String
Generate cryptographically strong random bytes. Available since GPGME 2.0.0.
587 588 589 590 591 592 593 594 595 596 |
# File 'lib/gpgme/ctx.rb', line 587 def random_bytes(size, mode = GPGME::RANDOM_MODE_NORMAL) result = GPGME::gpgme_op_random_bytes(self, size, mode) if result.is_a?(String) result else exc = GPGME::error_to_exception(result) raise exc if exc result end end |
#random_value(limit) ⇒ Integer
Generate a cryptographically strong random unsigned integer value. Available since GPGME 2.0.0.
603 604 605 606 607 608 609 610 611 612 |
# File 'lib/gpgme/ctx.rb', line 603 def random_value(limit) result = GPGME::gpgme_op_random_value(self, limit) if result.is_a?(Integer) && result >= 0 result else exc = GPGME::error_to_exception(result) raise exc if exc result end end |
#release ⇒ Object
Releases the Ctx instance. Must be called if it was initialized without a block.
101 102 103 |
# File 'lib/gpgme/ctx.rb', line 101 def release GPGME::gpgme_release(self) end |
#rewind ⇒ Object
Set the data pointer to the beginning.
26 27 28 |
# File 'lib/gpgme/compat.rb', line 26 def rewind seek(0) end |
#set_ctx_flag(flag_name, val) ⇒ Object
Set the Ctx flag with the given name to the given value.
139 140 141 142 143 144 |
# File 'lib/gpgme/ctx.rb', line 139 def set_ctx_flag(flag_name, val) err = GPGME::gpgme_set_ctx_flag(self, flag_name.to_s, val.to_s) exc = GPGME::error_to_exception(err) raise exc if exc val end |
#set_passphrase_callback(passfunc, hook_value = nil) ⇒ Object Also known as: set_passphrase_cb
Set the passphrase callback with given hook value. passfunc should respond to call with 5 arguments.
-
objthe parameter:passphrase_callback_valuepassed when creating the GPGME::Ctx object. -
uid_hinthint as to what key are we asking the password for. Ex:CFB3294A50C2CFD7 Albert Llop <[email protected]>
-
passphrase_info -
prev_was_bad0 if it’s the first time the password is being asked, 1 otherwise. -
fdfile descriptor where the password must be written too.
Expects a Method object which can be obtained by the method method (really..).
ctx.set_passphrase_callback(MyModule.method(:passfunc))
Note that this function doesn’t work with GnuPG 2.0. You can use either GnuPG 1.x, which can be installed in parallel with GnuPG 2.0, or GnuPG 2.1, which has loopback pinentry feature (see #pinentry_mode).
282 283 284 |
# File 'lib/gpgme/ctx.rb', line 282 def set_passphrase_callback(passfunc, hook_value = nil) GPGME::gpgme_set_passphrase_cb(self, passfunc, hook_value) end |
#set_progress_callback(progfunc, hook_value = nil) ⇒ Object Also known as: set_progress_cb
Set the progress callback with given hook value. progfunc should respond to call with 5 arguments.
def progfunc(hook, what, type, current, total)
$stderr.write("#{what}: #{current}/#{total}\r")
$stderr.flush
end
ctx.set_progress_callback(method(:progfunc))
297 298 299 |
# File 'lib/gpgme/ctx.rb', line 297 def set_progress_callback(progfunc, hook_value = nil) GPGME::gpgme_set_progress_cb(self, progfunc, hook_value) end |
#set_status_callback(statusfunc, hook_value = nil) ⇒ Object Also known as: set_status_cb
Set the status callback with given hook value. statusfunc should respond to call with 3 arguments.
-
objthe parameter:status_callback_valuepassed when creating the GPGME::Ctx object. -
keywordthe name of the status message -
argsany arguments for the status message
def status_function(obj, keyword, args)
$stderr.puts("#{keyword} #{args}")
return 0
end
314 315 316 |
# File 'lib/gpgme/ctx.rb', line 314 def set_status_callback(statusfunc, hook_value = nil) GPGME::gpgme_set_status_cb(self, statusfunc, hook_value) end |
#sign(plain, sig = Data.new, mode = GPGME::SIG_MODE_NORMAL) ⇒ Object
Create a signature for the text. plain is a data object which contains the text. sig is a data object where the generated signature is stored.
543 544 545 546 547 548 |
# File 'lib/gpgme/ctx.rb', line 543 def sign(plain, sig = Data.new, mode = GPGME::SIG_MODE_NORMAL) err = GPGME::gpgme_op_sign(self, plain, sig, mode) exc = GPGME::error_to_exception(err) raise exc if exc sig end |
#sign_result ⇒ Object
550 551 552 |
# File 'lib/gpgme/ctx.rb', line 550 def sign_result GPGME::gpgme_op_sign_result(self) end |
#spawn(file, argv, datain, dataout, dataerr, flags = 0) ⇒ Object
574 575 576 577 578 579 |
# File 'lib/gpgme/ctx.rb', line 574 def spawn(file, argv, datain, dataout, dataerr, flags = 0) err = GPGME::gpgme_op_spawn(self, file, argv, datain, dataout, dataerr, flags) exc = GPGME::error_to_exception(err) raise exc if exc end |
#textmode ⇒ Object
Return true if canonical text mode is enabled.
194 195 196 |
# File 'lib/gpgme/ctx.rb', line 194 def textmode GPGME::gpgme_get_textmode(self) == 1 ? true : false end |
#textmode=(yes) ⇒ Object
Tell whether canonical text mode should be used.
188 189 190 191 |
# File 'lib/gpgme/ctx.rb', line 188 def textmode=(yes) GPGME::gpgme_set_textmode(self, yes ? 1 : 0) yes end |
#verify(sig, signed_text = nil, plain = Data.new) ⇒ Object
Verify that the signature in the data object is a valid signature.
515 516 517 518 519 520 |
# File 'lib/gpgme/ctx.rb', line 515 def verify(sig, signed_text = nil, plain = Data.new) err = GPGME::gpgme_op_verify(self, sig, signed_text, plain) exc = GPGME::error_to_exception(err) raise exc if exc plain end |
#verify_result ⇒ Object
522 523 524 |
# File 'lib/gpgme/ctx.rb', line 522 def verify_result GPGME::gpgme_op_verify_result(self) end |