Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Mayr
wine
Commits
74bf713b
Commit
74bf713b
authored
17 years ago
by
Juan Lang
Committed by
Alexandre Julliard
17 years ago
Browse files
Options
Downloads
Patches
Plain Diff
crypt32: Implement CryptMsgUpdate for data messages opened to encode.
parent
b6bf594a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/crypt32/msg.c
+53
-0
53 additions, 0 deletions
dlls/crypt32/msg.c
dlls/crypt32/tests/msg.c
+0
-8
0 additions, 8 deletions
dlls/crypt32/tests/msg.c
with
53 additions
and
8 deletions
dlls/crypt32/msg.c
+
53
−
0
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
;
}
...
...
This diff is collapsed.
Click to expand it.
dlls/crypt32/tests/msg.c
+
0
−
8
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
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment