[gmime] No need for g_mime_crypto_context_verify() to take a 'digest' argument



commit c65519de636060e332d1eddad73d0c635a6e8bf8
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Sat Feb 25 14:43:35 2017 -0500

    No need for g_mime_crypto_context_verify() to take a 'digest' argument

 PORTING                              |    2 ++
 gmime/gmime-application-pkcs7-mime.c |    2 +-
 gmime/gmime-crypto-context.c         |   16 +++++++---------
 gmime/gmime-crypto-context.h         |   10 ++++------
 gmime/gmime-gpg-context.c            |    9 ++++-----
 gmime/gmime-multipart-signed.c       |    7 ++-----
 gmime/gmime-pkcs7-context.c          |    9 ++++-----
 tests/test-pgp.c                     |    3 +--
 tests/test-pkcs7.c                   |    3 +--
 9 files changed, 26 insertions(+), 35 deletions(-)
---
diff --git a/PORTING b/PORTING
index 3bb3617..f4e07e0 100644
--- a/PORTING
+++ b/PORTING
@@ -98,6 +98,8 @@ Porting from GMime 2.6 to GMime 3.0
   g_mime_crypto_context_decrypt() and so the decryot method now takes a session_key
   argument that is allowed to be NULL.
 
+- g_mime_crypto_context_verify() no longer takes a 'digest' argument.
+
 - g_mime_multipart_signed_verify() and g_mime_multipart_encrypted_decrypt() no longer
   take GMimeCryptoContext arguments. Instead, they instantiate their own contexts
   based on the protocol specified in the Content-Type header. These methods now also
diff --git a/gmime/gmime-application-pkcs7-mime.c b/gmime/gmime-application-pkcs7-mime.c
index 75c5a22..c2fddc6 100644
--- a/gmime/gmime-application-pkcs7-mime.c
+++ b/gmime/gmime-application-pkcs7-mime.c
@@ -563,7 +563,7 @@ g_mime_application_pkcs7_mime_verify (GMimeApplicationPkcs7Mime *pkcs7_mime, GMi
        g_object_unref (crlf_filter);
        
        /* decrypt the content stream */
-       if (!(signatures = g_mime_crypto_context_verify (ctx, flags, GMIME_DIGEST_ALGO_DEFAULT, ciphertext, 
NULL, filtered_stream, err))) {
+       if (!(signatures = g_mime_crypto_context_verify (ctx, flags, ciphertext, NULL, filtered_stream, 
err))) {
                g_object_unref (filtered_stream);
                g_object_unref (ciphertext);
                g_object_unref (stream);
diff --git a/gmime/gmime-crypto-context.c b/gmime/gmime-crypto-context.c
index ec84b6a..854e6d0 100644
--- a/gmime/gmime-crypto-context.c
+++ b/gmime/gmime-crypto-context.c
@@ -59,9 +59,8 @@ static int crypto_sign (GMimeCryptoContext *ctx, gboolean detach,
                        GError **err);
        
 static GMimeSignatureList *crypto_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags,
-                                         GMimeDigestAlgo digest, GMimeStream *istream,
-                                         GMimeStream *sigstream, GMimeStream *ostream,
-                                         GError **err);
+                                         GMimeStream *istream, GMimeStream *sigstream,
+                                         GMimeStream *ostream, GError **err);
        
 static int crypto_encrypt (GMimeCryptoContext *ctx, gboolean sign,
                           const char *userid, GMimeDigestAlgo digest,
@@ -391,8 +390,8 @@ g_mime_crypto_context_sign (GMimeCryptoContext *ctx, gboolean detach, const char
 
 
 static GMimeSignatureList *
-crypto_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags, GMimeDigestAlgo digest,
-              GMimeStream *istream, GMimeStream *sigstream, GMimeStream *ostream, GError **err)
+crypto_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags, GMimeStream *istream, GMimeStream *sigstream,
+              GMimeStream *ostream, GError **err)
 {
        g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED,
                     "Verifying is not supported by this crypto context");
@@ -405,7 +404,6 @@ crypto_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags, GMimeDigestAlgo
  * g_mime_crypto_context_verify:
  * @ctx: a #GMimeCryptoContext
  * @flags: a #GMimeVerifyFlags
- * @digest: digest algorithm used, if known
  * @istream: input stream
  * @sigstream: optional detached-signature stream
  * @ostream: optional output stream for use with encapsulated signature input streams
@@ -421,13 +419,13 @@ crypto_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags, GMimeDigestAlgo
  * the status of each signature or %NULL on error.
  **/
 GMimeSignatureList *
-g_mime_crypto_context_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags, GMimeDigestAlgo digest,
-                             GMimeStream *istream, GMimeStream *sigstream, GMimeStream *ostream, GError 
**err)
+g_mime_crypto_context_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags, GMimeStream *istream,
+                             GMimeStream *sigstream, GMimeStream *ostream, GError **err)
 {
        g_return_val_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx), NULL);
        g_return_val_if_fail (GMIME_IS_STREAM (istream), NULL);
        
-       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->verify (ctx, flags, digest, istream, sigstream, ostream, 
err);
+       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->verify (ctx, flags, istream, sigstream, ostream, err);
 }
 
 
diff --git a/gmime/gmime-crypto-context.h b/gmime/gmime-crypto-context.h
index 5423324..599dce9 100644
--- a/gmime/gmime-crypto-context.h
+++ b/gmime/gmime-crypto-context.h
@@ -144,9 +144,8 @@ struct _GMimeCryptoContextClass {
                                                  GError **err);
        
        GMimeSignatureList *     (* verify)      (GMimeCryptoContext *ctx, GMimeVerifyFlags flags,
-                                                 GMimeDigestAlgo digest, GMimeStream *istream,
-                                                 GMimeStream *sigstream, GMimeStream *ostream,
-                                                 GError **err);
+                                                 GMimeStream *istream, GMimeStream *sigstream,
+                                                 GMimeStream *ostream, GError **err);
        
        int                      (* encrypt)     (GMimeCryptoContext *ctx, gboolean sign,
                                                  const char *userid, GMimeDigestAlgo digest,
@@ -192,9 +191,8 @@ int g_mime_crypto_context_sign (GMimeCryptoContext *ctx, gboolean detach,
                                GError **err);
 
 GMimeSignatureList *g_mime_crypto_context_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags,
-                                                 GMimeDigestAlgo digest, GMimeStream *istream,
-                                                 GMimeStream *sigstream, GMimeStream *ostream,
-                                                 GError **err);
+                                                 GMimeStream *istream, GMimeStream *sigstream,
+                                                 GMimeStream *ostream, GError **err);
 
 int g_mime_crypto_context_encrypt (GMimeCryptoContext *ctx, gboolean sign,
                                   const char *userid, GMimeDigestAlgo digest,
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index 8f8086b..d12bd97 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -98,9 +98,8 @@ static const char *gpg_get_encryption_protocol (GMimeCryptoContext *ctx);
 static const char *gpg_get_key_exchange_protocol (GMimeCryptoContext *ctx);
 
 static GMimeSignatureList *gpg_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags,
-                                      GMimeDigestAlgo digest, GMimeStream *istream,
-                                      GMimeStream *sigstream, GMimeStream *ostream,
-                                      GError **err);
+                                      GMimeStream *istream, GMimeStream *sigstream,
+                                      GMimeStream *ostream, GError **err);
 
 static int gpg_encrypt (GMimeCryptoContext *ctx, gboolean sign, const char *userid, GMimeDigestAlgo digest,
                        GMimeEncryptFlags flags, GPtrArray *recipients, GMimeStream *istream, GMimeStream 
*ostream,
@@ -597,8 +596,8 @@ gpg_get_signatures (GMimeGpgContext *gpg, gboolean verify)
 #endif /* ENABLE_CRYPTO */
 
 static GMimeSignatureList *
-gpg_verify (GMimeCryptoContext *context, GMimeVerifyFlags flags, GMimeDigestAlgo digest,
-           GMimeStream *istream, GMimeStream *sigstream, GMimeStream *ostream, GError **err)
+gpg_verify (GMimeCryptoContext *context, GMimeVerifyFlags flags, GMimeStream *istream, GMimeStream 
*sigstream,
+           GMimeStream *ostream, GError **err)
 {
 #ifdef ENABLE_CRYPTO
        GMimeGpgContext *gpg = (GMimeGpgContext *) context;
diff --git a/gmime/gmime-multipart-signed.c b/gmime/gmime-multipart-signed.c
index 054a79e..59c4f6d 100644
--- a/gmime/gmime-multipart-signed.c
+++ b/gmime/gmime-multipart-signed.c
@@ -373,7 +373,7 @@ check_protocol_supported (const char *protocol, const char *supported)
 GMimeSignatureList *
 g_mime_multipart_signed_verify (GMimeMultipartSigned *mps, GMimeVerifyFlags flags, GError **err)
 {
-       const char *supported, *protocol, *micalg;
+       const char *supported, *protocol;
        GMimeObject *content, *signature;
        GMimeStream *stream, *sigstream;
        GMimeSignatureList *signatures;
@@ -399,8 +399,6 @@ g_mime_multipart_signed_verify (GMimeMultipartSigned *mps, GMimeVerifyFlags flag
                return NULL;
        }
        
-       micalg = g_mime_object_get_content_type_parameter (GMIME_OBJECT (mps), "micalg");
-       
        if (!(ctx = g_mime_crypto_context_new (protocol))) {
                g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
                             _("Cannot verify multipart/signed part: unregistered signature protocol '%s'."),
@@ -469,8 +467,7 @@ g_mime_multipart_signed_verify (GMimeMultipartSigned *mps, GMimeVerifyFlags flag
        g_mime_stream_reset (sigstream);
        
        /* verify the signature */
-       digest = g_mime_crypto_context_digest_id (ctx, micalg);
-       signatures = g_mime_crypto_context_verify (ctx, flags, digest, stream, sigstream, NULL, err);
+       signatures = g_mime_crypto_context_verify (ctx, flags, stream, sigstream, NULL, err);
        
        d(printf ("attempted to verify:\n----- BEGIN SIGNED PART -----\n%.*s----- END SIGNED PART -----\n",
                  (int) GMIME_STREAM_MEM (stream)->buffer->len, GMIME_STREAM_MEM (stream)->buffer->data));
diff --git a/gmime/gmime-pkcs7-context.c b/gmime/gmime-pkcs7-context.c
index 1fd48a6..f918ed4 100644
--- a/gmime/gmime-pkcs7-context.c
+++ b/gmime/gmime-pkcs7-context.c
@@ -97,9 +97,8 @@ static int pkcs7_sign (GMimeCryptoContext *ctx, gboolean detach,
                       GError **err);
        
 static GMimeSignatureList *pkcs7_verify (GMimeCryptoContext *ctx, GMimeVerifyFlags flags,
-                                        GMimeDigestAlgo digest, GMimeStream *istream,
-                                        GMimeStream *sigstream, GMimeStream *ostream,
-                                        GError **err);
+                                        GMimeStream *istream, GMimeStream *sigstream,
+                                        GMimeStream *ostream, GError **err);
 
 static int pkcs7_encrypt (GMimeCryptoContext *ctx, gboolean sign, const char *userid, GMimeDigestAlgo digest,
                          GMimeEncryptFlags flags, GPtrArray *recipients, GMimeStream *istream,
@@ -591,8 +590,8 @@ pkcs7_get_signatures (GMimePkcs7Context *pkcs7, gboolean verify)
 #endif /* ENABLE_CRYPTO */
 
 static GMimeSignatureList *
-pkcs7_verify (GMimeCryptoContext *context, GMimeVerifyFlags flags, GMimeDigestAlgo digest,
-             GMimeStream *istream, GMimeStream *sigstream, GMimeStream *ostream, GError **err)
+pkcs7_verify (GMimeCryptoContext *context, GMimeVerifyFlags flags, GMimeStream *istream, GMimeStream 
*sigstream,
+             GMimeStream *ostream, GError **err)
 {
 #ifdef ENABLE_CRYPTO
        GMimePkcs7Context *pkcs7 = (GMimePkcs7Context *) context;
diff --git a/tests/test-pgp.c b/tests/test-pgp.c
index 9367d24..0122442 100644
--- a/tests/test-pgp.c
+++ b/tests/test-pgp.c
@@ -97,8 +97,7 @@ test_verify (GMimeCryptoContext *ctx, GMimeStream *cleartext, GMimeStream *ciphe
        GError *err = NULL;
        Exception *ex;
        
-       signatures = g_mime_crypto_context_verify (ctx, 0, GMIME_DIGEST_ALGO_DEFAULT,
-                                                  cleartext, ciphertext, NULL, &err);
+       signatures = g_mime_crypto_context_verify (ctx, 0, cleartext, ciphertext, NULL, &err);
        
        if (signatures == NULL) {
                ex = exception_new ("%s", err->message);
diff --git a/tests/test-pkcs7.c b/tests/test-pkcs7.c
index e1929e5..b8a9f55 100644
--- a/tests/test-pkcs7.c
+++ b/tests/test-pkcs7.c
@@ -98,8 +98,7 @@ test_verify_detached (GMimeCryptoContext *ctx, GMimeStream *cleartext, GMimeStre
        GError *err = NULL;
        Exception *ex;
        
-       signatures = g_mime_crypto_context_verify (ctx, 0, GMIME_DIGEST_ALGO_DEFAULT,
-                                                  cleartext, ciphertext, NULL, &err);
+       signatures = g_mime_crypto_context_verify (ctx, 0, cleartext, ciphertext, NULL, &err);
        
        if (signatures == NULL) {
                ex = exception_new ("%s", err->message);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]