crypt32(24/25): Introduce an updated state, and use it to remove boolean "begun"

Juan Lang juan.lang at gmail.com
Thu Jul 12 17:27:16 CDT 2007


--Juan
-------------- next part --------------
From e25d31b40ff3b08e8a7919253bc332f06bad2e68 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 12 Jul 2007 15:05:45 -0700
Subject: [PATCH] Introduce an updated state, and use it to remove boolean "begun"
 Please enter the commit message for your changes.
---
 dlls/crypt32/msg.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 001e128..d8ab55a 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -40,6 +40,7 @@ typedef BOOL (*CryptMsgUpdateFunc)(HCRYP
 
 typedef enum _CryptMsgState {
     MsgStateInit,
+    MsgStateUpdated,
     MsgStateFinalized
 } CryptMsgState;
 
@@ -82,7 +83,6 @@ typedef struct _CDataEncodeMsg
     CryptMsgBase base;
     DWORD        bare_content_len;
     LPBYTE       bare_content;
-    BOOL         begun;
 } CDataEncodeMsg;
 
 static const BYTE empty_data_content[] = { 0x04,0x00 };
@@ -170,11 +170,10 @@ static BOOL CDataEncodeMsg_Update(HCRYPT
     {
         __TRY
         {
-            if (!msg->begun)
+            if (msg->base.state != MsgStateUpdated)
             {
                 CRYPT_DATA_BLOB header;
 
-                msg->begun = TRUE;
                 ret = CRYPT_EncodeDataContentInfoHeader(msg, &header);
                 if (ret)
                 {
@@ -316,7 +315,6 @@ static HCRYPTMSG CDataEncodeMsg_Open(DWO
          CDataEncodeMsg_Close, CDataEncodeMsg_GetParam, CDataEncodeMsg_Update);
         msg->bare_content_len = sizeof(empty_data_content);
         msg->bare_content = (LPBYTE)empty_data_content;
-        msg->begun = FALSE;
     }
     return (HCRYPTMSG)msg;
 }
@@ -327,7 +325,6 @@ typedef struct _CHashEncodeMsg
     HCRYPTPROV      prov;
     HCRYPTHASH      hash;
     CRYPT_DATA_BLOB data;
-    BOOL            begun;
 } CHashEncodeMsg;
 
 static void CHashEncodeMsg_Close(HCRYPTMSG hCryptMsg)
@@ -367,7 +364,7 @@ static BOOL CRYPT_EncodePKCSDigestedData
         items[cItem].encodeFunc = CRYPT_AsnEncodeAlgorithmIdWithNullParams;
         cItem++;
         /* Quirk:  OID is only encoded messages if an update has happened */
-        if (msg->begun)
+        if (msg->base.state != MsgStateInit)
             contentInfo.pszObjId = oid_rsa_data;
         if (!(msg->base.open_flags & CMSG_DETACHED_FLAG) && msg->data.cbData)
         {
@@ -479,7 +476,6 @@ static BOOL CHashEncodeMsg_Update(HCRYPT
 
     TRACE("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal);
 
-    msg->begun = TRUE;
     if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG))
     {
         /* Doesn't do much, as stream output is never called, and you
@@ -544,7 +540,6 @@ static HCRYPTMSG CHashEncodeMsg_Open(DWO
         msg->prov = prov;
         msg->data.cbData = 0;
         msg->data.pbData = NULL;
-        msg->begun = FALSE;
         if (!CryptCreateHash(prov, algID, 0, 0, &msg->hash))
         {
             CryptMsgClose(msg);
@@ -718,6 +713,7 @@ BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCr
     else
     {
         ret = msg->update(hCryptMsg, pbData, cbData, fFinal);
+        msg->state = MsgStateUpdated;
         if (fFinal)
             msg->state = MsgStateFinalized;
     }
-- 
1.4.1


More information about the wine-patches mailing list