Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
74bf713b
Commit
74bf713b
authored
Jun 28, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Jun 29, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement CryptMsgUpdate for data messages opened to encode.
parent
b6bf594a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
8 deletions
+53
-8
msg.c
dlls/crypt32/msg.c
+53
-0
msg.c
dlls/crypt32/tests/msg.c
+0
-8
No files found.
dlls/crypt32/msg.c
View file @
74bf713b
...
...
@@ -58,8 +58,57 @@ static inline void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags,
typedef
struct
_CDataEncodeMsg
{
CryptMsgBase
base
;
DWORD
bare_content_len
;
LPBYTE
bare_content
;
}
CDataEncodeMsg
;
static
const
BYTE
empty_data_content
[]
=
{
0x04
,
0x00
};
static
void
CDataEncodeMsg_Close
(
HCRYPTMSG
hCryptMsg
)
{
CDataEncodeMsg
*
msg
=
(
CDataEncodeMsg
*
)
hCryptMsg
;
if
(
msg
->
bare_content
!=
empty_data_content
)
LocalFree
(
msg
->
bare_content
);
}
static
BOOL
CDataEncodeMsg_Update
(
HCRYPTMSG
hCryptMsg
,
const
BYTE
*
pbData
,
DWORD
cbData
,
BOOL
fFinal
)
{
CDataEncodeMsg
*
msg
=
(
CDataEncodeMsg
*
)
hCryptMsg
;
BOOL
ret
=
FALSE
;
if
(
msg
->
base
.
finalized
)
SetLastError
(
CRYPT_E_MSG_ERROR
);
else
if
(
!
fFinal
)
{
if
(
msg
->
base
.
open_flags
&
CMSG_DETACHED_FLAG
)
SetLastError
(
E_INVALIDARG
);
else
SetLastError
(
CRYPT_E_MSG_ERROR
);
}
else
{
msg
->
base
.
finalized
=
TRUE
;
if
(
!
cbData
)
SetLastError
(
E_INVALIDARG
);
else
{
CRYPT_DATA_BLOB
blob
=
{
cbData
,
(
LPBYTE
)
pbData
};
/* data messages don't allow non-final updates, don't bother
* checking whether data already exist, they can't.
*/
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
)
FIXME
(
"stream info unimplemented
\n
"
);
}
}
return
ret
;
}
static
HCRYPTMSG
CDataEncodeMsg_Open
(
DWORD
dwFlags
,
const
void
*
pvMsgEncodeInfo
,
LPSTR
pszInnerContentObjID
,
PCMSG_STREAM_INFO
pStreamInfo
)
{
...
...
@@ -75,6 +124,10 @@ static HCRYPTMSG CDataEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo,
if
(
msg
)
{
CryptMsgBase_Init
((
CryptMsgBase
*
)
msg
,
dwFlags
,
pStreamInfo
);
msg
->
base
.
close
=
CDataEncodeMsg_Close
;
msg
->
base
.
update
=
CDataEncodeMsg_Update
;
msg
->
bare_content_len
=
sizeof
(
empty_data_content
);
msg
->
bare_content
=
(
LPBYTE
)
empty_data_content
;
}
return
(
HCRYPTMSG
)
msg
;
}
...
...
dlls/crypt32/tests/msg.c
View file @
74bf713b
...
...
@@ -309,17 +309,14 @@ static void test_data_msg_update(void)
/* Can't update a message that wasn't opened detached with final = FALSE */
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgUpdate
(
msg
,
NULL
,
0
,
FALSE
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_MSG_ERROR
,
"Expected CRYPT_E_MSG_ERROR, got %x
\n
"
,
GetLastError
());
/* Updating it with final = TRUE succeeds */
ret
=
CryptMsgUpdate
(
msg
,
msgData
,
sizeof
(
msgData
),
TRUE
);
todo_wine
ok
(
ret
,
"CryptMsgUpdate failed: %x
\n
"
,
GetLastError
());
/* Any subsequent update will fail, as the last was final */
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgUpdate
(
msg
,
msgData
,
sizeof
(
msgData
),
TRUE
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_MSG_ERROR
,
"Expected CRYPT_E_MSG_ERROR, got %x
\n
"
,
GetLastError
());
CryptMsgClose
(
msg
);
...
...
@@ -329,7 +326,6 @@ static void test_data_msg_update(void)
/* Can't update a message with no data */
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgUpdate
(
msg
,
NULL
,
0
,
TRUE
);
todo_wine
{
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %x
\n
"
,
GetLastError
());
/* Curiously, a valid update will now fail as well, presumably because of
...
...
@@ -338,7 +334,6 @@ static void test_data_msg_update(void)
ret
=
CryptMsgUpdate
(
msg
,
msgData
,
sizeof
(
msgData
),
TRUE
);
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_MSG_ERROR
,
"Expected CRYPT_E_MSG_ERROR, got %x
\n
"
,
GetLastError
());
}
CryptMsgClose
(
msg
);
msg
=
CryptMsgOpenToEncode
(
PKCS_7_ASN_ENCODING
,
CMSG_DETACHED_FLAG
,
...
...
@@ -346,16 +341,13 @@ static void test_data_msg_update(void)
/* Dont appear to be able to update CMSG-DATA with non-final updates */
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgUpdate
(
msg
,
NULL
,
0
,
FALSE
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgUpdate
(
msg
,
msgData
,
sizeof
(
msgData
),
FALSE
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %x
\n
"
,
GetLastError
());
ret
=
CryptMsgUpdate
(
msg
,
msgData
,
sizeof
(
msgData
),
TRUE
);
todo_wine
ok
(
ret
,
"CryptMsgUpdate failed: %x
\n
"
,
GetLastError
());
CryptMsgClose
(
msg
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment