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
62cbf426
Commit
62cbf426
authored
Dec 11, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Dec 12, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Split querying PKCS messages into helper functions.
parent
626a6fe1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
80 deletions
+112
-80
object.c
dlls/crypt32/object.c
+112
-80
No files found.
dlls/crypt32/object.c
View file @
62cbf426
...
...
@@ -322,6 +322,110 @@ static BOOL CRYPT_QuerySerializedStoreObject(DWORD dwObjectType,
return
ret
;
}
static
BOOL
CRYPT_QuerySignedMessage
(
const
CRYPT_DATA_BLOB
*
blob
,
DWORD
*
pdwMsgAndCertEncodingType
,
DWORD
*
pdwContentType
,
HCRYPTMSG
*
phMsg
)
{
DWORD
encodingType
=
X509_ASN_ENCODING
|
PKCS_7_ASN_ENCODING
;
BOOL
ret
=
FALSE
;
HCRYPTMSG
msg
;
if
((
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
0
,
0
,
NULL
,
NULL
)))
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
ret
)
{
DWORD
type
,
len
=
sizeof
(
type
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_TYPE_PARAM
,
0
,
&
type
,
&
len
);
if
(
ret
)
{
if
(
type
!=
CMSG_SIGNED
)
{
SetLastError
(
ERROR_INVALID_DATA
);
ret
=
FALSE
;
}
}
}
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
CMSG_SIGNED
,
0
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
NULL
;
}
}
}
}
if
(
ret
)
{
if
(
pdwMsgAndCertEncodingType
)
*
pdwMsgAndCertEncodingType
=
encodingType
;
if
(
pdwContentType
)
*
pdwContentType
=
CERT_QUERY_CONTENT_PKCS7_SIGNED
;
if
(
phMsg
)
*
phMsg
=
msg
;
}
return
ret
;
}
static
BOOL
CRYPT_QueryUnsignedMessage
(
const
CRYPT_DATA_BLOB
*
blob
,
DWORD
*
pdwMsgAndCertEncodingType
,
DWORD
*
pdwContentType
,
HCRYPTMSG
*
phMsg
)
{
DWORD
encodingType
=
X509_ASN_ENCODING
|
PKCS_7_ASN_ENCODING
;
BOOL
ret
=
FALSE
;
HCRYPTMSG
msg
;
if
((
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
0
,
0
,
NULL
,
NULL
)))
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
ret
)
{
DWORD
type
,
len
=
sizeof
(
type
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_TYPE_PARAM
,
0
,
&
type
,
&
len
);
if
(
ret
)
{
if
(
type
!=
CMSG_DATA
)
{
SetLastError
(
ERROR_INVALID_DATA
);
ret
=
FALSE
;
}
}
}
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
CMSG_DATA
,
0
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
NULL
;
}
}
}
}
if
(
ret
)
{
if
(
pdwMsgAndCertEncodingType
)
*
pdwMsgAndCertEncodingType
=
encodingType
;
if
(
pdwContentType
)
*
pdwContentType
=
CERT_QUERY_CONTENT_PKCS7_SIGNED
;
if
(
phMsg
)
*
phMsg
=
msg
;
}
return
ret
;
}
/* Used to decode non-embedded messages */
static
BOOL
CRYPT_QueryMessageObject
(
DWORD
dwObjectType
,
const
void
*
pvObject
,
DWORD
dwExpectedContentTypeFlags
,
DWORD
*
pdwMsgAndCertEncodingType
,
...
...
@@ -354,88 +458,16 @@ static BOOL CRYPT_QueryMessageObject(DWORD dwObjectType, const void *pvObject,
return
FALSE
;
ret
=
FALSE
;
/* Try it first as a PKCS content info */
if
((
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
)
||
(
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED
))
{
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
0
,
0
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
ret
)
{
DWORD
type
,
len
=
sizeof
(
type
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_TYPE_PARAM
,
0
,
&
type
,
&
len
);
if
(
ret
)
{
if
((
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
))
{
if
(
type
!=
CMSG_SIGNED
)
{
SetLastError
(
ERROR_INVALID_DATA
);
ret
=
FALSE
;
}
else
if
(
pdwContentType
)
*
pdwContentType
=
CERT_QUERY_CONTENT_PKCS7_SIGNED
;
}
else
if
((
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED
))
{
if
(
type
!=
CMSG_DATA
)
{
SetLastError
(
ERROR_INVALID_DATA
);
ret
=
FALSE
;
}
else
if
(
pdwContentType
)
*
pdwContentType
=
CERT_QUERY_CONTENT_PKCS7_UNSIGNED
;
}
}
}
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
NULL
;
}
}
}
/* Failing that, try explicitly typed messages */
if
(
!
ret
&&
(
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
))
{
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
CMSG_SIGNED
,
0
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
NULL
;
}
}
if
(
msg
&&
pdwContentType
)
*
pdwContentType
=
CERT_QUERY_CONTENT_PKCS7_SIGNED
;
}
/* Try it first as a signed message */
if
(
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
)
ret
=
CRYPT_QuerySignedMessage
(
blob
,
pdwMsgAndCertEncodingType
,
pdwContentType
,
&
msg
);
/* Failing that, try as an unsigned message */
if
(
!
ret
&&
(
dwExpectedContentTypeFlags
&
CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED
))
{
msg
=
CryptMsgOpenToDecode
(
encodingType
,
0
,
CMSG_DATA
,
0
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
blob
->
pbData
,
blob
->
cbData
,
TRUE
);
if
(
!
ret
)
{
CryptMsgClose
(
msg
);
msg
=
NULL
;
}
}
if
(
msg
&&
pdwContentType
)
*
pdwContentType
=
CERT_QUERY_CONTENT_PKCS7_UNSIGNED
;
}
if
(
pdwMsgAndCertEncodingType
)
*
pdwMsgAndCertEncodingType
=
encodingType
;
if
(
msg
)
ret
=
CRYPT_QueryUnsignedMessage
(
blob
,
pdwMsgAndCertEncodingType
,
pdwContentType
,
&
msg
);
if
(
ret
)
{
if
(
phMsg
)
*
phMsg
=
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