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
d3d7dfa7
Commit
d3d7dfa7
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 WVTAsn1CatMemberInfoEncode.
parent
52751981
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
5 deletions
+162
-5
asn.c
dlls/wintrust/asn.c
+162
-2
asn.c
dlls/wintrust/tests/asn.c
+0
-3
No files found.
dlls/wintrust/asn.c
View file @
d3d7dfa7
...
@@ -50,6 +50,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(cryptasn);
...
@@ -50,6 +50,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(cryptasn);
#endif
#endif
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
#define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
static
BOOL
CRYPT_EncodeLen
(
DWORD
len
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
static
BOOL
CRYPT_EncodeLen
(
DWORD
len
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
{
...
@@ -738,13 +739,172 @@ BOOL WINAPI WVTAsn1SpcIndirectDataContentEncode(DWORD dwCertEncodingType,
...
@@ -738,13 +739,172 @@ BOOL WINAPI WVTAsn1SpcIndirectDataContentEncode(DWORD dwCertEncodingType,
return
ret
;
return
ret
;
}
}
static
BOOL
WINAPI
CRYPT_AsnEncodeBMPString
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
=
TRUE
;
LPCWSTR
str
=
(
LPCWSTR
)
pvStructInfo
;
DWORD
bytesNeeded
,
lenBytes
,
strLen
;
if
(
str
)
strLen
=
lstrlenW
(
str
);
else
strLen
=
0
;
CRYPT_EncodeLen
(
strLen
*
2
,
NULL
,
&
lenBytes
);
bytesNeeded
=
1
+
lenBytes
+
strLen
*
2
;
if
(
!
pbEncoded
)
*
pcbEncoded
=
bytesNeeded
;
else
if
(
*
pcbEncoded
<
bytesNeeded
)
{
*
pcbEncoded
=
bytesNeeded
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
DWORD
i
;
*
pcbEncoded
=
bytesNeeded
;
*
pbEncoded
++
=
ASN_BMPSTRING
;
CRYPT_EncodeLen
(
strLen
*
2
,
pbEncoded
,
&
lenBytes
);
pbEncoded
+=
lenBytes
;
for
(
i
=
0
;
i
<
strLen
;
i
++
)
{
*
pbEncoded
++
=
(
str
[
i
]
&
0xff00
)
>>
8
;
*
pbEncoded
++
=
str
[
i
]
&
0x00ff
;
}
}
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodeInteger
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
;
__TRY
{
DWORD
significantBytes
,
lenBytes
,
bytesNeeded
;
BYTE
padByte
=
0
;
BOOL
pad
=
FALSE
;
const
CRYPT_INTEGER_BLOB
*
blob
=
(
const
CRYPT_INTEGER_BLOB
*
)
pvStructInfo
;
significantBytes
=
blob
->
cbData
;
if
(
significantBytes
)
{
if
(
blob
->
pbData
[
significantBytes
-
1
]
&
0x80
)
{
/* negative, lop off leading (little-endian) 0xffs */
for
(;
significantBytes
>
0
&&
blob
->
pbData
[
significantBytes
-
1
]
==
0xff
;
significantBytes
--
)
;
if
(
blob
->
pbData
[
significantBytes
-
1
]
<
0x80
)
{
padByte
=
0xff
;
pad
=
TRUE
;
}
}
else
{
/* positive, lop off leading (little-endian) zeroes */
for
(;
significantBytes
>
0
&&
!
blob
->
pbData
[
significantBytes
-
1
];
significantBytes
--
)
;
if
(
significantBytes
==
0
)
significantBytes
=
1
;
if
(
blob
->
pbData
[
significantBytes
-
1
]
>
0x7f
)
{
padByte
=
0
;
pad
=
TRUE
;
}
}
}
if
(
pad
)
CRYPT_EncodeLen
(
significantBytes
+
1
,
NULL
,
&
lenBytes
);
else
CRYPT_EncodeLen
(
significantBytes
,
NULL
,
&
lenBytes
);
bytesNeeded
=
1
+
lenBytes
+
significantBytes
;
if
(
pad
)
bytesNeeded
++
;
if
(
!
pbEncoded
)
{
*
pcbEncoded
=
bytesNeeded
;
ret
=
TRUE
;
}
else
if
(
*
pcbEncoded
<
bytesNeeded
)
{
*
pcbEncoded
=
bytesNeeded
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
*
pcbEncoded
=
bytesNeeded
;
*
pbEncoded
++
=
ASN_INTEGER
;
if
(
pad
)
{
CRYPT_EncodeLen
(
significantBytes
+
1
,
pbEncoded
,
&
lenBytes
);
pbEncoded
+=
lenBytes
;
*
pbEncoded
++
=
padByte
;
}
else
{
CRYPT_EncodeLen
(
significantBytes
,
pbEncoded
,
&
lenBytes
);
pbEncoded
+=
lenBytes
;
}
for
(;
significantBytes
>
0
;
significantBytes
--
)
*
(
pbEncoded
++
)
=
blob
->
pbData
[
significantBytes
-
1
];
ret
=
TRUE
;
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
ret
=
FALSE
;
}
__ENDTRY
return
ret
;
}
BOOL
WINAPI
CRYPT_AsnEncodeInt
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
CRYPT_INTEGER_BLOB
blob
=
{
sizeof
(
INT
),
(
BYTE
*
)
pvStructInfo
};
return
CRYPT_AsnEncodeInteger
(
dwCertEncodingType
,
X509_MULTI_BYTE_INTEGER
,
&
blob
,
pbEncoded
,
pcbEncoded
);
}
BOOL
WINAPI
WVTAsn1CatMemberInfoEncode
(
DWORD
dwCertEncodingType
,
BOOL
WINAPI
WVTAsn1CatMemberInfoEncode
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
BYTE
*
pbEncoded
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
DWORD
*
pcbEncoded
)
{
{
FIXME
(
"(0x%08x, %s, %p, %p, %p): stub
\n
"
,
dwCertEncodingType
,
BOOL
ret
=
FALSE
;
TRACE
(
"(0x%08x, %s, %p, %p, %p)
\n
"
,
dwCertEncodingType
,
debugstr_a
(
lpszStructType
),
pvStructInfo
,
pbEncoded
,
pcbEncoded
);
debugstr_a
(
lpszStructType
),
pvStructInfo
,
pbEncoded
,
pcbEncoded
);
return
FALSE
;
__TRY
{
const
CAT_MEMBERINFO
*
info
=
(
const
CAT_MEMBERINFO
*
)
pvStructInfo
;
struct
AsnEncodeSequenceItem
items
[]
=
{
{
info
->
pwszSubjGuid
,
CRYPT_AsnEncodeBMPString
,
0
},
{
&
info
->
dwCertVersion
,
CRYPT_AsnEncodeInt
,
0
},
};
ret
=
CRYPT_AsnEncodeSequence
(
X509_ASN_ENCODING
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
pbEncoded
,
pcbEncoded
);
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
}
__ENDTRY
return
ret
;
}
}
/* Gets the number of length bytes from the given (leading) length byte */
/* Gets the number of length bytes from the given (leading) length byte */
...
...
dlls/wintrust/tests/asn.c
View file @
d3d7dfa7
...
@@ -497,7 +497,6 @@ static void test_encodeCatMemberInfo(void)
...
@@ -497,7 +497,6 @@ static void test_encodeCatMemberInfo(void)
ret
=
pCryptEncodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
ret
=
pCryptEncodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
if
(
ret
)
{
{
...
@@ -509,7 +508,6 @@ static void test_encodeCatMemberInfo(void)
...
@@ -509,7 +508,6 @@ static void test_encodeCatMemberInfo(void)
info
.
pwszSubjGuid
=
foo
;
info
.
pwszSubjGuid
=
foo
;
ret
=
pCryptEncodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
ret
=
pCryptEncodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
(
LPBYTE
)
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
(
LPBYTE
)
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
if
(
ret
)
{
{
...
@@ -522,7 +520,6 @@ static void test_encodeCatMemberInfo(void)
...
@@ -522,7 +520,6 @@ static void test_encodeCatMemberInfo(void)
info
.
pwszSubjGuid
=
guidStr
;
info
.
pwszSubjGuid
=
guidStr
;
ret
=
pCryptEncodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
ret
=
pCryptEncodeObjectEx
(
X509_ASN_ENCODING
,
CAT_MEMBERINFO_STRUCT
,
(
LPBYTE
)
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
(
LPBYTE
)
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
todo_wine
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
ok
(
ret
,
"CryptEncodeObjectEx failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
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