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
7e848b6c
Commit
7e848b6c
authored
Aug 27, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Aug 28, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement authority info access encoding.
parent
76f400b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
5 deletions
+82
-5
encode.c
dlls/crypt32/encode.c
+82
-0
encode.c
dlls/crypt32/tests/encode.c
+0
-5
No files found.
dlls/crypt32/encode.c
View file @
7e848b6c
...
...
@@ -2347,6 +2347,83 @@ static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId2(DWORD dwCertEncodingType,
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodeAccessDescription
(
const
CERT_ACCESS_DESCRIPTION
*
descr
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
struct
AsnEncodeSequenceItem
items
[]
=
{
{
descr
->
pszAccessMethod
,
CRYPT_AsnEncodeOid
,
0
},
{
&
descr
->
AccessLocation
,
CRYPT_AsnEncodeAltNameEntry
,
0
},
};
if
(
!
descr
->
pszAccessMethod
)
{
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
return
CRYPT_AsnEncodeSequence
(
X509_ASN_ENCODING
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
0
,
NULL
,
pbEncoded
,
pcbEncoded
);
}
static
BOOL
WINAPI
CRYPT_AsnEncodeAuthorityInfoAccess
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
;
__TRY
{
DWORD
bytesNeeded
,
dataLen
,
lenBytes
,
i
;
const
CERT_AUTHORITY_INFO_ACCESS
*
info
=
(
const
CERT_AUTHORITY_INFO_ACCESS
*
)
pvStructInfo
;
ret
=
TRUE
;
for
(
i
=
0
,
dataLen
=
0
;
ret
&&
i
<
info
->
cAccDescr
;
i
++
)
{
DWORD
size
;
ret
=
CRYPT_AsnEncodeAccessDescription
(
&
info
->
rgAccDescr
[
i
],
NULL
,
&
size
);
if
(
ret
)
dataLen
+=
size
;
}
if
(
ret
)
{
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
<
info
->
cAccDescr
;
i
++
)
{
DWORD
size
=
dataLen
;
ret
=
CRYPT_AsnEncodeAccessDescription
(
&
info
->
rgAccDescr
[
i
],
pbEncoded
,
&
size
);
pbEncoded
+=
size
;
dataLen
-=
size
;
}
}
}
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
ret
=
FALSE
;
}
__ENDTRY
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodeBasicConstraints
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
...
...
@@ -3762,6 +3839,9 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
case
LOWORD
(
X509_AUTHORITY_KEY_ID2
):
encodeFunc
=
CRYPT_AsnEncodeAuthorityKeyId2
;
break
;
case
LOWORD
(
X509_AUTHORITY_INFO_ACCESS
):
encodeFunc
=
CRYPT_AsnEncodeAuthorityInfoAccess
;
break
;
case
LOWORD
(
X509_SEQUENCE_OF_ANY
):
encodeFunc
=
CRYPT_AsnEncodeSequenceOfAny
;
break
;
...
...
@@ -3832,6 +3912,8 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
encodeFunc
=
CRYPT_AsnEncodeIssuingDistPoint
;
else
if
(
!
strcmp
(
lpszStructType
,
szOID_NAME_CONSTRAINTS
))
encodeFunc
=
CRYPT_AsnEncodeNameConstraints
;
else
if
(
!
strcmp
(
lpszStructType
,
szOID_AUTHORITY_INFO_ACCESS
))
encodeFunc
=
CRYPT_AsnEncodeAuthorityInfoAccess
;
return
encodeFunc
;
}
...
...
dlls/crypt32/tests/encode.c
View file @
7e848b6c
...
...
@@ -4799,7 +4799,6 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
/* Having no access descriptions is allowed */
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_AUTHORITY_INFO_ACCESS
,
&
aia
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
buf
)
{
...
...
@@ -4813,7 +4812,6 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
aia
.
rgAccDescr
=
accessDescription
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_AUTHORITY_INFO_ACCESS
,
&
aia
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
/* It can't have an empty location */
...
...
@@ -4821,14 +4819,12 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
SetLastError
(
0xdeadbeef
);
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_AUTHORITY_INFO_ACCESS
,
&
aia
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
accessDescription
[
0
].
AccessLocation
.
dwAltNameChoice
=
CERT_ALT_NAME_URL
;
accessDescription
[
0
].
AccessLocation
.
pwszURL
=
(
LPWSTR
)
url
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_AUTHORITY_INFO_ACCESS
,
&
aia
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
buf
)
{
...
...
@@ -4849,7 +4845,6 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
aia
.
cAccDescr
=
2
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_AUTHORITY_INFO_ACCESS
,
&
aia
,
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