Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
db6c8e23
Commit
db6c8e23
authored
Aug 20, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Aug 21, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Add support for encoding PKCS_SMIME_CAPABILITIES.
parent
70744f07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
4 deletions
+95
-4
encode.c
dlls/crypt32/encode.c
+95
-0
encode.c
dlls/crypt32/tests/encode.c
+0
-4
No files found.
dlls/crypt32/encode.c
View file @
db6c8e23
...
...
@@ -1404,6 +1404,96 @@ static BOOL WINAPI CRYPT_AsnEncodeUnicodeName(DWORD dwCertEncodingType,
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodeSMIMECapability
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
=
FALSE
;
__TRY
{
const
CRYPT_SMIME_CAPABILITY
*
capability
=
(
const
CRYPT_SMIME_CAPABILITY
*
)
pvStructInfo
;
if
(
!
capability
->
pszObjId
)
SetLastError
(
E_INVALIDARG
);
else
{
struct
AsnEncodeSequenceItem
items
[]
=
{
{
capability
->
pszObjId
,
CRYPT_AsnEncodeOid
,
0
},
{
&
capability
->
Parameters
,
CRYPT_CopyEncodedBlob
,
0
},
};
ret
=
CRYPT_AsnEncodeSequence
(
dwCertEncodingType
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
dwFlags
,
pEncodePara
,
pbEncoded
,
pcbEncoded
);
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
}
__ENDTRY
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodeSMIMECapabilities
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
=
FALSE
;
__TRY
{
DWORD
bytesNeeded
,
dataLen
,
lenBytes
,
i
;
const
CRYPT_SMIME_CAPABILITIES
*
capabilities
=
(
const
CRYPT_SMIME_CAPABILITIES
*
)
pvStructInfo
;
ret
=
TRUE
;
for
(
i
=
0
,
dataLen
=
0
;
ret
&&
i
<
capabilities
->
cCapability
;
i
++
)
{
DWORD
size
;
ret
=
CRYPT_AsnEncodeSMIMECapability
(
dwCertEncodingType
,
NULL
,
&
capabilities
->
rgCapability
[
i
],
0
,
NULL
,
NULL
,
&
size
);
if
(
ret
)
dataLen
+=
size
;
}
CRYPT_EncodeLen
(
dataLen
,
NULL
,
&
lenBytes
);
bytesNeeded
=
1
+
lenBytes
+
dataLen
;
if
(
!
pbEncoded
)
*
pcbEncoded
=
bytesNeeded
;
else
{
if
((
ret
=
CRYPT_EncodeEnsureSpace
(
dwFlags
,
pEncodePara
,
pbEncoded
,
pcbEncoded
,
bytesNeeded
)))
{
if
(
dwFlags
&
CRYPT_ENCODE_ALLOC_FLAG
)
pbEncoded
=
*
(
BYTE
**
)
pbEncoded
;
*
pbEncoded
++
=
ASN_SEQUENCEOF
;
CRYPT_EncodeLen
(
dataLen
,
pbEncoded
,
&
lenBytes
);
pbEncoded
+=
lenBytes
;
for
(
i
=
0
;
i
<
capabilities
->
cCapability
;
i
++
)
{
DWORD
size
=
dataLen
;
ret
=
CRYPT_AsnEncodeSMIMECapability
(
dwCertEncodingType
,
NULL
,
&
capabilities
->
rgCapability
[
i
],
0
,
NULL
,
pbEncoded
,
&
size
);
pbEncoded
+=
size
;
dataLen
-=
size
;
}
}
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
}
__ENDTRY
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodePKCSAttribute
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
...
...
@@ -3684,6 +3774,9 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
case
LOWORD
(
X509_ENHANCED_KEY_USAGE
):
encodeFunc
=
CRYPT_AsnEncodeEnhancedKeyUsage
;
break
;
case
LOWORD
(
PKCS_SMIME_CAPABILITIES
):
encodeFunc
=
CRYPT_AsnEncodeSMIMECapabilities
;
break
;
case
LOWORD
(
PKCS_ATTRIBUTES
):
encodeFunc
=
CRYPT_AsnEncodePKCSAttributes
;
break
;
...
...
@@ -3705,6 +3798,8 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
encodeFunc
=
CRYPT_AsnEncodeExtensions
;
else
if
(
!
strcmp
(
lpszStructType
,
szOID_RSA_signingTime
))
encodeFunc
=
CRYPT_AsnEncodeUtcTime
;
else
if
(
!
strcmp
(
lpszStructType
,
szOID_RSA_SMIMECapabilities
))
encodeFunc
=
CRYPT_AsnEncodeUtcTime
;
else
if
(
!
strcmp
(
lpszStructType
,
szOID_AUTHORITY_KEY_IDENTIFIER
))
encodeFunc
=
CRYPT_AsnEncodeAuthorityKeyId
;
else
if
(
!
strcmp
(
lpszStructType
,
szOID_AUTHORITY_KEY_IDENTIFIER2
))
...
...
dlls/crypt32/tests/encode.c
View file @
db6c8e23
...
...
@@ -5180,7 +5180,6 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
capabilities
.
cCapability
=
0
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
PKCS_SMIME_CAPABILITIES
,
&
capabilities
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
buf
)
{
...
...
@@ -5198,13 +5197,11 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
SetLastError
(
0xdeadbeef
);
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
PKCS_SMIME_CAPABILITIES
,
&
capabilities
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
capability
[
0
].
pszObjId
=
oid1
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
PKCS_SMIME_CAPABILITIES
,
&
capabilities
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
buf
)
{
...
...
@@ -5217,7 +5214,6 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
capabilities
.
cCapability
=
2
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
PKCS_SMIME_CAPABILITIES
,
&
capabilities
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
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