winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2007
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
957 discussions
Start a n
N
ew thread
Evan Stade : gdiplus: Updated GdipDrawRectangleI.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: 14e0df1fa0c0225d8de4d997b64aaec74963dd9a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=14e0df1fa0c0225d8de4d997b…
Author: Evan Stade <estade(a)gmail.com> Date: Mon Jul 9 20:54:18 2007 -0700 gdiplus: Updated GdipDrawRectangleI. --- dlls/gdiplus/gdiplus_private.h | 2 +- dlls/gdiplus/graphics.c | 26 +++++++------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 7c5195a..d036057 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -22,7 +22,7 @@ #include "windef.h" #include "gdiplus.h" -#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_ENDCAP_FLAT) +#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER) COLORREF ARGB2COLORREF(ARGB color); diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 1040009..06a5dad 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -590,31 +590,19 @@ GpStatus WINGDIPAPI GdipDrawPie(GpGraphics *graphics, GpPen *pen, REAL x, GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height) { - LOGBRUSH lb; - HPEN hpen; - HGDIOBJ old_obj; + INT save_state; if(!pen || !graphics) return InvalidParameter; - lb.lbStyle = BS_SOLID; - lb.lbColor = pen->color; - lb.lbHatch = 0; - - hpen = ExtCreatePen(PS_GEOMETRIC | PS_ENDCAP_SQUARE, (INT) pen->width, - &lb, 0, NULL); - - old_obj = SelectObject(graphics->hdc, hpen); + save_state = SaveDC(graphics->hdc); + EndPath(graphics->hdc); + SelectObject(graphics->hdc, pen->gdipen); + SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH)); - /* assume pen aligment centered */ - MoveToEx(graphics->hdc, x, y, NULL); - LineTo(graphics->hdc, x+width, y); - LineTo(graphics->hdc, x+width, y+height); - LineTo(graphics->hdc, x, y+height); - LineTo(graphics->hdc, x, y); + Rectangle(graphics->hdc, x, y, x + width, y + height); - SelectObject(graphics->hdc, old_obj); - DeleteObject(hpen); + RestoreDC(graphics->hdc, save_state); return Ok; }
1
0
0
0
Evan Stade : gdiplus: Updated draw_pie to use SaveDC/RestoreDC.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: a4fff71454ac04b7b3aa4f4a8f1dbf41505b1617 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a4fff71454ac04b7b3aa4f4a8…
Author: Evan Stade <estade(a)gmail.com> Date: Mon Jul 9 20:54:11 2007 -0700 gdiplus: Updated draw_pie to use SaveDC/RestoreDC. --- dlls/gdiplus/graphics.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 5f730ab..1040009 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -60,14 +60,16 @@ static void deg2xy(REAL angle, REAL x_0, REAL y_0, REAL *x, REAL *y) static GpStatus draw_pie(GpGraphics *graphics, HBRUSH gdibrush, HPEN gdipen, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle) { - HGDIOBJ old_pen, old_brush; + INT save_state; REAL x_0, y_0, x_1, y_1, x_2, y_2; if(!graphics) return InvalidParameter; - old_pen = SelectObject(graphics->hdc, gdipen); - old_brush = SelectObject(graphics->hdc, gdibrush); + save_state = SaveDC(graphics->hdc); + EndPath(graphics->hdc); + SelectObject(graphics->hdc, gdipen); + SelectObject(graphics->hdc, gdibrush); x_0 = x + (width/2.0); y_0 = y + (height/2.0); @@ -78,8 +80,7 @@ static GpStatus draw_pie(GpGraphics *graphics, HBRUSH gdibrush, HPEN gdipen, Pie(graphics->hdc, roundr(x), roundr(y), roundr(x+width), roundr(y+height), roundr(x_1), roundr(y_1), roundr(x_2), roundr(y_2)); - SelectObject(graphics->hdc, old_pen); - SelectObject(graphics->hdc, old_brush); + RestoreDC(graphics->hdc, save_state); return Ok; }
1
0
0
0
Juan Lang : crypt32: More decode message update tests.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: 685d7e799a84dfa51e79e56594a4bd1107403a0b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=685d7e799a84dfa51e79e5659…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 11:27:46 2007 -0700 crypt32: More decode message update tests. --- dlls/crypt32/tests/msg.c | 100 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 99 insertions(+), 1 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 3c9fc7e..1e987d2 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -632,12 +632,20 @@ static void test_data_msg(void) test_data_msg_encoding(); } +static CRYPT_DATA_BLOB b4 = { 0, NULL }; +static const struct update_accum a4 = { 1, &b4 }; + +static const BYTE bogusOIDContent[] = { +0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x07,0xa0,0x02, +0x04,0x00 }; + static void test_decode_msg_update(void) { HCRYPTMSG msg; BOOL ret; CMSG_STREAM_INFO streamInfo = { 0 }; DWORD i; + struct update_accum accum = { 0, NULL }; msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); /* Update with a full message in a final update */ @@ -686,16 +694,106 @@ static void test_decode_msg_update(void) "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); CryptMsgClose(msg); + /* Empty non-final updates are allowed when streaming.. */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* but final updates aren't when not enough data has been received. */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_STREAM_INSUFFICIENT_DATA, + "Expected CRYPT_E_STREAM_INSUFFICIENT_DATA, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* Updating the message byte by byte is legal */ + streamInfo.pfnStreamOutput = accumulating_stream_output; + streamInfo.pvArg = &accum; msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); - todo_wine { for (i = 0, ret = TRUE; ret && i < sizeof(dataEmptyContent); i++) ret = CryptMsgUpdate(msg, &dataEmptyContent[i], 1, FALSE); + todo_wine { ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError()); ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError()); } CryptMsgClose(msg); + todo_wine + check_updates("byte-by-byte empty content", &a4, &accum); + free_updates(&accum); + + /* Decoding bogus content fails in non-streaming mode.. */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* and as the final update in streaming mode.. */ + streamInfo.pfnStreamOutput = nop_stream_output; + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* and even as a non-final update in streaming mode. */ + streamInfo.pfnStreamOutput = nop_stream_output; + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError()); + CryptMsgClose(msg); + + /* An empty message can be opened with indetermined type.. */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), + TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* but decoding it as an explicitly typed message fails. */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, + NULL); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), + TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* On the other hand, decoding the bare content of an empty message fails + * with unspecified type.. + */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyBareContent, + sizeof(dataEmptyBareContent), TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* but succeeds with explicit type. */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, + NULL); + ret = CryptMsgUpdate(msg, dataEmptyBareContent, + sizeof(dataEmptyBareContent), TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); + + /* Decoding valid content with an unsupported OID fails */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, bogusOIDContent, sizeof(bogusOIDContent), TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + CryptMsgClose(msg); } static void test_decode_msg(void)
1
0
0
0
Juan Lang : crypt32: Implement getting the type of a decode message.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: 8ca755915b6f677d51837b5e00658617474bd68e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8ca755915b6f677d51837b5e0…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 11:22:08 2007 -0700 crypt32: Implement getting the type of a decode message. --- dlls/crypt32/msg.c | 31 ++++++++++++++++++++++++++++--- dlls/crypt32/tests/msg.c | 14 -------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index dbe14b5..63f6671 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -269,9 +269,34 @@ static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData) { - FIXME("(%p, %d, %d, %p, %p): stub\n", hCryptMsg, dwParamType, dwIndex, - pvData, pcbData); - return FALSE; + CDecodeMsg *msg = (CDecodeMsg *)hCryptMsg; + BOOL ret = FALSE; + + switch (dwParamType) + { + case CMSG_TYPE_PARAM: + if (!pvData) + { + *pcbData = sizeof(DWORD); + ret = TRUE; + } + else if (*pcbData < sizeof(DWORD)) + { + *pcbData = sizeof(DWORD); + SetLastError(ERROR_MORE_DATA); + } + else + { + *pcbData = sizeof(DWORD); + *(DWORD *)pvData = msg->type; + ret = TRUE; + } + break; + default: + FIXME("unimplemented for parameter %d\n", dwParamType); + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + } + return ret; } HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index be1963e..80ba79c 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -155,14 +155,12 @@ static void test_msg_get_param(void) /* For decoded messages, the type is always available */ size = 0; ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); /* For this (empty) message, the type isn't set */ ok(value == 0, "Expected type 0, got %d\n", value); - } CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, @@ -171,10 +169,8 @@ static void test_msg_get_param(void) /* For explicitly typed messages, the type is known. */ size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_DATA, "Expected CMSG_DATA, got %d\n", value); - } for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; @@ -188,10 +184,8 @@ static void test_msg_get_param(void) ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value); - } for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; @@ -205,10 +199,8 @@ static void test_msg_get_param(void) ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value); - } for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; @@ -222,10 +214,8 @@ static void test_msg_get_param(void) ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value); - } for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++) { size = 0; @@ -240,20 +230,16 @@ static void test_msg_get_param(void) ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %d\n", value); - } CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL); ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == 1000, "Expected 1000, got %d\n", value); - } CryptMsgClose(msg); }
1
0
0
0
Juan Lang : crypt32: Add some tests for updating decode messages.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: acc0bec41ff75632442e38725e86a20f884e57fd URL:
http://source.winehq.org/git/wine.git/?a=commit;h=acc0bec41ff75632442e38725…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 11:25:24 2007 -0700 crypt32: Add some tests for updating decode messages. --- dlls/crypt32/tests/msg.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 80ba79c..3c9fc7e 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -632,6 +632,77 @@ static void test_data_msg(void) test_data_msg_encoding(); } +static void test_decode_msg_update(void) +{ + HCRYPTMSG msg; + BOOL ret; + CMSG_STREAM_INFO streamInfo = { 0 }; + DWORD i; + + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + /* Update with a full message in a final update */ + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* Can't update after a final update */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + CryptMsgClose(msg); + + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); + /* Can't send a non-final update without streaming */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), + FALSE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + /* A subsequent final update succeeds */ + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); + + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + /* Updating a message that has a NULL stream callback fails */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), + FALSE); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); + /* Changing the callback pointer after the fact yields the same error (so + * the message must copy the stream info, not just store a pointer to it) + */ + streamInfo.pfnStreamOutput = nop_stream_output; + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), + FALSE); + todo_wine + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); + CryptMsgClose(msg); + + /* Updating the message byte by byte is legal */ + msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo); + todo_wine { + for (i = 0, ret = TRUE; ret && i < sizeof(dataEmptyContent); i++) + ret = CryptMsgUpdate(msg, &dataEmptyContent[i], 1, FALSE); + ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError()); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError()); + } + CryptMsgClose(msg); +} + +static void test_decode_msg(void) +{ + test_decode_msg_update(); +} + START_TEST(msg) { /* Basic parameter checking tests */ @@ -642,4 +713,5 @@ START_TEST(msg) /* Message-type specific tests */ test_data_msg(); + test_decode_msg(); }
1
0
0
0
Juan Lang : crypt32: Add a stub decode message implementation.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: 656d960dd4b01e1ef1f293e1214f8b1629c7c2e6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=656d960dd4b01e1ef1f293e12…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 11:20:34 2007 -0700 crypt32: Add a stub decode message implementation. --- dlls/crypt32/msg.c | 43 +++++++++++++++++++++++++++++++++++++++++-- dlls/crypt32/tests/msg.c | 15 +++++---------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 7c7a8e0..dbe14b5 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -244,11 +244,43 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags, return msg; } +typedef struct _CDecodeMsg +{ + CryptMsgBase base; + DWORD type; + HCRYPTPROV crypt_prov; +} CDecodeMsg; + +static void CDecodeMsg_Close(HCRYPTMSG hCryptMsg) +{ + CDecodeMsg *msg = (CDecodeMsg *)hCryptMsg; + + if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG) + CryptReleaseContext(msg->crypt_prov, 0); +} + +static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, + DWORD cbData, BOOL fFinal) +{ + FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData, fFinal); + return FALSE; +} + +static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, + DWORD dwIndex, void *pvData, DWORD *pcbData) +{ + FIXME("(%p, %d, %d, %p, %p): stub\n", hCryptMsg, dwParamType, dwIndex, + pvData, pcbData); + return FALSE; +} + HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo) { - FIXME("(%08x, %08x, %08x, %08lx, %p, %p): stub\n", dwMsgEncodingType, + CDecodeMsg *msg; + + TRACE("(%08x, %08x, %08x, %08lx, %p, %p)\n", dwMsgEncodingType, dwFlags, dwMsgType, hCryptProv, pRecipientInfo, pStreamInfo); if (GET_CMSG_ENCODING_TYPE(dwMsgEncodingType) != PKCS_7_ASN_ENCODING) @@ -256,7 +288,14 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, SetLastError(E_INVALIDARG); return NULL; } - return NULL; + msg = CryptMemAlloc(sizeof(CDecodeMsg)); + if (msg) + { + CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, + CDecodeMsg_Close, CDecodeMsg_GetParam, CDecodeMsg_Update); + msg->type = dwMsgType; + } + return msg; } HCRYPTMSG WINAPI CryptMsgDuplicate(HCRYPTMSG hCryptMsg) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 2b0bc18..be1963e 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -95,7 +95,6 @@ static void test_msg_open_to_decode(void) /* The message type can be explicit... */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL); - todo_wine { ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, @@ -125,7 +124,6 @@ static void test_msg_open_to_decode(void) CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL); ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); - } CryptMsgClose(msg); /* And even though the stream info parameter "must be set to NULL" for @@ -133,7 +131,6 @@ static void test_msg_open_to_decode(void) */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, &streamInfo); - todo_wine ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); CryptMsgClose(msg); } @@ -154,7 +151,6 @@ static void test_msg_get_param(void) /* Decoded messages */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); - todo_wine ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); /* For decoded messages, the type is always available */ size = 0; @@ -171,7 +167,6 @@ static void test_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL); - todo_wine ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); /* For explicitly typed messages, the type is known. */ size = sizeof(value); @@ -190,10 +185,10 @@ static void test_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL, NULL); - todo_wine { ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); + todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value); } @@ -207,10 +202,10 @@ static void test_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL, NULL); - todo_wine { ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); + todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value); } @@ -224,10 +219,10 @@ static void test_msg_get_param(void) msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL, NULL); - todo_wine { ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); + todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value); } @@ -242,20 +237,20 @@ static void test_msg_get_param(void) /* Explicitly typed messages get their types set, even if they're invalid */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, 0, NULL, NULL); - todo_wine { ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); + todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %d\n", value); } CryptMsgClose(msg); msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL); - todo_wine { ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError()); size = sizeof(value); ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size); + todo_wine { ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError()); ok(value == 1000, "Expected 1000, got %d\n", value); }
1
0
0
0
Juan Lang : crypt32: Test and fix CryptMsgGetParam for streamed messages.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: e557d36320bad7768271e1774bb3e9acbb7bc8c2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e557d36320bad7768271e1774…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 11:19:44 2007 -0700 crypt32: Test and fix CryptMsgGetParam for streamed messages. --- dlls/crypt32/msg.c | 27 ++++++++++++++++----------- dlls/crypt32/tests/msg.c | 22 +++++++++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 7280642..7c7a8e0 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -132,19 +132,24 @@ static BOOL CDataEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, switch (dwParamType) { case CMSG_CONTENT_PARAM: - { - CRYPT_CONTENT_INFO info; - char rsa_data[] = "1.2.840.113549.1.7.1"; - - info.pszObjId = rsa_data; - info.Content.cbData = msg->bare_content_len; - info.Content.pbData = msg->bare_content; - ret = CryptEncodeObject(X509_ASN_ENCODING, PKCS_CONTENT_INFO, &info, - pvData, pcbData); + if (msg->base.streamed) + SetLastError(E_INVALIDARG); + else + { + CRYPT_CONTENT_INFO info; + char rsa_data[] = "1.2.840.113549.1.7.1"; + + info.pszObjId = rsa_data; + info.Content.cbData = msg->bare_content_len; + info.Content.pbData = msg->bare_content; + ret = CryptEncodeObject(X509_ASN_ENCODING, PKCS_CONTENT_INFO, &info, + pvData, pcbData); + } break; - } case CMSG_BARE_CONTENT_PARAM: - if (!pvData) + if (msg->base.streamed) + SetLastError(E_INVALIDARG); + else if (!pvData) { *pcbData = msg->bare_content_len; ret = TRUE; diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index ed54e82..2b0bc18 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -345,6 +345,12 @@ static void test_data_msg_open(void) static const BYTE msgData[] = { 1, 2, 3, 4 }; +static BOOL WINAPI nop_stream_output(const void *pvArg, BYTE *pb, DWORD cb, + BOOL final) +{ + return TRUE; +} + static void test_data_msg_update(void) { HCRYPTMSG msg; @@ -403,11 +409,12 @@ static void test_data_msg_get_param(void) HCRYPTMSG msg; DWORD size; BOOL ret; + CMSG_STREAM_INFO streamInfo = { 0, nop_stream_output, NULL }; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); - /* Content and bare content are always gettable */ + /* Content and bare content are always gettable when not streaming */ size = 0; ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); @@ -430,6 +437,19 @@ static void test_data_msg_get_param(void) ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); CryptMsgClose(msg); + + /* Can't get content or bare content when streaming */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, + NULL, &streamInfo); + SetLastError(0xdeadbeef); + ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + CryptMsgClose(msg); } static const BYTE dataEmptyBareContent[] = { 0x04,0x00 };
1
0
0
0
Juan Lang : crypt32: Add tests for streamed encoding of data messages.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: b18b05f53c08ae1ffc87c83447b9e562ea6bacd0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b18b05f53c08ae1ffc87c8344…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 11:17:35 2007 -0700 crypt32: Add tests for streamed encoding of data messages. --- dlls/crypt32/tests/msg.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 133 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index d67767f..ed54e82 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -441,11 +441,113 @@ static const BYTE dataContent[] = { 0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x06, 0x04,0x04,0x01,0x02,0x03,0x04 }; +struct update_accum +{ + DWORD cUpdates; + CRYPT_DATA_BLOB *updates; +}; + +static BOOL WINAPI accumulating_stream_output(const void *pvArg, BYTE *pb, + DWORD cb, BOOL final) +{ + struct update_accum *accum = (struct update_accum *)pvArg; + BOOL ret = FALSE; + + if (accum->cUpdates) + accum->updates = CryptMemRealloc(accum->updates, + (accum->cUpdates + 1) * sizeof(CRYPT_DATA_BLOB)); + else + accum->updates = CryptMemAlloc(sizeof(CRYPT_DATA_BLOB)); + if (accum->updates) + { + CRYPT_DATA_BLOB *blob = &accum->updates[accum->cUpdates]; + + blob->pbData = CryptMemAlloc(cb); + if (blob->pbData) + { + memcpy(blob->pbData, pb, cb); + blob->cbData = cb; + ret = TRUE; + } + accum->cUpdates++; + } + return ret; +} + +/* The updates of a (bogus) definite-length encoded message */ +static BYTE u1[] = { 0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01, + 0x07,0x01,0xa0,0x02,0x04,0x00 }; +static BYTE u2[] = { 0x01,0x02,0x03,0x04 }; +static CRYPT_DATA_BLOB b1[] = { + { sizeof(u1), u1 }, + { sizeof(u2), u2 }, + { sizeof(u2), u2 }, +}; +static const struct update_accum a1 = { sizeof(b1) / sizeof(b1[0]), b1 }; +/* The updates of a definite-length encoded message */ +static BYTE u3[] = { 0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01, + 0x07,0x01,0xa0,0x06,0x04,0x04 }; +static CRYPT_DATA_BLOB b2[] = { + { sizeof(u3), u3 }, + { sizeof(u2), u2 }, +}; +static const struct update_accum a2 = { sizeof(b2) / sizeof(b2[0]), b2 }; +/* The updates of an indefinite-length encoded message */ +static BYTE u4[] = { 0x30,0x80,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01, + 0x07,0x01,0xa0,0x80,0x24,0x80 }; +static BYTE u5[] = { 0x04,0x04 }; +static BYTE u6[] = { 0x00,0x00,0x00,0x00,0x00,0x00 }; +static CRYPT_DATA_BLOB b3[] = { + { sizeof(u4), u4 }, + { sizeof(u5), u5 }, + { sizeof(u2), u2 }, + { sizeof(u5), u5 }, + { sizeof(u2), u2 }, + { sizeof(u6), u6 }, +}; +static const struct update_accum a3 = { sizeof(b3) / sizeof(b3[0]), b3 }; + +static void check_updates(LPCSTR header, const struct update_accum *expected, + const struct update_accum *got) +{ + DWORD i; + + ok(expected->cUpdates == got->cUpdates, + "%s: expected %d updates, got %d\n", header, expected->cUpdates, + got->cUpdates); + if (expected->cUpdates == got->cUpdates) + for (i = 0; i < min(expected->cUpdates, got->cUpdates); i++) + { + ok(expected->updates[i].cbData == got->updates[i].cbData, + "%s, update %d: expected %d bytes, got %d\n", header, i, + expected->updates[i].cbData, got->updates[i].cbData); + if (expected->updates[i].cbData && expected->updates[i].cbData == + got->updates[i].cbData) + ok(!memcmp(expected->updates[i].pbData, got->updates[i].pbData, + got->updates[i].cbData), "%s, update %d: unexpected value\n", + header, i); + } +} + +/* Frees the updates stored in accum */ +static void free_updates(struct update_accum *accum) +{ + DWORD i; + + for (i = 0; i < accum->cUpdates; i++) + CryptMemFree(accum->updates[i].pbData); + CryptMemFree(accum->updates); + accum->updates = NULL; + accum->cUpdates = 0; +} + static void test_data_msg_encoding(void) { HCRYPTMSG msg; BOOL ret; static char oid[] = "1.2.3"; + struct update_accum accum = { 0, NULL }; + CMSG_STREAM_INFO streamInfo = { 0, accumulating_stream_output, &accum }; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); @@ -488,6 +590,37 @@ static void test_data_msg_encoding(void) check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent, sizeof(dataContent)); CryptMsgClose(msg); + /* A streaming message is DER encoded if the length is not 0xffffffff, but + * curiously, updates aren't validated to make sure they don't exceed the + * stated length. (The resulting output will of course fail to decode.) + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, + NULL, &streamInfo); + CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + CryptMsgClose(msg); + todo_wine + check_updates("bogus data message with definite length", &a1, &accum); + free_updates(&accum); + /* A valid definite-length encoding: */ + streamInfo.cbContent = sizeof(msgData); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, + NULL, &streamInfo); + CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + CryptMsgClose(msg); + todo_wine + check_updates("data message with definite length", &a2, &accum); + free_updates(&accum); + /* An indefinite-length encoding: */ + streamInfo.cbContent = 0xffffffff; + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, + NULL, &streamInfo); + CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + CryptMsgClose(msg); + todo_wine + check_updates("data message with indefinite length", &a3, &accum); + free_updates(&accum); } static void test_data_msg(void)
1
0
0
0
Juan Lang : crypt32: Test that inner content OID is ignored for data messages.
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: aa99cf8ec04801945f4c11f880f6fe64ec6c9dc8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=aa99cf8ec04801945f4c11f88…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 10:56:20 2007 -0700 crypt32: Test that inner content OID is ignored for data messages. --- dlls/crypt32/tests/msg.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 96489bc..d67767f 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -429,7 +429,6 @@ static void test_data_msg_get_param(void) ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); - CryptMsgClose(msg); } @@ -446,6 +445,7 @@ static void test_data_msg_encoding(void) { HCRYPTMSG msg; BOOL ret; + static char oid[] = "1.2.3"; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); @@ -474,6 +474,20 @@ static void test_data_msg_encoding(void) check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent, sizeof(dataContent)); CryptMsgClose(msg); + /* The inner OID is apparently ignored */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, oid, + NULL); + check_param("data bogus oid bare content", msg, CMSG_BARE_CONTENT_PARAM, + dataEmptyBareContent, sizeof(dataEmptyBareContent)); + check_param("data bogus oid content", msg, CMSG_CONTENT_PARAM, + dataEmptyContent, sizeof(dataEmptyContent)); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM, + dataBareContent, sizeof(dataBareContent)); + check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent, + sizeof(dataContent)); + CryptMsgClose(msg); } static void test_data_msg(void)
1
0
0
0
Juan Lang : crypt32: Make a copy of a passed-in stream info rather than assuming the pointer will live forever .
by Alexandre Julliard
10 Jul '07
10 Jul '07
Module: wine Branch: master Commit: 7e65d9439cd0141459cf3f0f3e1553c66518a71c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7e65d9439cd0141459cf3f0f3…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 9 10:55:42 2007 -0700 crypt32: Make a copy of a passed-in stream info rather than assuming the pointer will live forever. --- dlls/crypt32/msg.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index f5f1491..7280642 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -39,7 +39,8 @@ typedef struct _CryptMsgBase { LONG ref; DWORD open_flags; - PCMSG_STREAM_INFO stream_info; + BOOL streamed; + CMSG_STREAM_INFO stream_info; BOOL finalized; CryptMsgCloseFunc close; CryptMsgUpdateFunc update; @@ -52,7 +53,16 @@ static inline void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags, { msg->ref = 1; msg->open_flags = dwFlags; - msg->stream_info = pStreamInfo; + if (pStreamInfo) + { + msg->streamed = TRUE; + memcpy(&msg->stream_info, pStreamInfo, sizeof(msg->stream_info)); + } + else + { + msg->streamed = FALSE; + memset(&msg->stream_info, 0, sizeof(msg->stream_info)); + } msg->close = close; msg->get_param = get_param; msg->update = update; @@ -106,7 +116,7 @@ static BOOL CDataEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &msg->bare_content, &msg->bare_content_len); - if (ret && msg->base.stream_info) + if (ret && msg->base.streamed) FIXME("stream info unimplemented\n"); } }
1
0
0
0
← Newer
1
...
71
72
73
74
75
76
77
...
96
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Results per page:
10
25
50
100
200