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
dd4bd4ad
Commit
dd4bd4ad
authored
Jun 02, 2006
by
Juan Lang
Committed by
Alexandre Julliard
Jun 03, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement X509_NAME_VALUE encoding/decoding.
parent
d7043f23
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
18 deletions
+84
-18
crypt32_private.h
dlls/crypt32/crypt32_private.h
+1
-0
decode.c
dlls/crypt32/decode.c
+50
-2
encode.c
dlls/crypt32/encode.c
+33
-14
encode.c
dlls/crypt32/tests/encode.c
+0
-2
No files found.
dlls/crypt32/crypt32_private.h
View file @
dd4bd4ad
...
...
@@ -26,6 +26,7 @@
#define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
#define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
#define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
#define ASN_T61STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
#define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
#define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
#define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
...
...
dlls/crypt32/decode.c
View file @
dd4bd4ad
...
...
@@ -1182,7 +1182,7 @@ static BOOL WINAPI CRYPT_AsnDecodeExtensions(DWORD dwCertEncodingType,
* order to avoid overwriting memory. (In some cases, it may change it, if it
* doesn't copy anything to memory.) Be sure to set it correctly!
*/
static
BOOL
WINAPI
CRYPT_AsnDecodeNameValue
(
DWORD
dwCertEncodingType
,
static
BOOL
WINAPI
CRYPT_AsnDecodeNameValue
Internal
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
PCRYPT_DECODE_PARA
pDecodePara
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
...
...
@@ -1199,6 +1199,7 @@ static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType,
case
ASN_NUMERICSTRING
:
case
ASN_PRINTABLESTRING
:
case
ASN_IA5STRING
:
case
ASN_T61STRING
:
break
;
default:
FIXME
(
"Unimplemented string type %02x
\n
"
,
pbEncoded
[
0
]);
...
...
@@ -1214,6 +1215,7 @@ static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType,
case
ASN_NUMERICSTRING
:
case
ASN_PRINTABLESTRING
:
case
ASN_IA5STRING
:
case
ASN_T61STRING
:
if
(
!
(
dwFlags
&
CRYPT_DECODE_NOCOPY_FLAG
))
bytesNeeded
+=
dataLen
;
break
;
...
...
@@ -1240,6 +1242,9 @@ static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType,
case
ASN_IA5STRING
:
value
->
dwValueType
=
CERT_RDN_IA5_STRING
;
break
;
case
ASN_T61STRING
:
value
->
dwValueType
=
CERT_RDN_T61_STRING
;
break
;
}
if
(
dataLen
)
{
...
...
@@ -1248,6 +1253,7 @@ static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType,
case
ASN_NUMERICSTRING
:
case
ASN_PRINTABLESTRING
:
case
ASN_IA5STRING
:
case
ASN_T61STRING
:
value
->
Value
.
cbData
=
dataLen
;
if
(
dwFlags
&
CRYPT_DECODE_NOCOPY_FLAG
)
value
->
Value
.
pbData
=
(
BYTE
*
)
pbEncoded
+
1
+
...
...
@@ -1272,6 +1278,45 @@ static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType,
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnDecodeNameValue
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
PCRYPT_DECODE_PARA
pDecodePara
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
BOOL
ret
=
TRUE
;
__TRY
{
ret
=
CRYPT_AsnDecodeNameValueInternal
(
dwCertEncodingType
,
lpszStructType
,
pbEncoded
,
cbEncoded
,
dwFlags
&
~
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
NULL
,
pcbStructInfo
);
if
(
ret
&&
pvStructInfo
)
{
ret
=
CRYPT_DecodeEnsureSpace
(
dwFlags
,
pDecodePara
,
pvStructInfo
,
pcbStructInfo
,
*
pcbStructInfo
);
if
(
ret
)
{
CERT_NAME_VALUE
*
value
;
if
(
dwFlags
&
CRYPT_DECODE_ALLOC_FLAG
)
pvStructInfo
=
*
(
BYTE
**
)
pvStructInfo
;
value
=
(
CERT_NAME_VALUE
*
)
pvStructInfo
;
value
->
Value
.
pbData
=
((
BYTE
*
)
value
+
sizeof
(
CERT_NAME_VALUE
));
ret
=
CRYPT_AsnDecodeNameValueInternal
(
dwCertEncodingType
,
lpszStructType
,
pbEncoded
,
cbEncoded
,
dwFlags
&
~
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
pvStructInfo
,
pcbStructInfo
);
}
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
ret
=
FALSE
;
}
__ENDTRY
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnDecodeRdnAttr
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
PCRYPT_DECODE_PARA
pDecodePara
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
...
...
@@ -1282,7 +1327,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRdnAttr(DWORD dwCertEncodingType,
CRYPT_AsnDecodeOidInternal
,
sizeof
(
LPSTR
),
FALSE
,
TRUE
,
offsetof
(
CERT_RDN_ATTR
,
pszObjId
),
0
},
{
0
,
offsetof
(
CERT_RDN_ATTR
,
dwValueType
),
CRYPT_AsnDecodeNameValue
,
sizeof
(
CERT_NAME_VALUE
),
CRYPT_AsnDecodeNameValue
Internal
,
sizeof
(
CERT_NAME_VALUE
),
FALSE
,
TRUE
,
offsetof
(
CERT_RDN_ATTR
,
Value
.
pbData
),
0
},
};
CERT_RDN_ATTR
*
attr
=
(
CERT_RDN_ATTR
*
)
pvStructInfo
;
...
...
@@ -2940,6 +2985,9 @@ BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
case
(
WORD
)
X509_EXTENSIONS
:
decodeFunc
=
CRYPT_AsnDecodeExtensions
;
break
;
case
(
WORD
)
X509_NAME_VALUE
:
decodeFunc
=
CRYPT_AsnDecodeNameValue
;
break
;
case
(
WORD
)
X509_NAME
:
decodeFunc
=
CRYPT_AsnDecodeName
;
break
;
...
...
dlls/crypt32/encode.c
View file @
dd4bd4ad
...
...
@@ -906,11 +906,16 @@ static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
}
static
BOOL
WINAPI
CRYPT_AsnEncodeNameValue
(
DWORD
dwCertEncodingType
,
CERT_NAME_VALUE
*
value
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
=
TRUE
;
__TRY
{
BYTE
tag
;
DWORD
bytesNeeded
,
lenBytes
,
encodedLen
;
BOOL
ret
=
TRUE
;
const
CERT_NAME_VALUE
*
value
=
(
CERT_NAME_VALUE
*
)
pvStructInfo
;
switch
(
value
->
dwValueType
)
{
...
...
@@ -922,6 +927,10 @@ static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType,
tag
=
ASN_PRINTABLESTRING
;
encodedLen
=
value
->
Value
.
cbData
;
break
;
case
CERT_RDN_T61_STRING
:
tag
=
ASN_T61STRING
;
encodedLen
=
value
->
Value
.
cbData
;
break
;
case
CERT_RDN_IA5_STRING
:
tag
=
ASN_IA5STRING
;
encodedLen
=
value
->
Value
.
cbData
;
...
...
@@ -936,15 +945,15 @@ static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType,
}
CRYPT_EncodeLen
(
encodedLen
,
NULL
,
&
lenBytes
);
bytesNeeded
=
1
+
lenBytes
+
encodedLen
;
if
(
pbEncoded
)
{
if
(
*
pcbEncoded
<
bytesNeeded
)
{
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
if
(
!
pbEncoded
)
*
pcbEncoded
=
bytesNeeded
;
else
{
if
((
ret
=
CRYPT_EncodeEnsureSpace
(
dwFlags
,
pEncodePara
,
pbEncoded
,
pcbEncoded
,
bytesNeeded
)))
{
if
(
dwFlags
&
CRYPT_ENCODE_ALLOC_FLAG
)
pbEncoded
=
*
(
BYTE
**
)
pbEncoded
;
*
pbEncoded
++
=
tag
;
CRYPT_EncodeLen
(
encodedLen
,
pbEncoded
,
&
lenBytes
);
pbEncoded
+=
lenBytes
;
...
...
@@ -952,12 +961,19 @@ static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType,
{
case
CERT_RDN_NUMERIC_STRING
:
case
CERT_RDN_PRINTABLE_STRING
:
case
CERT_RDN_T61_STRING
:
case
CERT_RDN_IA5_STRING
:
memcpy
(
pbEncoded
,
value
->
Value
.
pbData
,
value
->
Value
.
cbData
);
}
}
}
*
pcbEncoded
=
bytesNeeded
;
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
ret
=
FALSE
;
}
__ENDTRY
return
ret
;
}
...
...
@@ -975,8 +991,8 @@ static BOOL WINAPI CRYPT_AsnEncodeRdnAttr(DWORD dwCertEncodingType,
/* hack: a CERT_RDN_ATTR is identical to a CERT_NAME_VALUE beginning
* with dwValueType, so "cast" it to get its encoded size
*/
ret
=
CRYPT_AsnEncodeNameValue
(
dwCertEncodingType
,
(
CERT_NAME_VALUE
*
)
&
attr
->
dwValueType
,
NULL
,
&
size
);
ret
=
CRYPT_AsnEncodeNameValue
(
dwCertEncodingType
,
X509_NAME_VALUE
,
(
CERT_NAME_VALUE
*
)
&
attr
->
dwValueType
,
0
,
NULL
,
NULL
,
&
size
);
if
(
ret
)
{
bytesNeeded
+=
size
;
...
...
@@ -1003,8 +1019,8 @@ static BOOL WINAPI CRYPT_AsnEncodeRdnAttr(DWORD dwCertEncodingType,
pbEncoded
+=
size
;
size
=
bytesNeeded
-
1
-
lenBytes
-
size
;
ret
=
CRYPT_AsnEncodeNameValue
(
dwCertEncodingType
,
(
CERT_NAME_VALUE
*
)
&
attr
->
dwValueType
,
pbEncoded
,
&
size
);
X509_NAME_VALUE
,
(
CERT_NAME_VALUE
*
)
&
attr
->
dwValueType
,
0
,
NULL
,
pbEncoded
,
&
size
);
}
}
}
...
...
@@ -2264,6 +2280,9 @@ BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
case
(
WORD
)
X509_EXTENSIONS
:
encodeFunc
=
CRYPT_AsnEncodeExtensions
;
break
;
case
(
WORD
)
X509_NAME_VALUE
:
encodeFunc
=
CRYPT_AsnEncodeNameValue
;
break
;
case
(
WORD
)
X509_NAME
:
encodeFunc
=
CRYPT_AsnEncodeName
;
break
;
...
...
dlls/crypt32/tests/encode.c
View file @
dd4bd4ad
...
...
@@ -3204,10 +3204,8 @@ START_TEST(encode)
test_decodeFiletime
(
encodings
[
i
]);
test_encodeName
(
encodings
[
i
]);
test_decodeName
(
encodings
[
i
]);
todo_wine
{
test_encodeNameValue
(
encodings
[
i
]);
test_decodeNameValue
(
encodings
[
i
]);
}
test_encodeAltName
(
encodings
[
i
]);
test_decodeAltName
(
encodings
[
i
]);
test_encodeOctets
(
encodings
[
i
]);
...
...
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