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
c80b99a2
Commit
c80b99a2
authored
Oct 17, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Oct 18, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wintrust: Implement WVTAsn1CatMemberInfoDecode.
parent
6b13b356
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
5 deletions
+152
-5
asn.c
dlls/wintrust/asn.c
+152
-2
asn.c
dlls/wintrust/tests/asn.c
+0
-3
No files found.
dlls/wintrust/asn.c
View file @
c80b99a2
...
...
@@ -1903,11 +1903,161 @@ BOOL WINAPI WVTAsn1SpcSpOpusInfoDecode(DWORD dwCertEncodingType,
return
FALSE
;
}
static
BOOL
WINAPI
CRYPT_AsnDecodeBMPString
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
BOOL
ret
;
DWORD
bytesNeeded
,
dataLen
;
if
((
ret
=
CRYPT_GetLen
(
pbEncoded
,
cbEncoded
,
&
dataLen
)))
{
BYTE
lenBytes
=
GET_LEN_BYTES
(
pbEncoded
[
1
]);
bytesNeeded
=
dataLen
+
2
+
sizeof
(
LPWSTR
);
if
(
!
pvStructInfo
)
*
pcbStructInfo
=
bytesNeeded
;
else
if
(
*
pcbStructInfo
<
bytesNeeded
)
{
*
pcbStructInfo
=
bytesNeeded
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
LPWSTR
str
;
DWORD
i
;
*
pcbStructInfo
=
bytesNeeded
;
assert
(
pvStructInfo
);
str
=
*
(
LPWSTR
*
)
pvStructInfo
;
for
(
i
=
0
;
i
<
dataLen
/
2
;
i
++
)
str
[
i
]
=
(
pbEncoded
[
1
+
lenBytes
+
2
*
i
]
<<
8
)
|
pbEncoded
[
1
+
lenBytes
+
2
*
i
+
1
];
/* Decoded string is always NULL-terminated */
str
[
i
]
=
'\0'
;
}
}
return
ret
;
}
static
BOOL
CRYPT_AsnDecodeInteger
(
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
BOOL
ret
;
DWORD
bytesNeeded
,
dataLen
;
if
((
ret
=
CRYPT_GetLen
(
pbEncoded
,
cbEncoded
,
&
dataLen
)))
{
BYTE
lenBytes
=
GET_LEN_BYTES
(
pbEncoded
[
1
]);
bytesNeeded
=
dataLen
+
sizeof
(
CRYPT_INTEGER_BLOB
);
if
(
!
pvStructInfo
)
*
pcbStructInfo
=
bytesNeeded
;
else
if
(
*
pcbStructInfo
<
bytesNeeded
)
{
*
pcbStructInfo
=
bytesNeeded
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
CRYPT_INTEGER_BLOB
*
blob
=
(
CRYPT_INTEGER_BLOB
*
)
pvStructInfo
;
*
pcbStructInfo
=
bytesNeeded
;
blob
->
cbData
=
dataLen
;
assert
(
blob
->
pbData
);
if
(
blob
->
cbData
)
{
DWORD
i
;
for
(
i
=
0
;
i
<
blob
->
cbData
;
i
++
)
{
blob
->
pbData
[
i
]
=
*
(
pbEncoded
+
1
+
lenBytes
+
dataLen
-
i
-
1
);
}
}
}
}
return
ret
;
}
/* Ignores tag. Only allows integers 4 bytes or smaller in size. */
static
BOOL
WINAPI
CRYPT_AsnDecodeInt
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
BOOL
ret
;
BYTE
buf
[
sizeof
(
CRYPT_INTEGER_BLOB
)
+
sizeof
(
int
)];
CRYPT_INTEGER_BLOB
*
blob
=
(
CRYPT_INTEGER_BLOB
*
)
buf
;
DWORD
size
=
sizeof
(
buf
);
blob
->
pbData
=
buf
+
sizeof
(
CRYPT_INTEGER_BLOB
);
ret
=
CRYPT_AsnDecodeInteger
(
pbEncoded
,
cbEncoded
,
0
,
buf
,
&
size
);
if
(
ret
)
{
if
(
!
pvStructInfo
)
*
pcbStructInfo
=
sizeof
(
int
);
else
if
(
*
pcbStructInfo
<
sizeof
(
int
))
{
*
pcbStructInfo
=
sizeof
(
int
);
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
int
val
,
i
;
*
pcbStructInfo
=
sizeof
(
int
);
if
(
blob
->
pbData
[
blob
->
cbData
-
1
]
&
0x80
)
{
/* initialize to a negative value to sign-extend */
val
=
-
1
;
}
else
val
=
0
;
for
(
i
=
0
;
i
<
blob
->
cbData
;
i
++
)
{
val
<<=
8
;
val
|=
blob
->
pbData
[
blob
->
cbData
-
i
-
1
];
}
memcpy
(
pvStructInfo
,
&
val
,
sizeof
(
int
));
}
}
else
if
(
GetLastError
()
==
ERROR_MORE_DATA
)
SetLastError
(
CRYPT_E_ASN1_LARGE
);
return
ret
;
}
BOOL
WINAPI
WVTAsn1CatMemberInfoDecode
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
FIXME
(
"%p, %d, %08x, %p, %d
\n
"
,
pbEncoded
,
cbEncoded
,
dwFlags
,
BOOL
ret
=
FALSE
;
TRACE
(
"%p, %d, %08x, %p, %d
\n
"
,
pbEncoded
,
cbEncoded
,
dwFlags
,
pvStructInfo
,
*
pcbStructInfo
);
return
FALSE
;
__TRY
{
struct
AsnDecodeSequenceItem
items
[]
=
{
{
ASN_BMPSTRING
,
offsetof
(
CAT_MEMBERINFO
,
pwszSubjGuid
),
CRYPT_AsnDecodeBMPString
,
sizeof
(
LPWSTR
),
FALSE
,
TRUE
,
offsetof
(
CAT_MEMBERINFO
,
pwszSubjGuid
),
0
},
{
ASN_INTEGER
,
offsetof
(
CAT_MEMBERINFO
,
dwCertVersion
),
CRYPT_AsnDecodeInt
,
sizeof
(
DWORD
),
FALSE
,
FALSE
,
0
,
0
},
};
ret
=
CRYPT_AsnDecodeSequence
(
dwCertEncodingType
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
pbEncoded
,
cbEncoded
,
dwFlags
,
pvStructInfo
,
pcbStructInfo
,
NULL
);
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
}
__ENDTRY
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
dlls/wintrust/tests/asn.c
View file @
c80b99a2
...
...
@@ -547,7 +547,6 @@ static void test_decodeCatMemberInfo(void)
ret
=
pCryptDecodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
emptyCatMemberInfo
,
sizeof
(
emptyCatMemberInfo
),
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptDecodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -561,7 +560,6 @@ static void test_decodeCatMemberInfo(void)
ret
=
pCryptDecodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
catMemberInfoWithSillyGuid
,
sizeof
(
catMemberInfoWithSillyGuid
),
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptDecodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -575,7 +573,6 @@ static void test_decodeCatMemberInfo(void)
ret
=
pCryptDecodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
catMemberInfoWithGuid
,
sizeof
(
catMemberInfoWithGuid
),
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptDecodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
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