gpgme (6 files)
cvs user marcus
cvs at cvs.gnupg.org
Fri Jun 3 21:20:38 CEST 2005
Date: Friday, June 3, 2005 @ 21:41:56
Author: marcus
Path: /cvs/gpgme/gpgme
Modified: NEWS doc/ChangeLog doc/gpgme.texi gpgme/ChangeLog gpgme/gpgme.h
gpgme/verify.c
doc/
2005-06-03 Marcus Brinkmann <marcus at g10code.de>
* gpgme.texi (Verify): Add information about new fields in
gpgme_signature_t.
gpgme/
2005-06-03 Marcus Brinkmann <marcus at 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.
-----------------+
NEWS | 1
doc/ChangeLog | 3 +
doc/gpgme.texi | 5 ++
gpgme/ChangeLog | 5 ++
gpgme/gpgme.h | 6 ++
gpgme/verify.c | 125 +++++++++++++++++++++++++++++++++++++++++-------------
6 files changed, 117 insertions(+), 28 deletions(-)
Index: gpgme/NEWS
diff -u gpgme/NEWS:1.142 gpgme/NEWS:1.143
--- gpgme/NEWS:1.142 Fri Jun 3 02:42:08 2005
+++ gpgme/NEWS Fri Jun 3 21:41:56 2005
@@ -24,6 +24,7 @@
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
Index: gpgme/doc/ChangeLog
diff -u gpgme/doc/ChangeLog:1.138 gpgme/doc/ChangeLog:1.139
--- gpgme/doc/ChangeLog:1.138 Fri Jun 3 02:42:08 2005
+++ gpgme/doc/ChangeLog Fri Jun 3 21:41:56 2005
@@ -1,5 +1,8 @@
2005-06-03 Marcus Brinkmann <marcus at 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 at g10code.de>
Index: gpgme/doc/gpgme.texi
diff -u gpgme/doc/gpgme.texi:1.140 gpgme/doc/gpgme.texi:1.141
--- gpgme/doc/gpgme.texi:1.140 Fri Jun 3 02:42:07 2005
+++ gpgme/doc/gpgme.texi Fri Jun 3 21:41:56 2005
@@ -3861,6 +3861,11 @@
@item gpgme_error_t validity_reason
If a signature is not valid, this provides a reason why.
+ at item gpgme_pubkey_algo_t
+The public key algorithm used to create this signature.
+
+ at item gpgme_hash_algo_t
+The hash algorithm used to create this signature.
@end table
@end deftp
Index: gpgme/gpgme/ChangeLog
diff -u gpgme/gpgme/ChangeLog:1.407 gpgme/gpgme/ChangeLog:1.408
--- gpgme/gpgme/ChangeLog:1.407 Fri Jun 3 16:23:10 2005
+++ gpgme/gpgme/ChangeLog Fri Jun 3 21:41:55 2005
@@ -1,5 +1,10 @@
2005-06-03 Marcus Brinkmann <marcus at 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.
Index: gpgme/gpgme/gpgme.h
diff -u gpgme/gpgme/gpgme.h:1.156 gpgme/gpgme/gpgme.h:1.157
--- gpgme/gpgme/gpgme.h:1.156 Fri Jun 3 02:42:07 2005
+++ gpgme/gpgme/gpgme.h Fri Jun 3 21:41:55 2005
@@ -1247,6 +1247,12 @@
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;
Index: gpgme/gpgme/verify.c
diff -u gpgme/gpgme/verify.c:1.71 gpgme/gpgme/verify.c:1.72
--- gpgme/gpgme/verify.c:1.71 Thu Apr 21 09:13:41 2005
+++ gpgme/gpgme/verify.c Fri Jun 3 21:41:55 2005
@@ -203,6 +203,7 @@
{
gpgme_signature_t sig;
char *end = strchr (args, ' ');
+ char *tail;
if (end)
{
@@ -248,39 +249,70 @@
break;
case GPGME_STATUS_ERRSIG:
- 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++;
+
+ /* 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] == ' '))
{
- int i = 0;
- /* The return code is the 6th argument, if it is 9, the
- problem is a missing key. */
- while (end && i < 4)
+ switch (end[0])
{
- end = strchr (end, ' ');
- if (end)
- end++;
- i++;
- }
- if (end && end[0] && (!end[1] || end[1] == ' '))
- {
- switch (end[0])
- {
- case '4':
- sig->status = gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
- break;
-
- case '9':
- sig->status = gpg_error (GPG_ERR_NO_PUBKEY);
- break;
-
- default:
- sig->status = gpg_error (GPG_ERR_GENERAL);
- }
+ case '4':
+ sig->status = gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
+ break;
+
+ case '9':
+ sig->status = gpg_error (GPG_ERR_NO_PUBKEY);
+ break;
+
+ default:
+ sig->status = gpg_error (GPG_ERR_GENERAL);
}
}
else
- sig->status = gpg_error (GPG_ERR_GENERAL);
- break;
+ 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:
return gpg_error (GPG_ERR_GENERAL);
}
@@ -299,7 +331,6 @@
parse_valid_sig (gpgme_signature_t sig, char *args)
{
char *end = strchr (args, ' ');
-
if (end)
{
*end = '\0';
@@ -316,6 +347,7 @@
if (!sig->fpr)
return gpg_error_from_errno (errno);
+ /* Skip the creation date. */
end = strchr (end, ' ');
if (end)
{
@@ -329,6 +361,43 @@
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;
}
More information about the Gnupg-commits
mailing list