From b73216a2973890112800e4d3635943f713d9866c Mon Sep 17 00:00:00 2001 From: joss17 Date: Tue, 22 Dec 2009 12:30:13 +0000 Subject: [PATCH] use siglen -1 for both gpg2 and gpg1 verify signature git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1930 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authgpg.cc | 34 +++++--------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index a05fb2d74..8f5d17772 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -1152,7 +1152,7 @@ bool GPGAuthMgr::VerifySignature_locked(std::string id, void *data, int datalen, std::cerr << std::endl; } - if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeSig, (const char *) sig, siglen, 1)) + if (siglen != 0 && GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeSig, (const char *) sig, siglen - 1, 1)) { std::cerr << "Error create Sig"; std::cerr << std::endl; @@ -1163,35 +1163,11 @@ bool GPGAuthMgr::VerifySignature_locked(std::string id, void *data, int datalen, gpgme_set_armor (CTX, 0); gpgme_error_t ERR; - if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)) && siglen != 0) - { - ProcessPGPmeError(ERR); - std::cerr << "GPGAuthMgr::VerifySignature_locked FAILED for first try."; - std::cerr << std::endl; - - std::cerr << "GPGAuthMgr::VerifySignature_locked making another signature check with siglen - 1 (mandatory for gpg v1)." << std::endl; - - std::cerr << "VerifySignature: datalen: " << datalen << " siglen: " << (siglen - 1); + if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL))) + { + ProcessPGPmeError(ERR); + std::cerr << "GPGAuthMgr::Verify FAILED"; std::cerr << std::endl; - - if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeData, (const char *) data, datalen, 1)) - { - std::cerr << "Error create Data"; - std::cerr << std::endl; - } - - if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeSig, (const char *) sig, siglen - 1, 1)) - { - std::cerr << "Error create Sig"; - std::cerr << std::endl; - } - if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL))) - { - ProcessPGPmeError(ERR); - std::cerr << "GPGAuthMgr::VerifySignature_locked FAILED for second try."; - std::cerr << std::endl; - } - } gpgme_verify_result_t res = gpgme_op_verify_result(CTX);