Bug 330503 - Use Array<octet> for passing byte buffers in nsICMSMessage.idl. r=kaie
authorBen Campbell <benc@thunderbird.net>
Sat, 18 Jan 2020 11:49:59 +0200
changeset 37978 bbea4c75d9828dcde30f383a50096381e33c83a6
parent 37977 d3a53a76bfbfadfb4fca4be32e0d37531d7bf791
child 37979 8408774e360fe8b68ae4010fdcdb64e6e5192faf
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewerskaie
bugs330503
Bug 330503 - Use Array<octet> for passing byte buffers in nsICMSMessage.idl. r=kaie
mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
mailnews/mime/public/nsICMSMessage.idl
mailnews/mime/src/mimecms.cpp
mailnews/mime/src/mimemcms.cpp
mailnews/mime/src/nsCMS.cpp
mailnews/mime/src/nsCMS.h
--- a/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
+++ b/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
@@ -567,17 +567,16 @@ nsresult nsMsgComposeSecure::MimeInitEnc
   }
 
 FAIL:
   return rv;
 }
 
 nsresult nsMsgComposeSecure::MimeFinishMultipartSigned(
     bool aOuter, nsIMsgSendReport *sendReport) {
-  int status;
   nsresult rv;
   nsCOMPtr<nsICMSMessage> cinfo =
       do_CreateInstance(NS_CMSMESSAGE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsICMSEncoder> encoder =
       do_CreateInstance(NS_CMSENCODER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -598,37 +597,34 @@ nsresult nsMsgComposeSecure::MimeFinishM
                                  mime_smime_sig_content_desc);
 
   NS_ConvertUTF16toUTF8 sig_content_desc_utf8(mime_smime_sig_content_desc);
 
   /* Compute the hash...
    */
 
   nsAutoCString hashString;
-  mDataHash->Finish(false, hashString);
-
+  rv = mDataHash->Finish(false, hashString);
   mDataHash = nullptr;
-
-  status = PR_GetError();
-  if (status < 0) goto FAIL;
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (PR_GetError() < 0) return NS_ERROR_FAILURE;
 
   /* Write out the headers for the signature.
    */
   uint32_t L;
   header = PR_smprintf(
       CRLF "--%s" CRLF "Content-Type: " APPLICATION_PKCS7_SIGNATURE
            "; name=\"smime.p7s\"" CRLF
            "Content-Transfer-Encoding: " ENCODING_BASE64 CRLF
            "Content-Disposition: attachment; "
            "filename=\"smime.p7s\"" CRLF "Content-Description: %s" CRLF CRLF,
       mMultipartSignedBoundary, sig_content_desc_utf8.get());
 
   if (!header) {
-    rv = NS_ERROR_OUT_OF_MEMORY;
-    goto FAIL;
+    return NS_ERROR_OUT_OF_MEMORY;
   }
 
   L = strlen(header);
   if (aOuter) {
     /* If this is the outer block, write it to the file. */
     uint32_t n;
     rv = mStream->Write(header, L, &n);
     if (NS_FAILED(rv) || n < L) {
@@ -636,88 +632,87 @@ nsresult nsMsgComposeSecure::MimeFinishM
       rv = static_cast<nsresult>(MK_MIME_ERROR_WRITING_FILE);
     }
   } else {
     /* If this is an inner block, feed it through the crypto stream. */
     rv = MimeCryptoWriteBlock(header, L);
   }
 
   PR_Free(header);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   /* Create the signature...
    */
 
   NS_ASSERTION(mHashType, "Hash function for signature has not been set.");
 
   PR_ASSERT(mSelfSigningCert);
   PR_SetError(0, 0);
 
-  rv = cinfo->CreateSigned(mSelfSigningCert, mSelfEncryptionCert,
-                           (unsigned char *)hashString.get(),
-                           hashString.Length(), mHashType);
+  nsTArray<uint8_t> digest;
+  digest.AppendElements(hashString.get(), hashString.Length());
+
+  rv = cinfo->CreateSigned(mSelfSigningCert, mSelfEncryptionCert, digest,
+                           mHashType);
   if (NS_FAILED(rv)) {
     SetError(sendReport, u"ErrorCanNotSignMail");
-    goto FAIL;
+    return rv;
   }
 
   // Initialize the base64 encoder for the signature data.
   MOZ_ASSERT(!mSigEncoder, "Shouldn't already have a mSigEncoder");
   mSigEncoder = MimeEncoder::GetBase64Encoder(
       (aOuter ? mime_encoder_output_fn : mime_nested_encoder_output_fn), this);
 
   /* Write out the signature.
    */
   PR_SetError(0, 0);
   rv = encoder->Start(cinfo, mime_crypto_write_base64, mSigEncoder);
   if (NS_FAILED(rv)) {
     SetError(sendReport, u"ErrorCanNotSignMail");
-    goto FAIL;
+    return rv;
   }
 
   // We're not passing in any data, so no update needed.
   rv = encoder->Finish();
   if (NS_FAILED(rv)) {
     SetError(sendReport, u"ErrorCanNotSignMail");
-    goto FAIL;
+    return rv;
   }
 
   // Shut down the sig's base64 encoder.
   rv = mSigEncoder->Flush();
   mSigEncoder = nullptr;
-  if (NS_FAILED(rv)) {
-    goto FAIL;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
   /* Now write out the terminating boundary.
    */
   {
     uint32_t L;
     char *header = PR_smprintf(CRLF "--%s--" CRLF, mMultipartSignedBoundary);
     PR_Free(mMultipartSignedBoundary);
     mMultipartSignedBoundary = 0;
 
     if (!header) {
-      rv = NS_ERROR_OUT_OF_MEMORY;
-      goto FAIL;
+      return NS_ERROR_OUT_OF_MEMORY;
     }
     L = strlen(header);
     if (aOuter) {
       /* If this is the outer block, write it to the file. */
       uint32_t n;
       rv = mStream->Write(header, L, &n);
       if (NS_FAILED(rv) || n < L)
         // XXX This is -1, not an nsresult
         rv = static_cast<nsresult>(MK_MIME_ERROR_WRITING_FILE);
     } else {
       /* If this is an inner block, feed it through the crypto stream. */
       rv = MimeCryptoWriteBlock(header, L);
     }
   }
 
-FAIL:
   return rv;
 }
 
 /* Helper function for mime_finish_crypto_encapsulation() to close off
    an opaque crypto object (for encrypted or signed-and-encrypted messages.)
  */
 nsresult nsMsgComposeSecure::MimeFinishEncryption(
     bool aSign, nsIMsgSendReport *sendReport) {
--- a/mailnews/mime/public/nsICMSMessage.idl
+++ b/mailnews/mime/public/nsICMSMessage.idl
@@ -29,55 +29,42 @@ interface nsICMSMessage : nsISupports
 {
   void contentIsSigned(out boolean aSigned);
   void contentIsEncrypted(out boolean aEncrypted);
   void getSignerCommonName(out string aName);
   void getSignerEmailAddress(out string aEmail);
   void getSignerCert(out nsIX509Cert scert);
   void getEncryptionCert(out nsIX509Cert ecert);
   void verifySignature();
-  void verifyDetachedSignature(in UnsignedCharPtr aDigestData,
-                               in unsigned long aDigestDataLen,
+  void verifyDetachedSignature(in Array<octet> aDigestData,
                                in int16_t aDigestType);
   void CreateEncrypted(in nsIArray aRecipientCerts);
 
   /* The parameter aDigestType must be one of the values in nsICryptoHash */
   void CreateSigned(in nsIX509Cert scert, in nsIX509Cert ecert,
-                    in UnsignedCharPtr aDigestData,
-                    in unsigned long aDigestDataLen, in int16_t aDigestType);
+                    in Array<octet> aDigestData, in int16_t aDigestType);
 
   /**
     * Async version of nsICMSMessage::VerifySignature.
     * Code will be executed on a background thread and
     * availability of results will be notified using a
     * call to nsISMimeVerificationListener.
    */
   void asyncVerifySignature(in nsISMimeVerificationListener listener);
 
   /**
     * Async version of nsICMSMessage::VerifyDetachedSignature.
     * Code will be executed on a background thread and
     * availability of results will be notified using a
     * call to nsISMimeVerificationListener.
     *
-    * We are using "native unsigned char" ptr, because the function
-    * signatures of this one and nsICMSMessage::verifyDetachedSignature
-    * should be the identical.
-    *
-    * Once both interfaces get cleaned up (bug 330503), the function signature
-    * should look like:
-    *     [array, length_is(aDigestDataLen)] or [const, array, length_is(aDigestDataLen])
-    *     in octet aDigestData,
-    *     in unsigned long aDigestDataLen);
-    *
     * Set aDigestType to one of the values from nsICryptoHash.
    */
   void asyncVerifyDetachedSignature(in nsISMimeVerificationListener listener,
-                                    in UnsignedCharPtr aDigestData,
-                                    in unsigned long aDigestDataLen,
+                                    in Array<octet> aDigestData,
                                     in int16_t aDigestType);
 };
 
 [uuid(5226d698-0773-4f25-b94c-7944b3fc01d3)]
 interface nsISMimeVerificationListener : nsISupports {
 
   /**
    * Notify that results are ready, that have been requested
--- a/mailnews/mime/src/mimecms.cpp
+++ b/mailnews/mime/src/mimecms.cpp
@@ -577,27 +577,26 @@ void MimeCMSGetFromSender(MimeObject *ob
   if (!s.IsEmpty())
     ExtractFirstAddress(EncodedHeader(s), sender_name, sender_addr);
 }
 
 void MimeCMSRequestAsyncSignatureVerification(
     nsICMSMessage *aCMSMsg, const char *aFromAddr, const char *aFromName,
     const char *aSenderAddr, const char *aSenderName,
     nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel,
-    const nsCString &aMsgNeckoURL, unsigned char *item_data, uint32_t item_len,
-    int16_t digest_type) {
+    const nsCString &aMsgNeckoURL, const nsTArray<uint8_t> &aDigestData,
+    int16_t aDigestType) {
   RefPtr<nsSMimeVerificationListener> listener =
       new nsSMimeVerificationListener(aFromAddr, aFromName, aSenderAddr,
                                       aSenderName, aHeaderSink,
                                       aMimeNestingLevel, aMsgNeckoURL);
-  if (item_data)
-    aCMSMsg->AsyncVerifyDetachedSignature(listener, item_data, item_len,
-                                          digest_type);
+  if (aDigestData.IsEmpty())
+    aCMSMsg->AsyncVerifySignature(listener);
   else
-    aCMSMsg->AsyncVerifySignature(listener);
+    aCMSMsg->AsyncVerifyDetachedSignature(listener, aDigestData, aDigestType);
 }
 
 static int MimeCMS_eof(void *crypto_closure, bool abort_p) {
   MimeCMSdata *data = (MimeCMSdata *)crypto_closure;
   nsresult rv;
   int32_t status = nsICMSMessageErrors::SUCCESS;
 
   if (!data || !data->output_fn) {
@@ -697,17 +696,17 @@ static int MimeCMS_eof(void *crypto_clos
       nsCString sender_name;
 
       MimeCMSGetFromSender(data->self, from_addr, from_name, sender_addr,
                            sender_name);
 
       MimeCMSRequestAsyncSignatureVerification(
           data->content_info, from_addr.get(), from_name.get(),
           sender_addr.get(), sender_name.get(), data->smimeHeaderSink,
-          aRelativeNestLevel, data->url, nullptr, 0, 0);
+          aRelativeNestLevel, data->url, {}, 0);
     }
   }
 
   if (data->ci_is_encrypted) {
     data->smimeHeaderSink->EncryptionStatus(aRelativeNestLevel, status,
                                             certOfInterest, data->url);
   }
 
--- a/mailnews/mime/src/mimemcms.cpp
+++ b/mailnews/mime/src/mimemcms.cpp
@@ -107,18 +107,18 @@ extern void MimeCMSGetFromSender(MimeObj
                                  nsCString &from_name, nsCString &sender_addr,
                                  nsCString &sender_name);
 extern bool MimeCMSHeadersAndCertsMatch(
     MimeObject *obj, nsICMSMessage *, bool *signing_cert_without_email_address);
 extern void MimeCMSRequestAsyncSignatureVerification(
     nsICMSMessage *aCMSMsg, const char *aFromAddr, const char *aFromName,
     const char *aSenderAddr, const char *aSenderName,
     nsIMsgSMIMEHeaderSink *aHeaderSink, int32_t aMimeNestingLevel,
-    const nsCString &aMsgNeckoURL, unsigned char *item_data, uint32_t item_len,
-    int16_t digest_type);
+    const nsCString &aMsgNeckoURL, const nsTArray<uint8_t> &aDigestData,
+    int16_t aDigestType);
 extern char *MimeCMS_MakeSAURL(MimeObject *obj);
 extern char *IMAP_CreateReloadAllPartsUrl(const char *url);
 extern int MIMEGetRelativeCryptoNestLevel(MimeObject *obj);
 
 static void *MimeMultCMS_init(MimeObject *obj) {
   MimeHeaders *hdrs = obj->headers;
   MimeMultCMSdata *data = 0;
   char *ct, *micalg;
@@ -429,20 +429,22 @@ static char *MimeMultCMS_generate(void *
   nsCString from_addr;
   nsCString from_name;
   nsCString sender_addr;
   nsCString sender_name;
 
   MimeCMSGetFromSender(data->self, from_addr, from_name, sender_addr,
                        sender_name);
 
+  nsTArray<uint8_t> digest;
+  digest.AppendElements(data->item_data, data->item_len);
   MimeCMSRequestAsyncSignatureVerification(
       data->content_info, from_addr.get(), from_name.get(), sender_addr.get(),
       sender_name.get(), data->smimeHeaderSink, aRelativeNestLevel, data->url,
-      data->item_data, data->item_len, data->hash_type);
+      digest, data->hash_type);
 
   if (data->content_info) {
 #if 0  // XXX Fix this. What do we do here? //
     if (SEC_CMSContainsCertsOrCrls(data->content_info))
     {
       /* #### call libsec telling it to import the certs */
     }
 #endif
--- a/mailnews/mime/src/nsCMS.cpp
+++ b/mailnews/mime/src/nsCMS.cpp
@@ -49,17 +49,17 @@ nsresult nsCMSMessage::Init() {
 
 void nsCMSMessage::destructorSafeDestroyNSSReference() {
   if (m_cmsMsg) {
     NSS_CMSMessage_Destroy(m_cmsMsg);
   }
 }
 
 NS_IMETHODIMP nsCMSMessage::VerifySignature() {
-  return CommonVerifySignature(nullptr, 0, 0);
+  return CommonVerifySignature({}, 0);
 }
 
 NSSCMSSignerInfo *nsCMSMessage::GetTopLevelSignerInfo() {
   if (!m_cmsMsg) return nullptr;
 
   if (!NSS_CMSMessage_IsSigned(m_cmsMsg)) return nullptr;
 
   NSSCMSContentInfo *cinfo = NSS_CMSMessage_ContentLevel(m_cmsMsg, 0);
@@ -145,27 +145,25 @@ NS_IMETHODIMP nsCMSMessage::GetSignerCer
   return NS_OK;
 }
 
 NS_IMETHODIMP nsCMSMessage::GetEncryptionCert(nsIX509Cert **) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsCMSMessage::VerifyDetachedSignature(unsigned char *aDigestData,
-                                      uint32_t aDigestDataLen,
+nsCMSMessage::VerifyDetachedSignature(const nsTArray<uint8_t> &aDigestData,
                                       int16_t aDigestType) {
-  if (!aDigestData || !aDigestDataLen) return NS_ERROR_FAILURE;
+  if (aDigestData.IsEmpty()) return NS_ERROR_FAILURE;
 
-  return CommonVerifySignature(aDigestData, aDigestDataLen, aDigestType);
+  return CommonVerifySignature(aDigestData, aDigestType);
 }
 
-nsresult nsCMSMessage::CommonVerifySignature(unsigned char *aDigestData,
-                                             uint32_t aDigestDataLen,
-                                             int16_t aDigestType) {
+nsresult nsCMSMessage::CommonVerifySignature(
+    const nsTArray<uint8_t> &aDigestData, int16_t aDigestType) {
   MOZ_LOG(gCMSLog, LogLevel::Debug,
           ("nsCMSMessage::CommonVerifySignature, content level count %d",
            NSS_CMSMessage_ContentLevelCount(m_cmsMsg)));
   NSSCMSContentInfo *cinfo = nullptr;
   NSSCMSSignedData *sigd = nullptr;
   NSSCMSSignerInfo *si;
   int32_t nsigners;
   RefPtr<SharedCertVerifier> certVerifier;
@@ -200,21 +198,23 @@ nsresult nsCMSMessage::CommonVerifySigna
 
   if (!sigd) {
     MOZ_LOG(gCMSLog, LogLevel::Debug,
             ("nsCMSMessage::CommonVerifySignature - no content info"));
     rv = NS_ERROR_CMS_VERIFY_NO_CONTENT_INFO;
     goto loser;
   }
 
-  if (aDigestData && aDigestDataLen) {
+  if (!aDigestData.IsEmpty()) {
     SECOidTag oidTag;
     SECItem digest;
-    digest.data = aDigestData;
-    digest.len = aDigestDataLen;
+    // NSS_CMSSignedData_SetDigestValue() takes a copy and won't mutate our
+    // data, so we're OK to cast away the const here.
+    digest.data = const_cast<uint8_t *>(aDigestData.Elements());
+    digest.len = aDigestData.Length();
 
     if (NSS_CMSSignedData_HasDigests(sigd)) {
       SECAlgorithmID **existingAlgs = NSS_CMSSignedData_GetDigestAlgs(sigd);
       if (existingAlgs) {
         while (*existingAlgs) {
           SECAlgorithmID *alg = *existingAlgs;
           SECOidTag algOIDTag = SECOID_FindOIDTag(&alg->algorithm);
           NSS_CMSSignedData_SetDigestValue(sigd, algOIDTag, NULL);
@@ -339,77 +339,74 @@ nsresult nsCMSMessage::CommonVerifySigna
 
   rv = NS_OK;
 loser:
   return rv;
 }
 
 NS_IMETHODIMP nsCMSMessage::AsyncVerifySignature(
     nsISMimeVerificationListener *aListener) {
-  return CommonAsyncVerifySignature(aListener, nullptr, 0, 0);
+  return CommonAsyncVerifySignature(aListener, {}, 0);
 }
 
 NS_IMETHODIMP nsCMSMessage::AsyncVerifyDetachedSignature(
-    nsISMimeVerificationListener *aListener, unsigned char *aDigestData,
-    uint32_t aDigestDataLen, int16_t aDigestType) {
-  if (!aDigestData || !aDigestDataLen) return NS_ERROR_FAILURE;
+    nsISMimeVerificationListener *aListener,
+    const nsTArray<uint8_t> &aDigestData, int16_t aDigestType) {
+  if (aDigestData.IsEmpty()) return NS_ERROR_FAILURE;
 
-  return CommonAsyncVerifySignature(aListener, aDigestData, aDigestDataLen,
-                                    aDigestType);
+  return CommonAsyncVerifySignature(aListener, aDigestData, aDigestType);
 }
 
 class SMimeVerificationTask final : public CryptoTask {
  public:
   SMimeVerificationTask(nsICMSMessage *aMessage,
                         nsISMimeVerificationListener *aListener,
-                        unsigned char *aDigestData, uint32_t aDigestDataLen,
-                        int16_t aDigestType) {
+                        const nsTArray<uint8_t> &aDigestData,
+                        int16_t aDigestType)
+      : mMessage(aMessage),
+        mListener(aListener),
+        mDigestData(aDigestData),
+        mDigestType(aDigestType) {
     MOZ_ASSERT(NS_IsMainThread());
-    mMessage = aMessage;
-    mListener = aListener;
-    mDigestData.Assign(reinterpret_cast<char *>(aDigestData), aDigestDataLen);
-    mDigestType = aDigestType;
   }
 
  private:
   virtual nsresult CalculateResult() override {
     MOZ_ASSERT(!NS_IsMainThread());
 
     mozilla::StaticMutexAutoLock lock(sMutex);
     nsresult rv;
-    if (!mDigestData.IsEmpty()) {
-      rv = mMessage->VerifyDetachedSignature(
-          reinterpret_cast<uint8_t *>(const_cast<char *>(mDigestData.get())),
-          mDigestData.Length(), mDigestType);
+    if (mDigestData.IsEmpty()) {
+      rv = mMessage->VerifySignature();
     } else {
-      rv = mMessage->VerifySignature();
+      rv = mMessage->VerifyDetachedSignature(mDigestData, mDigestType);
     }
 
     return rv;
   }
   virtual void CallCallback(nsresult rv) override {
     MOZ_ASSERT(NS_IsMainThread());
     mListener->Notify(mMessage, rv);
   }
 
   nsCOMPtr<nsICMSMessage> mMessage;
   nsCOMPtr<nsISMimeVerificationListener> mListener;
-  nsCString mDigestData;
+  nsTArray<uint8_t> mDigestData;
   int16_t mDigestType;
 
   static mozilla::StaticMutex sMutex;
 };
 
 mozilla::StaticMutex SMimeVerificationTask::sMutex;
 
 nsresult nsCMSMessage::CommonAsyncVerifySignature(
-    nsISMimeVerificationListener *aListener, unsigned char *aDigestData,
-    uint32_t aDigestDataLen, int16_t aDigestType) {
-  RefPtr<CryptoTask> task = new SMimeVerificationTask(
-      this, aListener, aDigestData, aDigestDataLen, aDigestType);
+    nsISMimeVerificationListener *aListener,
+    const nsTArray<uint8_t> &aDigestData, int16_t aDigestType) {
+  RefPtr<CryptoTask> task =
+      new SMimeVerificationTask(this, aListener, aDigestData, aDigestType);
   return task->Dispatch();
 }
 
 class nsZeroTerminatedCertArray {
  public:
   nsZeroTerminatedCertArray() : mCerts(nullptr), mPoolp(nullptr), mSize(0) {}
 
   ~nsZeroTerminatedCertArray() { destructorSafeDestroyNSSReference(); }
@@ -580,17 +577,17 @@ bool nsCMSMessage::IsAllowedHash(const i
       return true;
     default:
       return false;
   }
 }
 
 NS_IMETHODIMP
 nsCMSMessage::CreateSigned(nsIX509Cert *aSigningCert, nsIX509Cert *aEncryptCert,
-                           unsigned char *aDigestData, uint32_t aDigestDataLen,
+                           const nsTArray<uint8_t> &aDigestData,
                            int16_t aDigestType) {
   NS_ENSURE_ARG(aSigningCert);
   MOZ_LOG(gCMSLog, LogLevel::Debug, ("nsCMSMessage::CreateSigned"));
   NSSCMSContentInfo *cinfo;
   NSSCMSSignedData *sigd;
   NSSCMSSignerInfo *signerinfo;
   UniqueCERTCertificate scert(aSigningCert->GetCert());
   UniqueCERTCertificate ecert;
@@ -713,22 +710,23 @@ nsCMSMessage::CreateSigned(nsIX509Cert *
 
   if (NSS_CMSSignedData_AddSignerInfo(sigd, signerinfo) != SECSuccess) {
     MOZ_LOG(gCMSLog, LogLevel::Debug,
             ("nsCMSMessage::CreateSigned - can't add signer info"));
     goto loser;
   }
 
   // Finally, add the pre-computed digest if passed in
-  if (aDigestData) {
+  if (!aDigestData.IsEmpty()) {
     SECItem digest;
 
-    digest.data = aDigestData;
-    digest.len = aDigestDataLen;
-
+    // NSS_CMSSignedData_SetDigestValue() takes a copy and won't mutate our
+    // data, so we're OK to cast away the const here.
+    digest.data = const_cast<uint8_t *>(aDigestData.Elements());
+    digest.len = aDigestData.Length();
     if (NSS_CMSSignedData_SetDigestValue(sigd, digestType, &digest) !=
         SECSuccess) {
       MOZ_LOG(gCMSLog, LogLevel::Debug,
               ("nsCMSMessage::CreateSigned - can't set digest value"));
       goto loser;
     }
   }
 
--- a/mailnews/mime/src/nsCMS.h
+++ b/mailnews/mime/src/nsCMS.h
@@ -34,22 +34,21 @@ class nsCMSMessage : public nsICMSMessag
   void referenceContext(nsIInterfaceRequestor* aContext) { m_ctx = aContext; }
   NSSCMSMessage* getCMS() { return m_cmsMsg; }
 
  private:
   virtual ~nsCMSMessage();
   nsCOMPtr<nsIInterfaceRequestor> m_ctx;
   NSSCMSMessage* m_cmsMsg;
   NSSCMSSignerInfo* GetTopLevelSignerInfo();
-  nsresult CommonVerifySignature(unsigned char* aDigestData,
-                                 uint32_t aDigestDataLen, int16_t aDigestType);
+  nsresult CommonVerifySignature(const nsTArray<uint8_t>& aDigestData,
+                                 int16_t aDigestType);
 
   nsresult CommonAsyncVerifySignature(nsISMimeVerificationListener* aListener,
-                                      unsigned char* aDigestData,
-                                      uint32_t aDigestDataLen,
+                                      const nsTArray<uint8_t>& aDigestData,
                                       int16_t aDigestType);
   bool IsAllowedHash(const int16_t aCryptoHashInt);
 
   void destructorSafeDestroyNSSReference();
 };
 
 // ===============================================
 // nsCMSDecoder - implementation of nsICMSDecoder