The user is expected to write the response to the file descriptor,
followed by a newline.
- * The recipients interface has been removed and replaced by a more
- generic and light gpgme_user_ids_* interface, which only provides
- two functions: gpgme_user_ids_append adds a new user ID at the end
- of the linked list, and gpgme_user_ids_release releases all user
- IDs in the linked list. The resulting user ID object is free for
- the user to change (note however that gpgme_user_ids_release only
- releases resources allocated by GPGME).
-
- This change propagates to the prototypes of gpgme_op_encrypt,
- gpgme_op_encrypt_start, gpgme_op_encrypt_sign and
- gpgme_op_encrypt_sign_start. Also the prototypes of
- gpgme_op_export_start and gpgme_op_export finally make sense.
-
- Here is an example how to use the new interface:
-
- gpgme_user_id_t rset = NULL;
- gpgme_user_id_t *rset_lastp = &rset;
+ * The recipients interface has been removed. Instead, you use
+ NULL-terminated lists of keys for specifying the recipients of an
+ encryption operation. Use the new encryption flag
+ GPGME_ENCRYPT_ALWAYS_TRUST if you want to override the validity of
+ the keys (but note that in general this is not a good idea).
- err = gpgme_user_ids_append (rset_lastp, "Alpha");
- fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
-
- rset_lastp = &(*rset_lastp)->next;
- err = gpgme_user_ids_append (rset_lastp, "Bob");
- fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
-
- [...]
+ This change has been made to the prototypes of gpgme_op_encrypt,
+ gpgme_op_encrypt_start, gpgme_op_encrypt_sign and
+ gpgme_op_encrypt_sign_start.
- gpgme_user_ids_release (rset);
+ The export interface has been changed to use pattern strings like
+ the keylist interface. Thus, new functions gpgme_op_export_ext and
+ gpgme_op_export_ext_start have been added as well. Now the
+ prototypes of gpgme_op_export_start and gpgme_op_export finally
+ make sense.
* gpgme_op_verify and gpgme_op_decrypt_verify don't return a status
summary anymore. Use gpgme_get_sig_status to retrieve the individual
gpgme_wait CHANGED: Can return NULL even if hang is true.
GpgmeIdleFunc REMOVED
gpgme_register_idle REMOVED
-GpgmeRecipients REMOVED: Use gpgme_user_id_t.
-gpgme_recipients_new REMOVED: Initialize gpgme_user_id_t with NULL.
-gpgme_recipients_release REMOVED: Use gpgme_user_ids_release.
-gpgme_recipients_add_name REMOVED: Use gpgme_user_ids_append
-gpgme_recipients_add_name_with_validity REMOVED: Set validity directly.
-gpgme_recipients_count REMOVED: You can count them yourself.
-gpgme_recipients_enum_open REMOVED: gpgme_user_id_t is a linked list.
-gpgme_recipients_enum_read REMOVED: See gpgme_recipients_enum_open.
-gpgme_recipients_enum_close REMOVED: See gpgme_recipients_enum_read.
-gpgme_user_ids_append NEW
-gpgme_user_ids_release NEW
-gpgme_op_encrypt CHANGED: Recipients passed as gpgme_user_id_t.
-gpgme_op_encrypt_start CHANGED: Recipients passed as gpgme_user_id_t.
-gpgme_op_encrypt_sign CHANGED: Recipients passed as gpgme_user_id_t.
-gpgme_op_encrypt_sign_start CHANGED: Recipients passed as gpgme_user_id_t.
-gpgme_op_export_start CHANGED: User IDs passed as gpgme_user_id_t.
-gpgme_op_export CHANGED: User IDs passed as gpgme_user_id_t.
+GpgmeRecipients REMOVED
+gpgme_recipients_new REMOVED
+gpgme_recipients_release REMOVED
+gpgme_recipients_add_name REMOVED
+gpgme_recipients_add_name_with_validity REMOVED
+gpgme_recipients_count REMOVED
+gpgme_recipients_enum_open REMOVED
+gpgme_recipients_enum_read REMOVED
+gpgme_recipients_enum_close REMOVED
+gpgme_encrypt_flags_t NEW
+GPGME_ENCRYPT_ALWAYS_TRUST NEW
+gpgme_op_encrypt CHANGED: Recipients passed as gpgme_key_t[].
+gpgme_op_encrypt_start CHANGED: Recipients passed as gpgme_key_t[].
+gpgme_op_encrypt_sign CHANGED: Recipients passed as gpgme_key_t[].
+gpgme_op_encrypt_sign_start CHANGED: Recipients passed as gpgme_key_t[].
+gpgme_op_export_start CHANGED: User IDs passed as patterns.
+gpgme_op_export CHANGED: User IDs passed as patterns.
+gpgme_op_export_ext_start NEW
+gpgme_op_export_ext NEW
+gpgme_keylist_mode_t NEW
+gpgme_sigsum_t NEW
gpgme_engine_info_t NEW
gpgme_get_engine_info CHANGED: Return info structure instead XML.
gpgme_get_protocol_name NEW
+2003-05-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpgme.texi (Exporting Keys): Change and document prototypes.
+ Add new gpgme_op_export_ext and gpgme_op_export_ext_start
+ variants.
+ (Selecting Recipients): Section removed.
+ (Encrypting a Plaintext): Change prototypes and document the
+ changes.
+
2003-05-28 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Exporting Keys): Change argument type from
Encrypt
-* Selecting Recipients:: How to choose the recipients.
* Encrypting a Plaintext:: How to encrypt a plaintext.
Run Control
@cindex key listing mode
@cindex key listing, mode of
-@deftypefun void gpgme_set_keylist_mode (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{mode}})
+@deftypefun void gpgme_set_keylist_mode (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_keylist_mode_t @var{mode}})
The function @code{gpgme_set_keylist_mode} changes the default
behaviour of the key listing functions. The value in @var{mode} is a
bitwise-or combination of one or multiple of the following bit values:
@end deftypefun
-@deftypefun int gpgme_get_keylist_mode (@w{gpgme_ctx_t @var{ctx}})
+@deftypefun gpgme_keylist_mode_t gpgme_get_keylist_mode (@w{gpgme_ctx_t @var{ctx}})
The function @code{gpgme_get_keylist_mode} returns the current key
listing mode of the context @var{ctx}. This value can then be
modified and used in a subsequent @code{gpgme_set_keylist_mode}
@cindex key, export
@cindex key ring, export from
-@deftypefun gpgme_error_t gpgme_op_export (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_user_id_t @var{uids}}, @w{gpgme_data_t @var{keydata}})
-The function @code{gpgme_op_export} extracts the public keys of the
-user IDs in @var{uids} and returns them in the data buffer
-@var{keydata}. The type of the public keys returned is determined by
-the @acronym{ASCII} armor attribute set for the context @var{ctx}.
+@deftypefun gpgme_error_t gpgme_op_export (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}})
+The function @code{gpgme_op_export} extracts public keys and returns
+them in the data buffer @var{keydata}. The output format of the key
+data returned is determined by the @acronym{ASCII} armor attribute set
+for the context @var{ctx}.
+
+If @var{pattern} is @code{NULL}, all available keys are returned.
+Otherwise, @var{pattern} contains an engine specific expression that
+is used to limit the list to all keys matching the pattern.
+
+@var{reserved} is reserved for future use and must be @code{0}.
The function returns @code{GPGME_No_Error} if the operation completed
-successfully, @code{GPGME_Invalid_Value} if @var{uids} is
-@code{NULL} or @var{keydata} is not a valid empty data buffer, and
-passes through any errors that are reported by the crypto engine
-support routines.
+successfully, @code{GPGME_Invalid_Value} if @var{keydata} is not a
+valid empty data buffer, and passes through any errors that are
+reported by the crypto engine support routines.
@end deftypefun
-@deftypefun gpgme_error_t gpgme_op_export_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_user_id_t @var{uids}}, @w{gpgme_data_t @var{keydata}})
+@deftypefun gpgme_error_t gpgme_op_export_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}})
The function @code{gpgme_op_export_start} initiates a
@code{gpgme_op_export} operation. It can be completed by calling
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
The function returns @code{GPGME_No_Error} if the operation could be
-started successfully, and @code{GPGME_Invalid_Value} if
-@var{uids} is @code{NULL} or @var{keydata} is not a valid empty
-data buffer.
+started successfully, and @code{GPGME_Invalid_Value} if @var{keydata}
+is not a valid empty data buffer.
+@end deftypefun
+
+@deftypefun gpgme_error_t gpgme_op_export_ext (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}})
+The function @code{gpgme_op_export} extracts public keys and returns
+them in the data buffer @var{keydata}. The output format of the key
+data returned is determined by the @acronym{ASCII} armor attribute set
+for the context @var{ctx}.
+
+If @var{pattern} or @var{*pattern} is @code{NULL}, all available keys
+are returned. Otherwise, @var{pattern} is a @code{NULL} terminated
+array of strings that are used to limit the list to all keys matching
+at least one of the patterns verbatim.
+
+@var{reserved} is reserved for future use and must be @code{0}.
+
+The function returns @code{GPGME_No_Error} if the operation completed
+successfully, @code{GPGME_Invalid_Value} if @var{keydata} is not a
+valid empty data buffer, and passes through any errors that are
+reported by the crypto engine support routines.
+@end deftypefun
+
+@deftypefun gpgme_error_t gpgme_op_export_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}})
+The function @code{gpgme_op_export_ext_start} initiates a
+@code{gpgme_op_export_ext} operation. It can be completed by calling
+@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
+
+The function returns @code{GPGME_No_Error} if the operation could be
+started successfully, and @code{GPGME_Invalid_Value} if @var{keydata}
+is not a valid empty data buffer.
@end deftypefun
This is a pointer to the next new signature structure in the linked
list, or @code{NULL} if this is the last element.
-@item unsigned int summary;
+@item gpgme_sigsum_t summary;
This is a bit vector giving a summary of the signature status. It
provides an easy interface to a defined semantic of the signature
status. Checking just one bit is sufficient to see whether a
and then passed to the encryption operation.
@menu
-* Selecting Recipients:: How to choose the recipients.
* Encrypting a Plaintext:: How to encrypt a plaintext.
@end menu
-@node Selecting Recipients
-@subsubsection Selecting Recipients
-@cindex encryption, selecting recipients
-@cindex recipients
-
-@deftypefun gpgme_error_t gpgme_user_ids_append (@w{gpgme_user_id_t *@var{rset_p}}, @w{const char *@var{name}})
-The function @code{gpgme_user_ids_append} creates a new
-@code{gpgme_user_id_t} object, initializes its @code{uid} member with
-a copy of the string pointed to by @var{name}, initializes its
-@code{name}, @code{email}, @code{comment} members to the empty string,
-its @code{validity} member to @code{GPGME_VALIDITY_UNKNOWN} and leaves
-all other fields to 0.
-
-It then appends the user ID at the end of the linked list of user IDs
-that starts at *@var{rset_p}, or it returns it in *@var{rset_p} if
-that is @code{NULL}. You can then update for example the validity
-information in the user ID directly.
-
-We recommend that you keep a pointer to the last element in your
-linked list. This is faster and allows you to easily update the
-fields of the last user ID. Here is an example how to create a linked
-list of user IDs in @var{rset} with full validity from a
-@code{NULL}-terminated array of names:
-
-@example
- const char *names[] = @{ "Alpha", "Bob", NULL @};
- gpgme_error_t err;
- gpgme_user_id_t rset = NULL;
- gpgme_user_id_t *rset_lastp = &rset;
-
- do
- @{
- err = gpgme_user_ids_append (rset_lastp, *(names++));
- if (!err)
- @{
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
- rset_lastp = &(*rset_lastp)->next;
- @}
- @}
- while (!err && *names);
-@end example
-
-The function returns @code{GPGME_No_Error} if the recipient set could
-be created successfully, and @code{GPGME_Out_Of_Core} if not enough
-memory was available.
-@end deftypefun
-
-@deftypefun void gpgme_user_ids_release (@w{gpgme_user_id_t @var{uids}})
-The function @code{gpgme_user_ids_release} destroys the linked list of
-user IDs @var{uids} and releases all associated resources allocated by
-@acronym{GPGME}..
-@end deftypefun
-
-
@node Encrypting a Plaintext
@subsubsection Encrypting a Plaintext
-@deftypefun gpgme_error_t gpgme_op_encrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_user_id_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
+@deftypefun gpgme_error_t gpgme_op_encrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
The function @code{gpgme_op_encrypt} encrypts the plaintext in the data
-object @var{plain} for the recipients @var{rset} and stores the
+object @var{plain} for the recipients @var{recp} and stores the
ciphertext in the data object @var{cipher}. The type of the
ciphertext created is determined by the @acronym{ASCII} armor and text
mode attributes set for the context @var{ctx}.
-If @code{GPGME_Invalid_UserID} is returned, some recipients in
-@var{rset} are invalid, but not all. In this case the plaintext is
-encrypted for all valid recipients and returned in @var{cipher}. More
-information about the invalid recipients is available with
+@var{key} must be a @code{NULL}-terminated array of keys. The user
+must keep references for all keys during the whole duration of the
+call (but see @code{gpgme_op_encrypt_start} for the requirements with
+the asynchronous variant).
+
+The value in @var{flags} is a bitwise-or combination of one or
+multiple of the following bit values:
+
+@table @code
+@item GPGME_ENCRYPT_ALWAYS_TRUST
+The @code{GPGME_ENCRYPT_ALWAYS_TRUST} symbol specifies that all the
+recipients in @var{recp} should be trusted, even if the keys do not
+have a high enough validity in the keyring. This flag should be used
+with care; in general it is not a good idea to use any untrusted keys.
+@end table
+
+If @code{GPGME_Invalid_Key} is returned, some recipients in @var{recp}
+are invalid, but not all. In this case the plaintext might be
+encrypted for all valid recipients and returned in @var{cipher} (if
+this happens depends on the crypto engine). More information about
+the invalid recipients is available with
@code{gpgme_op_encrypt_result}.
If @var{recp} is @code{NULL}, symmetric rather than public key
The function returns @code{GPGME_No_Error} if the ciphertext could be
created successfully, @code{GPGME_Invalid_Value} if @var{ctx},
-@var{rset}, @var{plain} or @var{cipher} is not a valid pointer,
-@code{GPGME_No_UserID} if @var{rset} does not contain any valid
-recipients, @code{GPGME_Invalid_UserID} if @var{rset} contains some
-invalid recipients, @code{GPGME_Bad_Passphrase} if the passphrase for
-the secret key could not be retrieved, and passes through any errors
-that are reported by the crypto engine support routines.
+@var{recp}, @var{plain} or @var{cipher} is not a valid pointer,
+@code{GPGME_Invalid_Key} if @var{recp} contains some invalid
+recipients, @code{GPGME_Bad_Passphrase} if the passphrase for the
+secret key could not be retrieved, and passes through any errors that
+are reported by the crypto engine support routines.
@end deftypefun
-@deftypefun gpgme_error_t gpgme_op_encrypt_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_user_id_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
+@deftypefun gpgme_error_t gpgme_op_encrypt_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
The function @code{gpgme_op_encrypt_start} initiates a
@code{gpgme_op_encrypt} operation. It can be completed by calling
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
+References to the keys only need to be held for the duration of this
+call. The user can release its references to the keys after this
+function returns, even if the operation is not yet finished.
+
The function returns @code{GPGME_No_Error} if the operation could be
started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
@var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and
@end deftypefun
-@deftypefun gpgme_error_t gpgme_op_encrypt_sign (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_user_id_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
+@deftypefun gpgme_error_t gpgme_op_encrypt_sign (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
The function @code{gpgme_op_encrypt_sign} does a combined encrypt and
sign operation. It is used like @code{gpgme_op_encrypt}, but the
ciphertext also contains signatures for the signers listed in
for the OpenPGP crypto engine.
@end deftypefun
-@deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_user_id_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
+@deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
The function @code{gpgme_op_encrypt_sign_start} initiates a
@code{gpgme_op_encrypt_sign} operation. It can be completed by
calling @code{gpgme_wait} on the context. @xref{Waiting For
Completion}.
The function returns @code{GPGME_No_Error} if the operation could be
-started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
-@var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and
-@code{GPGME_No_UserID} if @var{rset} does not contain any valid
-recipients.
+started successfully, and @code{GPGME_Invalid_Value} if @var{ctx},
+@var{rset}, @var{plain} or @var{cipher} is not a valid pointer.
@end deftypefun
+2003-05-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpgme.h (gpgme_op_export_start): Change second arg to const char *.
+ (gpgme_op_export): Likewise.
+ (gpgme_op_export_ext_start): New prototype.
+ (gpgme_op_export_ext): Likewise.
+ * engine.h: Likewise for _gpgme_engine_op_export and
+ _gpgme_engine_op_export_ext.
+ * engine-backend.h (struct engine_ops): Change second argument of
+ prototype of export to const char *, and add reserverd int as
+ third argument. Add prototype for export_ext.
+ * engine.c (_gpgme_engine_op_export_ext): New function.
+ (_gpgme_engine_op_export): Change second argument of prototype of
+ export to const char *, and add reserverd int as third argument.
+ * rungpg.c (gpg_export): Change second argument of prototype of
+ export to const char *, and add reserverd int as third argument.
+ (gpg_export_ext): New function.
+ (gpg_keylist_ext): Break loop at error.
+ (_gpgme_engine_ops_gpg): Add gpg_export_ext.
+ * engine-gpgsm.c (gpgsm_export): Change second argument of
+ prototype of export to const char *, and add reserverd int as
+ third argument.
+ (gpgsm_export_ext): New function.
+ (_gpgme_engine_ops_gpgsm): Add gpgsm_export_ext.
+ * export.c (export_start): Change second argument of prototype of
+ export to const char *, and add reserverd int as third argument.
+ (gpgme_op_export_start): Likewise.
+ (export_ext_start): New function.
+ (gpgme_op_export_ext_start): Likewise.
+ (gpgme_op_export_ext): Likewise.
+
+ * gpgme.h (gpgme_keylist_mode_t): New type for anonymous enum.
+ (gpgme_sigsum_t): New type for anonymous enum.
+
+ * encrypt-sign.c (encrypt_sign_start): Check for errors earlier,
+ and return an error if RECP is not set.
+
+ * Makefile.am (libgpgme_la_SOURCES): Remove user-id.c.
+ * user-id.c: Remove file.
+ * ops.h: Remove prototype for _gpgme_user_ids_all_valid.
+ * gpgme.h (gpgme_encrypt_flags_t): New type.
+ (gpgme_op_encrypt_start): Change second parameter to type
+ gpgme_key_t[], and add third parameter.
+ (gpgme_op_encrypt): Likewise.
+ (gpgme_op_encrypt_sign_start): Likewise.
+ (gpgme_op_encrypt_sign): Likewise.
+ * encrypt.c (encrypt_start): Likewise.
+ (gpgme_op_encrypt_start): Likewise.
+ (gpgme_op_encrypt): Likewise. Pass flags to engine.
+ * encrypt-sign.c (encrypt_sign_start): Likewise.
+ (gpgme_op_encrypt_sign_start): Likewise.
+ (gpgme_op_encrypt_sign): Likewise.
+ * engine-backend.h (struct engine_ops): Likewise for prototypes of
+ encrypt and encrypt_sign.
+ * engine.h: Likewise for prototypes of _gpgme_engine_op_encrypt
+ and _gpgme_engine_op_encrypt_sign.
+ * engine.c (_gpgme_engine_op_encrypt): Likewise.
+ (_gpgme_engine_op_encrypt_sign): Likewise.
+ * rungpg.c (gpg_encrypt): Likewise.
+ (gpg_encrypt_sign): Likewise.
+ * rungpg.c (gpg_encrypt): Check flags for always trust option.
+ * engine-gpgsm.c (gpgsm_encrypt): Likewise.
+ (set_recipients): Rewritten to use keys instead user IDs.
+ * rungpg.c (append_args_from_recipients): Rewritten to use keys
+ instead user IDs.
+ * encrypt.c (_gpgme_encrypt_status_handler): Change errors
+ returned to GPGME_Invalid_Key and GPGME_General_Error.
+
2003-05-28 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c: Rename GpgsmObject to engine_gpgsm_t.
gpgme.h util.h conversion.c context.h ops.h \
data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \
data-compat.c \
- user-id.c signers.c \
+ signers.c \
wait.c wait-global.c wait-private.c wait-user.c wait.h \
op-support.c \
encrypt.c encrypt-sign.c decrypt.c decrypt-verify.c verify.c \
unsigned int use_textmode : 1;
/* Flags for keylist mode. */
- unsigned int keylist_mode;
+ gpgme_keylist_mode_t keylist_mode;
/* Number of certs to be included. */
unsigned int include_certs;
static gpgme_error_t
-encrypt_sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_user_id_t recp,
+encrypt_sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
gpgme_error_t err;
if (err)
return err;
+ if (!plain)
+ return GPGME_No_Data;
+ if (!cipher || !recp)
+ return GPGME_Invalid_Value;
+
err = _gpgme_op_encrypt_init_result (ctx);
if (err)
return err;
if (err)
return err;
- if (!plain)
- return GPGME_No_Data;
- if (!cipher)
- return GPGME_Invalid_Value;
-
if (ctx->passphrase_cb)
{
- err = _gpgme_engine_set_command_handler (ctx->engine,
- _gpgme_passphrase_command_handler,
- ctx, NULL);
+ err = _gpgme_engine_set_command_handler
+ (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
if (err)
return err;
}
_gpgme_engine_set_status_handler (ctx->engine,
encrypt_sign_status_handler, ctx);
- return _gpgme_engine_op_encrypt_sign (ctx->engine, recp, plain, cipher,
- ctx->use_armor, ctx /* FIXME */);
+ return _gpgme_engine_op_encrypt_sign (ctx->engine, recp, flags, plain,
+ cipher, ctx->use_armor,
+ ctx /* FIXME */);
}
store the resulting ciphertext in CIPHER. Also sign the ciphertext
with the signers in CTX. */
gpgme_error_t
-gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx, gpgme_user_id_t recp,
- gpgme_data_t plain, gpgme_data_t cipher)
+gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain, gpgme_data_t cipher)
{
- return encrypt_sign_start (ctx, 0, recp, plain, cipher);
+ return encrypt_sign_start (ctx, 0, recp, flags, plain, cipher);
}
store the resulting ciphertext in CIPHER. Also sign the ciphertext
with the signers in CTX. */
gpgme_error_t
-gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_user_id_t recp,
+gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- gpgme_error_t err = encrypt_sign_start (ctx, 1, recp, plain, cipher);
+ gpgme_error_t err = encrypt_sign_start (ctx, 1, recp, flags, plain, cipher);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
{
case GPGME_STATUS_EOF:
if (opd->result.invalid_recipients)
- return GPGME_Invalid_UserID;
+ return GPGME_Invalid_Key;
break;
case GPGME_STATUS_INV_RECP:
case GPGME_STATUS_NO_RECP:
/* Should not happen, because we require at least one recipient. */
- return GPGME_No_UserID;
+ return GPGME_General_Error;
default:
break;
static gpgme_error_t
-encrypt_start (gpgme_ctx_t ctx, int synchronous, gpgme_user_id_t recp,
+encrypt_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
gpgme_error_t err;
return GPGME_No_Data;
if (!cipher)
return GPGME_Invalid_Value;
+ if (recp && ! *recp)
+ return GPGME_Invalid_Value;
if (symmetric && ctx->passphrase_cb)
{
: encrypt_status_handler,
ctx);
- return _gpgme_engine_op_encrypt (ctx->engine, recp, plain, cipher,
+ return _gpgme_engine_op_encrypt (ctx->engine, recp, flags, plain, cipher,
ctx->use_armor);
}
gpgme_error_t
-gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_user_id_t recp,
+gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- return encrypt_start (ctx, 0, recp, plain, cipher);
+ return encrypt_start (ctx, 0, recp, flags, plain, cipher);
}
/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
store the resulting ciphertext in CIPHER. */
gpgme_error_t
-gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_user_id_t recp,
+gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- gpgme_error_t err = encrypt_start (ctx, 1, recp, plain, cipher);
+ gpgme_error_t err = encrypt_start (ctx, 1, recp, flags, plain, cipher);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
gpgme_error_t (*delete) (void *engine, gpgme_key_t key, int allow_secret);
gpgme_error_t (*edit) (void *engine, gpgme_key_t key, gpgme_data_t out,
gpgme_ctx_t ctx /* FIXME */);
- gpgme_error_t (*encrypt) (void *engine, gpgme_user_id_t recp,
+ gpgme_error_t (*encrypt) (void *engine, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t ciph,
int use_armor);
- gpgme_error_t (*encrypt_sign) (void *engine, gpgme_user_id_t recp,
+ gpgme_error_t (*encrypt_sign) (void *engine, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t ciph,
int use_armor, gpgme_ctx_t ctx /* FIXME */);
- gpgme_error_t (*export) (void *engine, gpgme_user_id_t uids,
- gpgme_data_t keydata, int use_armor);
+ gpgme_error_t (*export) (void *engine, const char *pattern,
+ unsigned int reserved, gpgme_data_t keydata,
+ int use_armor);
+ gpgme_error_t (*export_ext) (void *engine, const char *pattern[],
+ unsigned int reserved, gpgme_data_t keydata,
+ int use_armor);
gpgme_error_t (*genkey) (void *engine, gpgme_data_t help_data, int use_armor,
gpgme_data_t pubkey, gpgme_data_t seckey);
gpgme_error_t (*import) (void *engine, gpgme_data_t keydata);
gpgme_error_t (*keylist) (void *engine, const char *pattern,
- int secret_only, int keylist_mode);
+ int secret_only, gpgme_keylist_mode_t mode);
gpgme_error_t (*keylist_ext) (void *engine, const char *pattern[],
int secret_only, int reserved,
- int keylist_mode);
+ gpgme_keylist_mode_t mode);
gpgme_error_t (*sign) (void *engine, gpgme_data_t in, gpgme_data_t out,
gpgme_sig_mode_t mode, int use_armor,
int use_textmode,
static gpgme_error_t
-set_recipients (engine_gpgsm_t gpgsm, gpgme_user_id_t uid)
+set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[])
{
- gpgme_error_t err;
+ gpgme_error_t err = 0;
ASSUAN_CONTEXT ctx = gpgsm->assuan_ctx;
char *line;
int linelen;
int invalid_recipients = 0;
+ int i = 0;
linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */
line = malloc (10 + 40 + 1);
if (!line)
return GPGME_Out_Of_Core;
strcpy (line, "RECIPIENT ");
- while (uid)
+ while (!err && recp[i])
{
- int newlen = 11 + strlen (uid->uid);
+ char *fpr;
+
+ if (!recp[i]->subkeys || !recp[i]->subkeys->fpr)
+ {
+ invalid_recipients++;
+ continue;
+ }
+ fpr = recp[i]->subkeys->fpr;
+
+ int newlen = 11 + strlen (fpr);
if (linelen < newlen)
{
char *newline = realloc (line, newlen);
line = newline;
linelen = newlen;
}
- strcpy (&line[10], uid->uid);
-
+ strcpy (&line[10], fpr);
+
err = gpgsm_assuan_simple_command (ctx, line, gpgsm->status.fnc,
gpgsm->status.fnc_value);
if (err == GPGME_Invalid_Key)
- invalid_recipients = 1;
+ invalid_recipients++;
else if (err)
{
free (line);
return err;
}
- uid = uid->next;
+ i++;
}
free (line);
- return invalid_recipients ? GPGME_Invalid_UserID : 0;
+ return invalid_recipients ? GPGME_Invalid_Key : 0;
}
static gpgme_error_t
-gpgsm_encrypt (void *engine, gpgme_user_id_t recp, gpgme_data_t plain,
- gpgme_data_t ciph, int use_armor)
+gpgsm_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain, gpgme_data_t ciph, int use_armor)
{
engine_gpgsm_t gpgsm = engine;
gpgme_error_t err;
static gpgme_error_t
-gpgsm_export (void *engine, gpgme_user_id_t uid, gpgme_data_t keydata,
- int use_armor)
+gpgsm_export (void *engine, const char *pattern, unsigned int reserved,
+ gpgme_data_t keydata, int use_armor)
{
engine_gpgsm_t gpgsm = engine;
gpgme_error_t err = 0;
- char *cmd = NULL;
- int cmdi;
- int cmdlen = 32;
+ char *cmd;
- if (!gpgsm)
+ if (!gpgsm || reserved)
return GPGME_Invalid_Value;
- cmd = malloc (cmdlen);
+ if (!pattern)
+ pattern = "";
+
+ cmd = malloc (7 + strlen (pattern) + 1);
if (!cmd)
return GPGME_Out_Of_Core;
- strcpy (cmd, "EXPORT");
- cmdi = 6;
+ strcpy (cmd, "EXPORT ");
+ strcpy (&cmd[7], pattern);
+
+ gpgsm->output_cb.data = keydata;
+ err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,
+ use_armor ? "--armor" : 0);
+ if (err)
+ return err;
+ _gpgme_io_close (gpgsm->input_cb.fd);
+ _gpgme_io_close (gpgsm->message_cb.fd);
+
+ err = start (gpgsm, cmd);
+ free (cmd);
+ return err;
+}
- while (!err && uid)
+
+static gpgme_error_t
+gpgsm_export_ext (void *engine, const char *pattern[], unsigned int reserved,
+ gpgme_data_t keydata, int use_armor)
+{
+ engine_gpgsm_t gpgsm = engine;
+ gpgme_error_t err = 0;
+ char *line;
+ /* Length is "EXPORT " + p + '\0'. */
+ int length = 7 + 1;
+ char *linep;
+
+ if (!gpgsm || reserved)
+ return GPGME_Invalid_Value;
+
+ if (pattern && *pattern)
{
- int uidlen = strlen (uid->uid);
- /* New string is old string + ' ' + s + '\0'. */
- if (cmdlen < cmdi + 1 + uidlen + 1)
+ const char **pat = pattern;
+
+ while (*pat)
{
- char *newcmd = realloc (cmd, cmdlen * 2);
- if (!newcmd)
+ const char *patlet = *pat;
+
+ while (*patlet)
{
- free (cmd);
- return GPGME_Out_Of_Core;
+ length++;
+ if (*patlet == '%' || *patlet == ' ' || *patlet == '+')
+ length += 2;
+ patlet++;
}
- cmd = newcmd;
- cmdlen *= 2;
+ pat++;
+ /* This will allocate one byte more than necessary. */
+ length++;
}
- cmd[cmdi++] = ' ';
- strcpy (cmd + cmdi, uid->uid);
- cmdi += uidlen;
- uid = uid->next;
}
- if (err)
- return err;
+ line = malloc (length);
+ if (!line)
+ return GPGME_Out_Of_Core;
+
+ strcpy (line, "EXPORT ");
+ linep = &line[7];
+
+ if (pattern && *pattern)
+ {
+ while (*pattern)
+ {
+ const char *patlet = *pattern;
+
+ while (*patlet)
+ {
+ switch (*patlet)
+ {
+ case '%':
+ *(linep++) = '%';
+ *(linep++) = '2';
+ *(linep++) = '5';
+ break;
+ case ' ':
+ *(linep++) = '%';
+ *(linep++) = '2';
+ *(linep++) = '0';
+ break;
+ case '+':
+ *(linep++) = '%';
+ *(linep++) = '2';
+ *(linep++) = 'B';
+ break;
+ default:
+ *(linep++) = *patlet;
+ break;
+ }
+ patlet++;
+ }
+ pattern++;
+ }
+ }
+ *linep = '\0';
gpgsm->output_cb.data = keydata;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,
_gpgme_io_close (gpgsm->input_cb.fd);
_gpgme_io_close (gpgsm->message_cb.fd);
- err = start (gpgsm, cmd);
- free (cmd);
+ err = start (gpgsm, line);
+ free (line);
return err;
}
static gpgme_error_t
gpgsm_keylist (void *engine, const char *pattern, int secret_only,
- int keylist_mode)
+ gpgme_keylist_mode_t mode)
{
engine_gpgsm_t gpgsm = engine;
char *line;
gpgme_error_t err;
+ int list_mode = 0;
+
+ if (mode & GPGME_KEYLIST_MODE_LOCAL)
+ list_mode |= 1;
+ if (mode & GPGME_KEYLIST_MODE_EXTERN)
+ list_mode |= 2;
if (!pattern)
pattern = "";
- if (asprintf (&line, "OPTION list-mode=%d", (keylist_mode & 3)) < 0)
+ if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
return GPGME_Out_Of_Core;
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
free (line);
static gpgme_error_t
gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
- int reserved, int keylist_mode)
+ int reserved, gpgme_keylist_mode_t mode)
{
engine_gpgsm_t gpgsm = engine;
char *line;
/* Length is "LISTSECRETKEYS " + p + '\0'. */
int length = 15 + 1;
char *linep;
-
+ int list_mode = 0;
+
if (reserved)
return GPGME_Invalid_Value;
- if (asprintf (&line, "OPTION list-mode=%d", (keylist_mode & 3)) < 0)
+ if (mode & GPGME_KEYLIST_MODE_LOCAL)
+ list_mode |= 1;
+ if (mode & GPGME_KEYLIST_MODE_EXTERN)
+ list_mode |= 2;
+
+ if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
return GPGME_Out_Of_Core;
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
free (line);
gpgsm_delete,
NULL, /* edit */
gpgsm_encrypt,
- NULL,
+ NULL, /* encrypt_sign */
gpgsm_export,
+ gpgsm_export_ext,
gpgsm_genkey,
gpgsm_import,
gpgsm_keylist,
gpgme_error_t
-_gpgme_engine_op_encrypt (engine_t engine, gpgme_user_id_t recp,
+_gpgme_engine_op_encrypt (engine_t engine, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t ciph, int use_armor)
{
if (!engine)
if (!engine->ops->encrypt)
return GPGME_Not_Implemented;
- return (*engine->ops->encrypt) (engine->engine, recp, plain, ciph,
+ return (*engine->ops->encrypt) (engine->engine, recp, flags, plain, ciph,
use_armor);
}
gpgme_error_t
-_gpgme_engine_op_encrypt_sign (engine_t engine, gpgme_user_id_t recp,
+_gpgme_engine_op_encrypt_sign (engine_t engine, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t ciph,
int use_armor, gpgme_ctx_t ctx /* FIXME */)
{
if (!engine->ops->encrypt_sign)
return GPGME_Not_Implemented;
- return (*engine->ops->encrypt_sign) (engine->engine, recp, plain, ciph,
- use_armor, ctx);
+ return (*engine->ops->encrypt_sign) (engine->engine, recp, flags,
+ plain, ciph, use_armor, ctx);
}
gpgme_error_t
-_gpgme_engine_op_export (engine_t engine, gpgme_user_id_t uids,
- gpgme_data_t keydata, int use_armor)
+_gpgme_engine_op_export (engine_t engine, const char *pattern,
+ unsigned int reserved, gpgme_data_t keydata,
+ int use_armor)
{
if (!engine)
return GPGME_Invalid_Value;
if (!engine->ops->export)
return GPGME_Not_Implemented;
- return (*engine->ops->export) (engine->engine, uids, keydata, use_armor);
+ return (*engine->ops->export) (engine->engine, pattern, reserved,
+ keydata, use_armor);
+}
+
+
+gpgme_error_t
+_gpgme_engine_op_export_ext (engine_t engine, const char *pattern[],
+ unsigned int reserved, gpgme_data_t keydata,
+ int use_armor)
+{
+ if (!engine)
+ return GPGME_Invalid_Value;
+
+ if (!engine->ops->export_ext)
+ return GPGME_Not_Implemented;
+
+ return (*engine->ops->export_ext) (engine->engine, pattern, reserved,
+ keydata, use_armor);
}
gpgme_error_t
_gpgme_engine_op_keylist (engine_t engine, const char *pattern,
- int secret_only, int keylist_mode)
+ int secret_only, gpgme_keylist_mode_t mode)
{
if (!engine)
return GPGME_Invalid_Value;
if (!engine->ops->keylist)
return GPGME_Not_Implemented;
- return (*engine->ops->keylist) (engine->engine, pattern, secret_only,
- keylist_mode);
+ return (*engine->ops->keylist) (engine->engine, pattern, secret_only, mode);
}
gpgme_error_t
_gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[],
- int secret_only, int reserved, int keylist_mode)
+ int secret_only, int reserved,
+ gpgme_keylist_mode_t mode)
{
if (!engine)
return GPGME_Invalid_Value;
return GPGME_Not_Implemented;
return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only,
- reserved, keylist_mode);
+ reserved, mode);
}
gpgme_data_t out,
gpgme_ctx_t ctx /* FIXME */);
gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
- gpgme_user_id_t recp,
+ gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t ciph,
int use_armor);
gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
- gpgme_user_id_t recp,
+ gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain,
gpgme_data_t ciph,
int use_armor,
gpgme_ctx_t ctx /* FIXME */);
-gpgme_error_t _gpgme_engine_op_export (engine_t engine,
- gpgme_user_id_t uids,
+gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
+ unsigned int reserved,
gpgme_data_t keydata, int use_armor);
+gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
+ const char *pattern[],
+ unsigned int reserved,
+ gpgme_data_t keydata,
+ int use_armor);
gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
gpgme_data_t help_data,
int use_armor, gpgme_data_t pubkey,
gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
const char *pattern,
int secret_only,
- int keylist_mode);
+ gpgme_keylist_mode_t mode);
gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
const char *pattern[],
int secret_only,
int reserved,
- int keylist_mode);
+ gpgme_keylist_mode_t mode);
gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
gpgme_data_t out, gpgme_sig_mode_t mode,
int use_armor, int use_textmode,
static gpgme_error_t
-export_start (gpgme_ctx_t ctx, int synchronous,
- gpgme_user_id_t uids, gpgme_data_t keydata)
+export_start (gpgme_ctx_t ctx, int synchronous, const char *pattern,
+ unsigned int reserved, gpgme_data_t keydata)
{
gpgme_error_t err;
- if (!keydata || !uids)
+ if (!keydata)
return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, synchronous);
_gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
- return _gpgme_engine_op_export (ctx->engine, uids, keydata, ctx->use_armor);
+ return _gpgme_engine_op_export (ctx->engine, pattern, reserved, keydata,
+ ctx->use_armor);
}
/* Export the keys listed in RECP into KEYDATA. */
gpgme_error_t
-gpgme_op_export_start (gpgme_ctx_t ctx, gpgme_user_id_t uids,
- gpgme_data_t keydata)
+gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
+ unsigned int reserved, gpgme_data_t keydata)
{
- return export_start (ctx, 0, uids, keydata);
+ return export_start (ctx, 0, pattern, reserved, keydata);
}
/* Export the keys listed in RECP into KEYDATA. */
gpgme_error_t
-gpgme_op_export (gpgme_ctx_t ctx, gpgme_user_id_t uids, gpgme_data_t keydata)
+gpgme_op_export (gpgme_ctx_t ctx, const char *pattern, unsigned int reserved,
+ gpgme_data_t keydata)
{
- gpgme_error_t err = export_start (ctx, 1, uids, keydata);
+ gpgme_error_t err = export_start (ctx, 1, pattern, reserved, keydata);
+ if (!err)
+ err = _gpgme_wait_one (ctx);
+ return err;
+}
+
+\f
+static gpgme_error_t
+export_ext_start (gpgme_ctx_t ctx, int synchronous, const char *pattern[],
+ unsigned int reserved, gpgme_data_t keydata)
+{
+ gpgme_error_t err;
+
+ if (!keydata)
+ return GPGME_Invalid_Value;
+
+ err = _gpgme_op_reset (ctx, synchronous);
+ if (err)
+ return err;
+
+ _gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
+
+ return _gpgme_engine_op_export_ext (ctx->engine, pattern, reserved, keydata,
+ ctx->use_armor);
+}
+
+
+/* Export the keys listed in RECP into KEYDATA. */
+gpgme_error_t
+gpgme_op_export_ext_start (gpgme_ctx_t ctx, const char *pattern[],
+ unsigned int reserved, gpgme_data_t keydata)
+{
+ return export_ext_start (ctx, 0, pattern, reserved, keydata);
+}
+
+
+/* Export the keys listed in RECP into KEYDATA. */
+gpgme_error_t
+gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
+ unsigned int reserved, gpgme_data_t keydata)
+{
+ gpgme_error_t err = export_ext_start (ctx, 1, pattern, reserved, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
{
gpgme_ctx_t ctx;
- if (!r_ctx)
- return GPGME_Invalid_Value;
- *r_ctx = 0;
ctx = calloc (1, sizeof *ctx);
if (!ctx)
return GPGME_Out_Of_Core;
}
-/**
- * gpgme_release:
- * @c: Context to be released.
- *
- * Release all resources associated with the given context.
- **/
+/* Release all resources associated with the given context. */
void
gpgme_release (gpgme_ctx_t ctx)
{
- if (!ctx)
- return;
_gpgme_engine_release (ctx->engine);
_gpgme_fd_table_deinit (&ctx->fdt);
_gpgme_release_result (ctx);
free (ctx);
}
+
void
_gpgme_release_result (gpgme_ctx_t ctx)
{
}
}
-/**
- * gpgme_set_armor:
- * @ctx: the context
- * @yes: boolean value to set or clear that flag
- *
- * Enable or disable the use of an ascii armor for all output.
- **/
+/* Enable or disable the use of an ascii armor for all output. */
void
gpgme_set_armor (gpgme_ctx_t ctx, int yes)
{
- if (!ctx)
- return;
ctx->use_armor = yes;
}
-/**
- * gpgme_get_armor:
- * @ctx: the context
- *
- * Return the state of the armor flag which can be changed using
- * gpgme_set_armor().
- *
- * Return value: Boolean whether armor mode is to be used.
- **/
+/* Return the state of the armor flag. */
int
gpgme_get_armor (gpgme_ctx_t ctx)
{
- return ctx && ctx->use_armor;
+ return ctx->use_armor;
}
-/**
- * gpgme_set_textmode:
- * @ctx: the context
- * @yes: boolean flag whether textmode should be enabled
- *
- * Enable or disable the use of the special textmode. Textmode is for example
- * used for the RFC2015 signatures; note that the updated RFC 3156 mandates
- * that the MUA does some preparations so that textmode is not needed anymore.
- **/
+/* Enable or disable the use of the special textmode. Textmode is for
+ example used for the RFC2015 signatures; note that the updated RFC
+ 3156 mandates that the MUA does some preparations so that textmode
+ is not needed anymore. */
void
gpgme_set_textmode (gpgme_ctx_t ctx, int yes)
{
- if (!ctx)
- return;
ctx->use_textmode = yes;
}
-/**
- * gpgme_get_textmode:
- * @ctx: the context
- *
- * Return the state of the textmode flag which can be changed using
- * gpgme_set_textmode().
- *
- * Return value: Boolean whether textmode is to be used.
- **/
+/* Return the state of the textmode flag. */
int
gpgme_get_textmode (gpgme_ctx_t ctx)
{
- return ctx && ctx->use_textmode;
+ return ctx->use_textmode;
}
-/**
- * gpgme_set_include_certs:
- * @ctx: the context
- *
- * Set the number of certifications to include in an S/MIME message.
- * The default is 1 (only the cert of the sender). -1 means all certs,
- * and -2 means all certs except the root cert.
- *
- * Return value: Boolean whether textmode is to be used.
- **/
+/* Set the number of certifications to include in an S/MIME message.
+ The default is 1 (only the cert of the sender). -1 means all
+ certs, and -2 means all certs except the root cert. */
void
gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
{
}
-/**
- * gpgme_get_include_certs:
- * @ctx: the context
- *
- * Get the number of certifications to include in an S/MIME message.
- *
- * Return value: Boolean whether textmode is to be used.
- **/
+/* Get the number of certifications to include in an S/MIME
+ message. */
int
gpgme_get_include_certs (gpgme_ctx_t ctx)
{
}
-/**
- * gpgme_set_keylist_mode:
- * @ctx: the context
- * @mode: listing mode
- *
- * This function changes the default behaviour of the keylisting
- * functions. mode is a bitwise-OR of the GPGME_KEYLIST_* flags.
- * The default mode is GPGME_KEYLIST_MODE_LOCAL.
- *
- * Return value: GPGME_Invalid_Value if ctx is not a context or mode
- * not a valid mode.
- **/
+/* This function changes the default behaviour of the keylisting
+ functions. MODE is a bitwise-OR of the GPGME_KEYLIST_* flags. The
+ default mode is GPGME_KEYLIST_MODE_LOCAL. */
gpgme_error_t
-gpgme_set_keylist_mode (gpgme_ctx_t ctx, int mode)
+gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
{
- if (!ctx)
- return GPGME_Invalid_Value;
-
if (!((mode & GPGME_KEYLIST_MODE_LOCAL)
|| (mode & GPGME_KEYLIST_MODE_EXTERN)
|| (mode & GPGME_KEYLIST_MODE_SIGS)))
return 0;
}
-
-/**
- * gpgme_get_keylist_mode:
- * @ctx: the context
- *
- * This function ch the default behaviour of the keylisting functions.
- * Defines values for @mode are: %0 = normal, %1 = fast listing without
- * information about key validity.
- *
- * Return value: 0 if ctx is not a valid context, or the current mode.
- * Note that 0 is never a valid mode.
- **/
-int
+/* This function returns the default behaviour of the keylisting
+ functions. */
+gpgme_keylist_mode_t
gpgme_get_keylist_mode (gpgme_ctx_t ctx)
{
- if (!ctx)
- return 0;
return ctx->keylist_mode;
}
-/**
- * gpgme_set_passphrase_cb:
- * @ctx: the context
- * @cb: A callback function
- * @cb_value: The value passed to the callback function
- *
- * This function sets a callback function to be used to pass a passphrase
- * to gpg. The preferred way to handle this is by using the gpg-agent, but
- * because that beast is not ready for real use, you can use this passphrase
- * thing.
- *
- * The callback function is defined as:
- * <literal>
- * typedef const char *(*gpgme_passphrase_cb_t)(void*cb_value,
- * const char *desc,
- * void **r_hd);
- * </literal>
- * and called whenever gpgme needs a passphrase. DESC will have a nice
- * text, to be used to prompt for the passphrase and R_HD is just a parameter
- * to be used by the callback it self. Because the callback returns a const
- * string, the callback might want to know when it can release resources
- * assocated with that returned string; gpgme helps here by calling this
- * passphrase callback with an DESC of %NULL as soon as it does not need
- * the returned string anymore. The callback function might then choose
- * to release resources depending on R_HD.
- *
- **/
+/* This function sets a callback function to be used to pass a
+ passphrase to gpg. */
void
gpgme_set_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb,
void *cb_value)
{
- if (ctx)
- {
- ctx->passphrase_cb = cb;
- ctx->passphrase_cb_value = cb_value;
- }
+ ctx->passphrase_cb = cb;
+ ctx->passphrase_cb_value = cb_value;
}
-/**
- * gpgme_get_passphrase_cb:
- * @ctx: the context
- * @r_cb: The current callback function
- * @r_cb_value: The current value passed to the callback function
- *
- * This function returns the callback function to be used to pass a passphrase
- * to the crypto engine.
- **/
+/* This function returns the callback function to be used to pass a
+ passphrase to the crypto engine. */
void
gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb,
void **r_cb_value)
{
- if (ctx)
- {
- if (r_cb)
- *r_cb = ctx->passphrase_cb;
- if (r_cb_value)
- *r_cb_value = ctx->passphrase_cb_value;
- }
- else
- {
- if (r_cb)
- *r_cb = NULL;
- if (r_cb_value)
- *r_cb_value = NULL;
- }
+ if (r_cb)
+ *r_cb = ctx->passphrase_cb;
+ if (r_cb_value)
+ *r_cb_value = ctx->passphrase_cb_value;
}
-/**
- * gpgme_set_progress_cb:
- * @ctx: the context
- * @cb: A callback function
- * @cb_value: The value passed to the callback function
- *
- * This function sets a callback function to be used as a progress indicator.
- *
- * The callback function is defined as:
- * <literal>
- * typedef void (*gpgme_progress_cb_t) (void *cb_value,
- * const char *what, int type,
- * int curretn, int total);
- * </literal>
- * For details on the progress events, see the entry for the PROGRESS
- * status in the file doc/DETAILS of the GnuPG distribution.
- **/
+/* This function sets a callback function to be used as a progress
+ indicator. */
void
gpgme_set_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t cb, void *cb_value)
{
- if (ctx)
- {
- ctx->progress_cb = cb;
- ctx->progress_cb_value = cb_value;
- }
+ ctx->progress_cb = cb;
+ ctx->progress_cb_value = cb_value;
}
-/**
- * gpgme_get_progress_cb:
- * @ctx: the context
- * @r_cb: The current callback function
- * @r_cb_value: The current value passed to the callback function
- *
- * This function returns the callback function to be used as a
- * progress indicator.
- **/
+/* This function returns the callback function to be used as a
+ progress indicator. */
void
gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb,
void **r_cb_value)
{
- if (ctx)
- {
- if (r_cb)
- *r_cb = ctx->progress_cb;
- if (r_cb_value)
- *r_cb_value = ctx->progress_cb_value;
- }
- else
- {
- if (r_cb)
- *r_cb = NULL;
- if (r_cb_value)
- *r_cb_value = NULL;
- }
+ if (r_cb)
+ *r_cb = ctx->progress_cb;
+ if (r_cb_value)
+ *r_cb_value = ctx->progress_cb_value;
}
-/**
- * gpgme_set_io_cbs:
- * @ctx: the context
- * @register_io_cb: A callback function
- * @register_hook_value: The value passed to the callback function
- * @remove_io_cb: Another callback function
- *
- **/
+/* Set the I/O callback functions for CTX to IO_CBS. */
void
gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
{
- if (!ctx)
- return;
-
if (io_cbs)
ctx->io_cbs = *io_cbs;
else
}
-/**
- * gpgme_get_io_cbs:
- * @ctx: the context
- * @r_register_cb: The current register callback function
- * @r_register_cb_value: The current value passed to the
- * register callback function
- * @r_remove_cb: The current remove callback function
- *
- * This function returns the callback function to be used to pass a passphrase
- * to the crypto engine.
- **/
+/* This function returns the callback function for I/O. */
void
gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
{
- if (ctx && io_cbs)
- *io_cbs = ctx->io_cbs;
+ *io_cbs = ctx->io_cbs;
}
int gpgme_get_include_certs (gpgme_ctx_t ctx);
/* The available keylist mode flags. */
-enum
+typedef enum
{
GPGME_KEYLIST_MODE_LOCAL = 1,
GPGME_KEYLIST_MODE_EXTERN = 2,
GPGME_KEYLIST_MODE_SIGS = 4
- };
+ }
+gpgme_keylist_mode_t;
/* Set keylist mode in CTX to MODE. */
-gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx, int mode);
+gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
+ gpgme_keylist_mode_t mode);
/* Get keylist mode in CTX. */
-int gpgme_get_keylist_mode (gpgme_ctx_t ctx);
+gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
/* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
passed as first argument to the passphrase callback function. */
function. */
typedef void (*gpgme_remove_io_cb_t) (void *tag);
-typedef enum { GPGME_EVENT_START,
- GPGME_EVENT_DONE,
- GPGME_EVENT_NEXT_KEY,
- GPGME_EVENT_NEXT_TRUSTITEM } gpgme_event_io_t;
+typedef enum
+ {
+ GPGME_EVENT_START,
+ GPGME_EVENT_DONE,
+ GPGME_EVENT_NEXT_KEY,
+ GPGME_EVENT_NEXT_TRUSTITEM
+ }
+gpgme_event_io_t;
/* The type of a function that is called when a context finished an
operation. */
/* Retrieve a pointer to the result of the encrypt operation. */
gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
+/* The valid encryption flags. */
+typedef enum
+ {
+ GPGME_ENCRYPT_ALWAYS_TRUST = 1
+ }
+gpgme_encrypt_flags_t;
+
/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
store the resulting ciphertext in CIPHER. */
-gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_user_id_t recp,
+gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher);
-gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_user_id_t recp,
+gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher);
/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
store the resulting ciphertext in CIPHER. Also sign the ciphertext
with the signers in CTX. */
gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
- gpgme_user_id_t recp,
+ gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain,
gpgme_data_t cipher);
-gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_user_id_t recp,
+gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher);
\f
typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
/* Flags used for the SUMMARY field in a gpgme_signature_t. */
-enum
+typedef enum
{
GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */
- };
+ }
+gpgme_sigsum_t;
struct _gpgme_signature
{
struct _gpgme_signature *next;
/* A summary of the signature status. */
- unsigned int summary;
+ gpgme_sigsum_t summary;
/* The fingerprint or key ID of the signature. */
char *fpr;
int *nr) _GPGME_DEPRECATED;
\f
-/* Export the keys listed in UIDS into KEYDATA. */
-gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, gpgme_user_id_t uids,
+/* Export the keys found by PATTERN into KEYDATA. */
+gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
+ unsigned int reserved,
gpgme_data_t keydata);
-gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, gpgme_user_id_t uids,
- gpgme_data_t keydata);
+gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
+ unsigned int reserved, gpgme_data_t keydata);
+
+gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
+ const char *pattern[],
+ unsigned int reserved,
+ gpgme_data_t keydata);
+gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
+ unsigned int reserved,
+ gpgme_data_t keydata);
\f
/* Key generation. */
gpgme_data_t out);
\f
-/* Key management functions */
+/* Key management functions. */
struct _gpgme_op_keylist_result
{
unsigned int truncated : 1;
gpgme_error_t _gpgme_wait_one (gpgme_ctx_t ctx);
gpgme_error_t _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond);
-\f
-/* From user-id.c. */
-int _gpgme_user_ids_all_valid (gpgme_user_id_t uid);
-
\f
/* From data.c. */
gpgme_error_t _gpgme_data_inbound_handler (void *opaque, int fd);
static gpgme_error_t
-append_args_from_recipients (engine_gpg_t gpg, gpgme_user_id_t uid)
+append_args_from_recipients (engine_gpg_t gpg, gpgme_key_t recp[])
{
gpgme_error_t err = 0;
+ int i = 0;
- while (uid)
+ while (recp[i])
{
- err = add_arg (gpg, "-r");
+ if (!recp[i]->subkeys || !recp[i]->subkeys->fpr)
+ err = GPGME_Invalid_Key;
+ if (!err)
+ err = add_arg (gpg, "-r");
if (!err)
- err = add_arg (gpg, uid->uid);
+ err = add_arg (gpg, recp[i]->subkeys->fpr);
if (err)
break;
- uid = uid->next;
+ i++;
}
return err;
}
static gpgme_error_t
-gpg_encrypt (void *engine, gpgme_user_id_t recp, gpgme_data_t plain,
- gpgme_data_t ciph, int use_armor)
+gpg_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain, gpgme_data_t ciph, int use_armor)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
{
/* If we know that all recipients are valid (full or ultimate trust)
we can suppress further checks. */
- if (!err && !symmetric && _gpgme_user_ids_all_valid (recp))
+ if (!err && !symmetric && (flags & GPGME_ENCRYPT_ALWAYS_TRUST))
err = add_arg (gpg, "--always-trust");
if (!err)
static gpgme_error_t
-gpg_encrypt_sign (void *engine, gpgme_user_id_t recp, gpgme_data_t plain,
+gpg_encrypt_sign (void *engine, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags, gpgme_data_t plain,
gpgme_data_t ciph, int use_armor,
gpgme_ctx_t ctx /* FIXME */)
{
err = add_arg (gpg, "--armor");
/* If we know that all recipients are valid (full or ultimate trust)
- * we can suppress further checks */
- if (!err && _gpgme_user_ids_all_valid (recp))
+ we can suppress further checks. */
+ if (!err && (flags & GPGME_ENCRYPT_ALWAYS_TRUST))
err = add_arg (gpg, "--always-trust");
if (!err)
static gpgme_error_t
-gpg_export (void *engine, gpgme_user_id_t uids, gpgme_data_t keydata,
- int use_armor)
+gpg_export (void *engine, const char *pattern, unsigned int reserved,
+ gpgme_data_t keydata, int use_armor)
+{
+ engine_gpg_t gpg = engine;
+ gpgme_error_t err;
+
+ if (reserved)
+ return GPGME_Invalid_Value;
+
+ err = add_arg (gpg, "--export");
+ if (!err && use_armor)
+ err = add_arg (gpg, "--armor");
+ if (!err)
+ err = add_data (gpg, keydata, 1, 1);
+ if (!err)
+ err = add_arg (gpg, "--");
+
+ if (!err && pattern && *pattern)
+ err = add_arg (gpg, pattern);
+
+ if (!err)
+ err = start (gpg);
+
+ return err;
+}
+
+
+static gpgme_error_t
+gpg_export_ext (void *engine, const char *pattern[], unsigned int reserved,
+ gpgme_data_t keydata, int use_armor)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
+ if (reserved)
+ return GPGME_Invalid_Value;
+
err = add_arg (gpg, "--export");
if (!err && use_armor)
err = add_arg (gpg, "--armor");
if (!err)
err = add_arg (gpg, "--");
- while (!err && uids)
+ if (pattern)
{
- err = add_arg (gpg, uids->uid);
- uids = uids->next;
+ while (!err && *pattern && **pattern)
+ err = add_arg (gpg, *(pattern++));
}
if (!err)
static gpgme_error_t
gpg_keylist (void *engine, const char *pattern, int secret_only,
- int keylist_mode)
+ gpgme_keylist_mode_t mode)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
err = add_arg (gpg, "--with-fingerprint");
if (!err)
err = add_arg (gpg, secret_only ? "--list-secret-keys"
- : ((keylist_mode & GPGME_KEYLIST_MODE_SIGS)
+ : ((mode & GPGME_KEYLIST_MODE_SIGS)
? "--check-sigs" : "--list-keys"));
/* Tell the gpg object about the data. */
static gpgme_error_t
gpg_keylist_ext (void *engine, const char *pattern[], int secret_only,
- int reserved, int keylist_mode)
+ int reserved, gpgme_keylist_mode_t mode)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
err = add_arg (gpg, "--with-fingerprint");
if (!err)
err = add_arg (gpg, secret_only ? "--list-secret-keys"
- : ((keylist_mode & GPGME_KEYLIST_MODE_SIGS)
+ : ((mode & GPGME_KEYLIST_MODE_SIGS)
? "--check-sigs" : "--list-keys"));
-
- /* Tell the gpg object about the data. */
if (!err)
err = add_arg (gpg, "--");
- if (!err && pattern && *pattern)
+
+ if (pattern)
{
- while (*pattern && **pattern)
+ while (!err && *pattern && **pattern)
err = add_arg (gpg, *(pattern++));
}
gpg_encrypt,
gpg_encrypt_sign,
gpg_export,
+ gpg_export_ext,
gpg_genkey,
gpg_import,
gpg_keylist,
+++ /dev/null
-/* user-id.c - Managing user IDs.
- Copyright (C) 2000 Werner Koch (dd9jn)
- Copyright (C) 2001, 2002, 2003 g10 Code GmbH
-
- This file is part of GPGME.
-
- GPGME is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- GPGME is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GPGME; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-
-#include <gpgme.h>
-
-\f
-/* Release the user IDs in the list UID. */
-void
-gpgme_user_ids_release (gpgme_user_id_t uid)
-{
- while (uid)
- {
- gpgme_user_id_t next_uid = uid->next;
-
- free (uid);
- uid = next_uid;
- }
-}
-
-
-/* Add the name NAME to the user ID list *UIDS_P (with unknown
- validity). */
-gpgme_error_t
-gpgme_user_ids_append (gpgme_user_id_t *uids_p, const char *name)
-{
- gpgme_user_id_t uids;
- gpgme_user_id_t uid;
-
- if (!name || !uids_p)
- return GPGME_Invalid_Value;
-
- uid = calloc (1, sizeof (*uid) + strlen (name) + 1);
- if (!uid)
- return GPGME_Out_Of_Core;
-
- uid->uid = ((char *) uid) + sizeof (*uid);
- strcpy (uid->uid, name);
- uid->name = uid->uid + strlen (name);
- uid->email = uid->name;
- uid->comment = uid->name;
- uid->validity = GPGME_VALIDITY_UNKNOWN;
-
- uids = *uids_p;
- if (uids)
- {
- while (uids->next)
- uids = uids->next;
- uids->next = uid;
- }
- else
- *uids_p = uid;
-
- return 0;
-}
-
-
-int
-_gpgme_user_ids_all_valid (gpgme_user_id_t uid)
-{
- while (uid)
- {
- if (uid->validity != GPGME_VALIDITY_FULL
- && uid->validity != GPGME_VALIDITY_ULTIMATE)
- return 0;
- uid = uid->next;
- }
- return 1;
-}
+2003-05-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpg/t-encrypt-sym.c (main): Adapt to new syntax.
+ * gpg/t-encrypt.c (main): Likewise.
+ * gpg/t-eventloop.c (main): Likewise.
+ * gpg/t-encrypt-sign.c (main): Likewise.
+ * gpgsm/t-export.c (main): Likewise.
+ * gpgsm/t-encrypt.c (main): Likewise.
+
2003-05-28 Marcus Brinkmann <marcus@g10code.de>
* gpg/t-eventloop.c (main): Rewrite recipient management.
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_data_t in, out;
- gpgme_user_id_t rset = NULL;
- gpgme_user_id_t *rset_lastp = &rset;
+ gpgme_key_t key[3] = { NULL, NULL, NULL };
gpgme_encrypt_result_t result;
gpgme_sign_result_t sign_result;
char *agent_info;
err = gpgme_data_new (&out);
fail_if_err (err);
- err = gpgme_user_ids_append (rset_lastp, "Alpha");
+ err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
+ &key[0], 0);
fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
-
- rset_lastp = &(*rset_lastp)->next;
- err = gpgme_user_ids_append (rset_lastp, "Bob");
+ err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2",
+ &key[1], 0);
fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
- err = gpgme_op_encrypt_sign (ctx, rset, in, out);
+ err = gpgme_op_encrypt_sign (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
fail_if_err (err);
result = gpgme_op_encrypt_result (ctx);
if (result->invalid_recipients)
check_result (sign_result, GPGME_SIG_MODE_NORMAL);
print_data (out);
- gpgme_user_ids_release (rset);
+ gpgme_key_unref (key[0]);
+ gpgme_key_unref (key[1]);
gpgme_data_release (in);
gpgme_data_release (out);
gpgme_release (ctx);
/* t-encrypt-sym.c - regression test
- * Copyright (C) 2000 Werner Koch (dd9jn)
- * Copyright (C) 2001, 2003 g10 Code GmbH
- *
- * This file is part of GPGME.
- *
- * GPGME is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GPGME is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ GPGME is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GPGME; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <gpgme.h>
-#define fail_if_err(a) do { if(a) { \
- fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
- __FILE__, __LINE__, gpgme_strerror(a)); \
- exit (1); } \
- } while(0)
+#define fail_if_err(err) \
+ do \
+ { \
+ if (err) \
+ { \
+ fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
+ __FILE__, __LINE__, gpgme_strerror (err)); \
+ exit (1); \
+ } \
+ } \
+ while (0)
+
static void
print_data (gpgme_data_t dh)
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
fail_if_err (err);
- do
- {
- err = gpgme_new (&ctx);
- fail_if_err (err);
- gpgme_set_armor (ctx, 1);
-
- p = getenv("GPG_AGENT_INFO");
- if (!(p && strchr (p, ':')))
- gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_armor (ctx, 1);
- err = gpgme_data_new_from_mem (&plain, text, strlen (text), 0);
- fail_if_err (err);
+ p = getenv("GPG_AGENT_INFO");
+ if (!(p && strchr (p, ':')))
+ gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
- err = gpgme_data_new (&cipher);
- fail_if_err (err);
+ err = gpgme_data_new_from_mem (&plain, text, strlen (text), 0);
+ fail_if_err (err);
- err = gpgme_op_encrypt (ctx, 0, plain, cipher);
- fail_if_err (err);
+ err = gpgme_data_new (&cipher);
+ fail_if_err (err);
- fflush (NULL);
- fputs ("Begin Result Encryption:\n", stdout);
- print_data (cipher);
- fputs ("End Result.\n", stdout);
+ err = gpgme_op_encrypt (ctx, 0, 0, plain, cipher);
+ fail_if_err (err);
- gpgme_data_seek (cipher, 0, SEEK_SET);
+ fflush (NULL);
+ fputs ("Begin Result Encryption:\n", stdout);
+ print_data (cipher);
+ fputs ("End Result.\n", stdout);
- gpgme_data_release (plain);
- err = gpgme_data_new (&plain);
- fail_if_err (err);
+ gpgme_data_seek (cipher, 0, SEEK_SET);
- err = gpgme_op_decrypt (ctx, cipher, plain);
- fail_if_err (err);
+ gpgme_data_release (plain);
+ err = gpgme_data_new (&plain);
+ fail_if_err (err);
- fputs ("Begin Result Decryption:\n", stdout);
- print_data (plain);
- fputs ("End Result.\n", stdout);
+ err = gpgme_op_decrypt (ctx, cipher, plain);
+ fail_if_err (err);
- text2 = gpgme_data_release_and_get_mem (plain, &len);
- if (strncmp (text, text2, len))
- {
- fprintf (stderr, "%s:%d: Wrong plaintext\n", __FILE__, __LINE__);
- exit (1);
- }
+ fputs ("Begin Result Decryption:\n", stdout);
+ print_data (plain);
+ fputs ("End Result.\n", stdout);
- gpgme_data_release (cipher);
- gpgme_release (ctx);
+ text2 = gpgme_data_release_and_get_mem (plain, &len);
+ if (strncmp (text, text2, len))
+ {
+ fprintf (stderr, "%s:%d: Wrong plaintext\n", __FILE__, __LINE__);
+ exit (1);
}
- while (argc > 1 && !strcmp (argv[1], "--loop"));
+
+ gpgme_data_release (cipher);
+ gpgme_release (ctx);
return 0;
}
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_data_t in, out;
- gpgme_user_id_t rset = NULL;
- gpgme_user_id_t *rset_lastp = &rset;
+ gpgme_key_t key[3] = { NULL, NULL, NULL };
gpgme_encrypt_result_t result;
+ gpgme_check_version (0);
+
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
fail_if_err (err);
err = gpgme_data_new (&out);
fail_if_err (err);
-
- err = gpgme_user_ids_append (rset_lastp, "Alpha");
- fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
- rset_lastp = &(*rset_lastp)->next;
- err = gpgme_user_ids_append (rset_lastp, "Bob");
+ err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
+ &key[0], 0);
+ fail_if_err (err);
+ err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2",
+ &key[1], 0);
fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
- err = gpgme_op_encrypt (ctx, rset, in, out);
+ err = gpgme_op_encrypt (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
fail_if_err (err);
result = gpgme_op_encrypt_result (ctx);
if (result->invalid_recipients)
}
print_data (out);
- gpgme_user_ids_release (rset);
+ gpgme_key_unref (key[0]);
+ gpgme_key_unref (key[1]);
gpgme_data_release (in);
gpgme_data_release (out);
gpgme_release (ctx);
return 0;
}
-
-
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_data_t in, out;
- gpgme_user_id_t rset = NULL;
- gpgme_user_id_t *rset_lastp = &rset;
+ gpgme_key_t key[3] = { NULL, NULL, NULL };
int i;
for (i = 0; i < FDLIST_MAX; i++)
err = gpgme_data_new (&out);
fail_if_err (err);
- err = gpgme_user_ids_append (rset_lastp, "Alpha");
+ err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
+ &key[0], 0);
fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
-
- rset_lastp = &(*rset_lastp)->next;
- err = gpgme_user_ids_append (rset_lastp, "Bob");
+ err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2",
+ &key[1], 0);
fail_if_err (err);
- (*rset_lastp)->validity = GPGME_VALIDITY_FULL;
- err = gpgme_op_encrypt_start (ctx, rset, in, out);
+ err = gpgme_op_encrypt_start (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
fail_if_err (err);
my_wait ();
print_data (out);
fputs ("End Result.\n", stdout);
- gpgme_user_ids_release (rset);
+ gpgme_key_unref (key[0]);
+ gpgme_key_unref (key[1]);
gpgme_data_release (in);
gpgme_data_release (out);
gpgme_release (ctx);
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_data_t out;
- gpgme_user_id_t uids = NULL;
- gpgme_user_id_t *uids_lastp = &uids;
+ const char *pattern[] = { "Alpha", "Bob", NULL };
err = gpgme_new (&ctx);
fail_if_err (err);
err = gpgme_data_new (&out);
fail_if_err (err);
- err = gpgme_user_ids_append (uids_lastp, "Alpha");
- fail_if_err (err);
- uids_lastp = &(*uids_lastp)->next;
-
- err = gpgme_user_ids_append (uids_lastp, "Bob");
- fail_if_err (err);
-
gpgme_set_armor (ctx, 1);
- err = gpgme_op_export (ctx, uids, out);
+ err = gpgme_op_export_ext (ctx, pattern, 0, out);
fail_if_err (err);
fflush (NULL);
print_data (out);
fputs ("End Result.\n", stdout);
- gpgme_user_ids_release (uids);
gpgme_data_release (out);
gpgme_release (ctx);
return 0;
}
-
-
gpgme_ctx_t ctx;
gpgme_error_t err;
gpgme_data_t in, out;
- gpgme_user_id_t rset = NULL;
+ gpgme_key_t key[] = { NULL, NULL };
gpgme_encrypt_result_t result;
err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS);
err = gpgme_data_new (&out);
fail_if_err (err);
- err = gpgme_user_ids_append (&rset, "test cert 1");
+ err = gpgme_get_key (ctx, "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ &key[0], 0);
fail_if_err (err);
- rset->validity = GPGME_VALIDITY_FULL;
- err = gpgme_op_encrypt (ctx, rset, in, out);
+ err = gpgme_op_encrypt (ctx, key, 0, in, out);
fail_if_err (err);
result = gpgme_op_encrypt_result (ctx);
if (result->invalid_recipients)
}
print_data (out);
- gpgme_user_ids_release (rset);
+ gpgme_key_unref (key[0]);
gpgme_data_release (in);
gpgme_data_release (out);
gpgme_release (ctx);
{
gpgme_ctx_t ctx;
gpgme_error_t err;
- gpgme_data_t out;
- gpgme_user_id_t rset = NULL;
-
+ gpgme_data_t out;
+ const char *pattern[] = { "DFN Top Level Certification Authority", NULL };
err = gpgme_new (&ctx);
fail_if_err (err);
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
err = gpgme_data_new (&out);
fail_if_err (err);
- err = gpgme_user_ids_append (&rset, "DFN Top Level Certification Authority");
- fail_if_err (err);
-
gpgme_set_armor (ctx, 1);
- err = gpgme_op_export (ctx, rset, out);
+ err = gpgme_op_export_ext (ctx, pattern, 0, out);
fail_if_err (err);
fflush (NULL);
print_data (out);
fputs ("End Result.\n", stdout);
- gpgme_user_ids_release (rset);
gpgme_data_release (out);
gpgme_release (ctx);