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
f44ae748
Commit
f44ae748
authored
Dec 15, 2010
by
Alexander Morozov
Committed by
Alexandre Julliard
Dec 16, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement getting content and some parameters from a decoded enveloped message.
parent
dd75ab38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
15 deletions
+87
-15
msg.c
dlls/crypt32/msg.c
+87
-0
msg.c
dlls/crypt32/tests/msg.c
+0
-15
No files found.
dlls/crypt32/msg.c
View file @
f44ae748
...
...
@@ -2881,6 +2881,89 @@ static BOOL CRYPT_CopySignerCertInfo(void *pvData, DWORD *pcbData,
return
ret
;
}
static
BOOL
CRYPT_CopyRecipientInfo
(
void
*
pvData
,
DWORD
*
pcbData
,
const
CERT_ISSUER_SERIAL_NUMBER
*
in
)
{
DWORD
size
=
sizeof
(
CERT_INFO
);
BOOL
ret
;
TRACE
(
"(%p, %d, %p)
\n
"
,
pvData
,
pvData
?
*
pcbData
:
0
,
in
);
size
+=
in
->
SerialNumber
.
cbData
;
size
+=
in
->
Issuer
.
cbData
;
if
(
!
pvData
)
{
*
pcbData
=
size
;
ret
=
TRUE
;
}
else
if
(
*
pcbData
<
size
)
{
*
pcbData
=
size
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
LPBYTE
nextData
=
(
BYTE
*
)
pvData
+
sizeof
(
CERT_INFO
);
CERT_INFO
*
out
=
pvData
;
CRYPT_CopyBlob
(
&
out
->
SerialNumber
,
&
in
->
SerialNumber
,
&
nextData
);
CRYPT_CopyBlob
(
&
out
->
Issuer
,
&
in
->
Issuer
,
&
nextData
);
ret
=
TRUE
;
}
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
static
BOOL
CDecodeEnvelopedMsg_GetParam
(
CDecodeMsg
*
msg
,
DWORD
dwParamType
,
DWORD
dwIndex
,
void
*
pvData
,
DWORD
*
pcbData
)
{
BOOL
ret
=
FALSE
;
switch
(
dwParamType
)
{
case
CMSG_TYPE_PARAM
:
ret
=
CRYPT_CopyParam
(
pvData
,
pcbData
,
&
msg
->
type
,
sizeof
(
msg
->
type
));
break
;
case
CMSG_CONTENT_PARAM
:
if
(
msg
->
u
.
enveloped_data
.
data
)
ret
=
CRYPT_CopyParam
(
pvData
,
pcbData
,
msg
->
u
.
enveloped_data
.
content
.
pbData
,
msg
->
u
.
enveloped_data
.
content
.
cbData
);
else
SetLastError
(
CRYPT_E_INVALID_MSG_TYPE
);
break
;
case
CMSG_RECIPIENT_COUNT_PARAM
:
if
(
msg
->
u
.
enveloped_data
.
data
)
ret
=
CRYPT_CopyParam
(
pvData
,
pcbData
,
&
msg
->
u
.
enveloped_data
.
data
->
cRecipientInfo
,
sizeof
(
DWORD
));
else
SetLastError
(
CRYPT_E_INVALID_MSG_TYPE
);
break
;
case
CMSG_RECIPIENT_INFO_PARAM
:
if
(
msg
->
u
.
enveloped_data
.
data
)
{
if
(
dwIndex
<
msg
->
u
.
enveloped_data
.
data
->
cRecipientInfo
)
{
PCMSG_KEY_TRANS_RECIPIENT_INFO
recipientInfo
=
&
msg
->
u
.
enveloped_data
.
data
->
rgRecipientInfo
[
dwIndex
];
ret
=
CRYPT_CopyRecipientInfo
(
pvData
,
pcbData
,
&
recipientInfo
->
RecipientId
.
u
.
IssuerSerialNumber
);
}
else
SetLastError
(
CRYPT_E_INVALID_INDEX
);
}
else
SetLastError
(
CRYPT_E_INVALID_MSG_TYPE
);
break
;
default:
FIXME
(
"unimplemented for %d
\n
"
,
dwParamType
);
SetLastError
(
CRYPT_E_INVALID_MSG_TYPE
);
}
return
ret
;
}
static
BOOL
CDecodeSignedMsg_GetParam
(
CDecodeMsg
*
msg
,
DWORD
dwParamType
,
DWORD
dwIndex
,
void
*
pvData
,
DWORD
*
pcbData
)
{
...
...
@@ -3073,6 +3156,10 @@ static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
ret
=
CDecodeHashMsg_GetParam
(
msg
,
dwParamType
,
dwIndex
,
pvData
,
pcbData
);
break
;
case
CMSG_ENVELOPED
:
ret
=
CDecodeEnvelopedMsg_GetParam
(
msg
,
dwParamType
,
dwIndex
,
pvData
,
pcbData
);
break
;
case
CMSG_SIGNED
:
ret
=
CDecodeSignedMsg_GetParam
(
msg
,
dwParamType
,
dwIndex
,
pvData
,
pcbData
);
...
...
dlls/crypt32/tests/msg.c
View file @
f44ae748
...
...
@@ -3057,7 +3057,6 @@ static void test_decode_msg_get_param(void)
NULL
);
CryptMsgUpdate
(
msg
,
envelopedEmptyBareContent
,
sizeof
(
envelopedEmptyBareContent
),
TRUE
);
todo_wine
check_param
(
"enveloped empty bare content"
,
msg
,
CMSG_CONTENT_PARAM
,
NULL
,
0
);
CryptMsgClose
(
msg
);
...
...
@@ -3065,7 +3064,6 @@ static void test_decode_msg_get_param(void)
msg
=
CryptMsgOpenToDecode
(
PKCS_7_ASN_ENCODING
,
0
,
0
,
0
,
NULL
,
NULL
);
CryptMsgUpdate
(
msg
,
envelopedEmptyContent
,
sizeof
(
envelopedEmptyContent
),
TRUE
);
todo_wine
check_param
(
"enveloped empty content"
,
msg
,
CMSG_CONTENT_PARAM
,
NULL
,
0
);
CryptMsgClose
(
msg
);
...
...
@@ -3080,7 +3078,6 @@ static void test_decode_msg_get_param(void)
msg
=
CryptMsgOpenToDecode
(
PKCS_7_ASN_ENCODING
,
0
,
0
,
0
,
NULL
,
NULL
);
CryptMsgUpdate
(
msg
,
envelopedMessage
,
sizeof
(
envelopedMessage
),
TRUE
);
todo_wine
check_param
(
"enveloped message before decrypting"
,
msg
,
CMSG_CONTENT_PARAM
,
envelopedMessage
+
sizeof
(
envelopedMessage
)
-
4
,
4
);
if
(
key
)
...
...
@@ -3094,7 +3091,6 @@ static void test_decode_msg_get_param(void)
ret
=
CryptMsgControl
(
msg
,
0
,
CMSG_CTRL_DECRYPT
,
&
decryptPara
);
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_ALREADY_DECRYPTED
,
"expected CRYPT_E_ALREADY_DECRYPTED, got %08x
\n
"
,
GetLastError
());
todo_wine
check_param
(
"enveloped message"
,
msg
,
CMSG_CONTENT_PARAM
,
msgData
,
sizeof
(
msgData
));
}
...
...
@@ -3106,7 +3102,6 @@ static void test_decode_msg_get_param(void)
NULL
);
CryptMsgUpdate
(
msg
,
envelopedBareMessage
,
sizeof
(
envelopedBareMessage
),
TRUE
);
todo_wine
check_param
(
"enveloped bare message before decrypting"
,
msg
,
CMSG_CONTENT_PARAM
,
envelopedBareMessage
+
sizeof
(
envelopedBareMessage
)
-
4
,
4
);
...
...
@@ -3116,7 +3111,6 @@ static void test_decode_msg_get_param(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgControl
(
msg
,
0
,
CMSG_CTRL_DECRYPT
,
&
decryptPara
);
ok
(
ret
,
"CryptMsgControl failed: %08x
\n
"
,
GetLastError
());
todo_wine
check_param
(
"enveloped bare message"
,
msg
,
CMSG_CONTENT_PARAM
,
msgData
,
sizeof
(
msgData
));
}
...
...
@@ -3132,21 +3126,17 @@ static void test_decode_msg_get_param(void)
CryptMsgUpdate
(
msg
,
envelopedMessageWith3Recps
,
sizeof
(
envelopedMessageWith3Recps
),
TRUE
);
value
=
3
;
todo_wine
check_param
(
"recipient count"
,
msg
,
CMSG_RECIPIENT_COUNT_PARAM
,
(
const
BYTE
*
)
&
value
,
sizeof
(
value
));
size
=
0
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_RECIPIENT_INFO_PARAM
,
3
,
NULL
,
&
size
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_INVALID_INDEX
,
"expected CRYPT_E_INVALID_INDEX, got %08x
\n
"
,
GetLastError
());
size
=
0
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_RECIPIENT_INFO_PARAM
,
2
,
NULL
,
&
size
);
todo_wine
ok
(
ret
,
"CryptMsgGetParam failed: %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
size
>=
142
,
"unexpected size: %u
\n
"
,
size
);
if
(
ret
)
buf
=
CryptMemAlloc
(
size
);
...
...
@@ -3158,18 +3148,13 @@ static void test_decode_msg_get_param(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_RECIPIENT_INFO_PARAM
,
2
,
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptMsgGetParam failed: %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
certInfo
->
SerialNumber
.
cbData
==
sizeof
(
serialNumber
),
"unexpected serial number size: %u
\n
"
,
certInfo
->
SerialNumber
.
cbData
);
todo_wine
ok
(
!
memcmp
(
certInfo
->
SerialNumber
.
pbData
,
serialNumber
,
sizeof
(
serialNumber
)),
"unexpected serial number
\n
"
);
todo_wine
ok
(
certInfo
->
Issuer
.
cbData
==
sizeof
(
issuer
),
"unexpected issuer size: %u
\n
"
,
certInfo
->
Issuer
.
cbData
);
todo_wine
ok
(
!
memcmp
(
certInfo
->
Issuer
.
pbData
,
issuer
,
sizeof
(
issuer
)),
"unexpected issuer
\n
"
);
CryptMemFree
(
buf
);
...
...
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