2005-06-03  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Verify): Add information about new fields in
	gpgme_signature_t.

gpgme/
2005-06-03  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.h (struct _gpgme_signature): New members pubkey_algo and
	hash_algo.
	* verify.c (parse_valid_sig): Parse pubkey and hash algo numbers.
	(parse_new_sig): Parse pubkey, hash algo and timestamp for ERRSIG.
This commit is contained in:
Marcus Brinkmann 2005-06-03 19:41:56 +00:00
parent e5f1dad76d
commit fcddcb674e
6 changed files with 117 additions and 28 deletions

1
NEWS
View File

@ -24,6 +24,7 @@ gpgme_set_include_certs CHANGED DEFAULT
GPGME_INCLUDE_CERTS_DEFAULT NEW
gpgme_recipient_t NEW
gpgme_decrypt_result_t EXTENDED: New field recipients.
gpgme_verify_result_t EXTENDED: New fields pubkey_algo, hash_algo.
GPGME_STATUS_SIG_SUBPACKET NEW
GPGME_STATUS_NEED_PASSPHRASE_PIN NEW
GPGME_STATUS_SC_OP_FAILURE NEW

View File

@ -1,5 +1,8 @@
2005-06-03 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Verify): Add information about new fields in
gpgme_signature_t.
* gpgme.texi (Decrypt): Add gpgme_recipient_t.
2005-05-28 Marcus Brinkmann <marcus@g10code.de>

View File

@ -3861,6 +3861,11 @@ The validity of the signature.
@item gpgme_error_t validity_reason
If a signature is not valid, this provides a reason why.
@item gpgme_pubkey_algo_t
The public key algorithm used to create this signature.
@item gpgme_hash_algo_t
The hash algorithm used to create this signature.
@end table
@end deftp

View File

@ -1,5 +1,10 @@
2005-06-03 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (struct _gpgme_signature): New members pubkey_algo and
hash_algo.
* verify.c (parse_valid_sig): Parse pubkey and hash algo numbers.
(parse_new_sig): Parse pubkey, hash algo and timestamp for ERRSIG.
(_gpgme_decrypt_status_handler): Fix last change.
* gpgme.h (struct _gpgme_recipient): New structure.

View File

@ -1247,6 +1247,12 @@ struct _gpgme_signature
gpgme_validity_t validity;
gpgme_error_t validity_reason;
/* The public key algorithm used to create the signature. */
gpgme_pubkey_algo_t pubkey_algo;
/* The hash algorithm used to create the signature. */
gpgme_hash_algo_t hash_algo;
};
typedef struct _gpgme_signature *gpgme_signature_t;

View File

@ -203,6 +203,7 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args)
{
gpgme_signature_t sig;
char *end = strchr (args, ' ');
char *tail;
if (end)
{
@ -248,19 +249,45 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_ERRSIG:
if (end)
{
int i = 0;
/* The return code is the 6th argument, if it is 9, the
problem is a missing key. */
while (end && i < 4)
{
end = strchr (end, ' ');
if (end)
/* Parse the pubkey algo. */
if (!end)
goto parse_err_sig_fail;
errno = 0;
sig->pubkey_algo = strtol (end, &tail, 0);
if (errno || end == tail || *tail != ' ')
goto parse_err_sig_fail;
end = tail;
while (*end == ' ')
end++;
i++;
}
if (end && end[0] && (!end[1] || end[1] == ' '))
/* Parse the hash algo. */
if (!*end)
goto parse_err_sig_fail;
errno = 0;
sig->hash_algo = strtol (end, &tail, 0);
if (errno || end == tail || *tail != ' ')
goto parse_err_sig_fail;
end = tail;
while (*end == ' ')
end++;
/* Skip the sig class. */
end = strchr (end, ' ');
if (!end)
goto parse_err_sig_fail;
while (*end == ' ')
end++;
/* Parse the timestamp. */
sig->timestamp = _gpgme_parse_timestamp (end, &tail);
if (sig->timestamp == -1 || end == tail || (*tail && *tail != ' '))
return gpg_error (GPG_ERR_INV_ENGINE);
end = tail;
while (*end == ' ')
end++;
/* Parse the return code. */
if (end[0] && (!end[1] || end[1] == ' '))
{
switch (end[0])
{
@ -276,9 +303,14 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args)
sig->status = gpg_error (GPG_ERR_GENERAL);
}
}
}
else
goto parse_err_sig_fail;
goto parse_err_sig_ok;
parse_err_sig_fail:
sig->status = gpg_error (GPG_ERR_GENERAL);
parse_err_sig_ok:
break;
default:
@ -299,7 +331,6 @@ static gpgme_error_t
parse_valid_sig (gpgme_signature_t sig, char *args)
{
char *end = strchr (args, ' ');
if (end)
{
*end = '\0';
@ -316,6 +347,7 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
if (!sig->fpr)
return gpg_error_from_errno (errno);
/* Skip the creation date. */
end = strchr (end, ' ');
if (end)
{
@ -329,6 +361,43 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
sig->exp_timestamp = _gpgme_parse_timestamp (end, &tail);
if (sig->exp_timestamp == -1 || end == tail || (*tail && *tail != ' '))
return gpg_error (GPG_ERR_INV_ENGINE);
end = tail;
while (*end == ' ')
end++;
/* Skip the signature version. */
end = strchr (end, ' ');
if (end)
{
while (*end == ' ')
end++;
/* Skip the reserved field. */
end = strchr (end, ' ');
if (end)
{
/* Parse the pubkey algo. */
errno = 0;
sig->pubkey_algo = strtol (end, &tail, 0);
if (errno || end == tail || *tail != ' ')
return gpg_error (GPG_ERR_INV_ENGINE);
end = tail;
while (*end == ' ')
end++;
if (*end)
{
/* Parse the hash algo. */
errno = 0;
sig->hash_algo = strtol (end, &tail, 0);
if (errno || end == tail || *tail != ' ')
return gpg_error (GPG_ERR_INV_ENGINE);
end = tail;
}
}
}
}
return 0;
}