Really thank you for all these explainations.
I've corrected my code and now error codes are more
meaningfull for me. But I
can't understand why this failed to verify. I sign and
verify and nothing
more.
result = gpgme_op_sign(context, msg,signature,
GPGME_SIG_MODE_DETACH) ;
Q_ASSERT(gpgme_err_code(result) == GPG_ERR_NO_ERROR ||
gpgme_err_code(result)
== GPG_ERR_BAD_PASSPHRASE || gpgme_err_code(result) ==
GPG_ERR_CANCELED) ;
// test
gpgme_data_rewind(signature) ;
gpgme_data_rewind(msg) ;
result = gpgme_op_verify (context, signature, msg , 0) ;
qDebug() << "verify result" <<
gpgme_err_code(result) ;
Q_ASSERT(gpgme_err_code(result) != GPG_ERR_INV_VALUE) ;
Q_ASSERT(gpgme_err_code(result) != GPG_ERR_NO_DATA) ;
Q_ASSERT(result == GPG_ERR_NO_ERROR) ;
qDebug() << "verify" ;
gpgme_verify_result_t verification =
gpgme_op_verify_result(context) ;
Q_ASSERT(verification != NULL) ;
qDebug() << "result" ;
gpgme_signature_t signatures = verification->signatures
;
Q_ASSERT(verification->signatures != NULL) ;
gpgme_error_t status = signatures->status ;
qDebug() << "status" <<
gpgme_err_code(status) ;
// test
output :
verify result 0
verify
result
status 8
signature "-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFE/XKv3r3TxDvLjIQRAi5SAKCODnDtKwtCCbfRnkXI8hd4E8VX1ACc
DGyd
kkScz6pUEiCABCYzQOI/4Yw=
=Vf9z
-----END PGP SIGNATURE-----
"
and : alf gros:~/gpl_projects/torrentlibre/tlclient$ gpg-error
8
8 = (0, 8) = (GPG_ERR_SOURCE_UNKNOWN, GPG_ERR_BAD_SIGNATURE)
= (Source
non-spécifiée, Mauvaise signature)
--
Francois Gaudin
_______________________________________________
Gnupg-devel mailing list
Gnupg-devel gnupg.org
h
ttp://lists.gnupg.org/mailman/listinfo/gnupg-devel
|