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
02ab124c
Commit
02ab124c
authored
Dec 08, 2010
by
Alexander Morozov
Committed by
Alexandre Julliard
Dec 08, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement CryptEncryptMessage.
parent
2a2020d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
18 deletions
+55
-18
message.c
dlls/crypt32/message.c
+55
-2
message.c
dlls/crypt32/tests/message.c
+0
-16
No files found.
dlls/crypt32/message.c
View file @
02ab124c
...
...
@@ -536,8 +536,61 @@ BOOL WINAPI CryptEncryptMessage(PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara,
const
BYTE
*
pbToBeEncrypted
,
DWORD
cbToBeEncrypted
,
BYTE
*
pbEncryptedBlob
,
DWORD
*
pcbEncryptedBlob
)
{
FIXME
(
"(%p, %d, %p, %p, %d, %p, %p): stub
\n
"
,
pEncryptPara
,
cRecipientCert
,
BOOL
ret
=
TRUE
;
DWORD
i
;
PCERT_INFO
*
certInfo
=
NULL
;
CMSG_ENVELOPED_ENCODE_INFO
envelopedInfo
;
HCRYPTMSG
msg
=
0
;
TRACE
(
"(%p, %d, %p, %p, %d, %p, %p)
\n
"
,
pEncryptPara
,
cRecipientCert
,
rgpRecipientCert
,
pbToBeEncrypted
,
cbToBeEncrypted
,
pbEncryptedBlob
,
pcbEncryptedBlob
);
return
FALSE
;
if
(
pEncryptPara
->
cbSize
!=
sizeof
(
CRYPT_ENCRYPT_MESSAGE_PARA
)
||
GET_CMSG_ENCODING_TYPE
(
pEncryptPara
->
dwMsgEncodingType
)
!=
PKCS_7_ASN_ENCODING
)
{
*
pcbEncryptedBlob
=
0
;
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
memset
(
&
envelopedInfo
,
0
,
sizeof
(
envelopedInfo
));
envelopedInfo
.
cbSize
=
sizeof
(
envelopedInfo
);
envelopedInfo
.
hCryptProv
=
pEncryptPara
->
hCryptProv
;
envelopedInfo
.
ContentEncryptionAlgorithm
=
pEncryptPara
->
ContentEncryptionAlgorithm
;
envelopedInfo
.
pvEncryptionAuxInfo
=
pEncryptPara
->
pvEncryptionAuxInfo
;
if
(
cRecipientCert
)
{
certInfo
=
CryptMemAlloc
(
sizeof
(
PCERT_INFO
)
*
cRecipientCert
);
if
(
certInfo
)
{
for
(
i
=
0
;
i
<
cRecipientCert
;
++
i
)
certInfo
[
i
]
=
rgpRecipientCert
[
i
]
->
pCertInfo
;
envelopedInfo
.
cRecipients
=
cRecipientCert
;
envelopedInfo
.
rgpRecipientCert
=
certInfo
;
}
else
ret
=
FALSE
;
}
if
(
ret
)
msg
=
CryptMsgOpenToEncode
(
pEncryptPara
->
dwMsgEncodingType
,
0
,
CMSG_ENVELOPED
,
&
envelopedInfo
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
pbToBeEncrypted
,
cbToBeEncrypted
,
TRUE
);
if
(
ret
)
ret
=
CryptMsgGetParam
(
msg
,
CMSG_CONTENT_PARAM
,
0
,
pbEncryptedBlob
,
pcbEncryptedBlob
);
CryptMsgClose
(
msg
);
}
else
ret
=
FALSE
;
CryptMemFree
(
certInfo
);
if
(
!
ret
)
*
pcbEncryptedBlob
=
0
;
return
ret
;
}
dlls/crypt32/tests/message.c
View file @
02ab124c
...
...
@@ -1225,10 +1225,8 @@ static void test_encrypt_message(void)
encryptedBlobSize
=
255
;
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
NULL
,
0
,
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
!
encryptedBlobSize
,
"unexpected size %d
\n
"
,
encryptedBlobSize
);
para
.
cbSize
=
sizeof
(
para
);
para
.
dwMsgEncodingType
=
X509_ASN_ENCODING
;
...
...
@@ -1236,23 +1234,19 @@ static void test_encrypt_message(void)
encryptedBlobSize
=
255
;
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
NULL
,
0
,
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
!
encryptedBlobSize
,
"unexpected size %d
\n
"
,
encryptedBlobSize
);
para
.
dwMsgEncodingType
=
PKCS_7_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
encryptedBlobSize
=
255
;
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
NULL
,
0
,
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
!
ret
&&
(
GetLastError
()
==
CRYPT_E_UNKNOWN_ALGO
||
GetLastError
()
==
E_INVALIDARG
),
/* Win9x */
"expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
!
encryptedBlobSize
,
"unexpected size %d
\n
"
,
encryptedBlobSize
);
para
.
hCryptProv
=
hCryptProv
;
...
...
@@ -1262,7 +1256,6 @@ static void test_encrypt_message(void)
encryptedBlobSize
=
0
;
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
NULL
,
0
,
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
||
broken
(
!
ret
)
/* Win9x */
,
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
...
...
@@ -1274,9 +1267,7 @@ static void test_encrypt_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
NULL
,
0
,
encryptedBlob
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
,
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
encryptedBlobSize
==
sizeof
(
encryptedMessage
),
"unexpected size of encrypted blob %d
\n
"
,
encryptedBlobSize
);
ok
(
!
memcmp
(
encryptedBlob
,
encryptedMessage
,
encryptedBlobSize
),
...
...
@@ -1289,7 +1280,6 @@ static void test_encrypt_message(void)
encryptedBlobSize
=
0
;
ret
=
CryptEncryptMessage
(
&
para
,
2
,
certs
,
NULL
,
0
,
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
,
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -1299,7 +1289,6 @@ static void test_encrypt_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptEncryptMessage
(
&
para
,
2
,
certs
,
NULL
,
0
,
encryptedBlob
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
,
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
CryptMemFree
(
encryptedBlob
);
}
...
...
@@ -1309,7 +1298,6 @@ static void test_encrypt_message(void)
encryptedBlobSize
=
0
;
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
blob
,
sizeof
(
blob
),
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
||
broken
(
!
ret
)
/* Win9x */
,
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
...
...
@@ -1321,13 +1309,11 @@ static void test_encrypt_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptEncryptMessage
(
&
para
,
0
,
NULL
,
blob
,
sizeof
(
blob
),
encryptedBlob
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_PERM
),
/* some NT4 */
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
todo_wine
ok
(
encryptedBlobSize
==
55
,
"unexpected size of encrypted blob %d
\n
"
,
encryptedBlobSize
);
}
...
...
@@ -1339,7 +1325,6 @@ static void test_encrypt_message(void)
encryptedBlobSize
=
0
;
ret
=
CryptEncryptMessage
(
&
para
,
2
,
certs
,
blob
,
sizeof
(
blob
),
NULL
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
,
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -1349,7 +1334,6 @@ static void test_encrypt_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptEncryptMessage
(
&
para
,
2
,
certs
,
blob
,
sizeof
(
blob
),
encryptedBlob
,
&
encryptedBlobSize
);
todo_wine
ok
(
ret
||
broken
(
!
ret
),
/* some Win95 and some NT4 */
"CryptEncryptMessage failed: %08x
\n
"
,
GetLastError
());
...
...
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