Juan Lang : crypt32: Introduce a helper function to get encoded length that allows indefinite-length encoding .
Alexandre Julliard
julliard at winehq.org
Tue Sep 18 05:31:20 CDT 2007
Module: wine
Branch: master
Commit: 7ecf5becbd9ce7f62a80cc4294db1f44a62a17c1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7ecf5becbd9ce7f62a80cc4294db1f44a62a17c1
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Sep 17 15:09:16 2007 -0700
crypt32: Introduce a helper function to get encoded length that allows indefinite-length encoding.
---
dlls/crypt32/decode.c | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 0421bd0..67f79d5 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -135,9 +135,11 @@ static BOOL WINAPI CRYPT_AsnDecodeUnsignedIntegerInternal(
/* Helper function to get the encoded length of the data starting at pbEncoded,
* where pbEncoded[0] is the tag. If the data are too short to contain a
* length or if the length is too large for cbEncoded, sets an appropriate
- * error code and returns FALSE.
+ * error code and returns FALSE. If the encoded length is unknown due to
+ * indefinite length encoding, *len is set to CMSG_INDEFINITE_LENGTH.
*/
-static BOOL CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, DWORD *len)
+static BOOL CRYPT_GetLengthIndefinite(const BYTE *pbEncoded, DWORD cbEncoded,
+ DWORD *len)
{
BOOL ret;
@@ -161,9 +163,8 @@ static BOOL CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, DWORD *len)
}
else if (pbEncoded[1] == 0x80)
{
- FIXME("unimplemented for indefinite-length encoding\n");
- SetLastError(CRYPT_E_ASN1_CORRUPT);
- ret = FALSE;
+ *len = CMSG_INDEFINITE_LENGTH;
+ ret = TRUE;
}
else
{
@@ -204,6 +205,20 @@ static BOOL CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, DWORD *len)
return ret;
}
+/* Like CRYPT_GetLengthIndefinite, but disallows indefinite-length encoding. */
+static BOOL CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, DWORD *len)
+{
+ BOOL ret;
+
+ if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, len)) &&
+ *len == CMSG_INDEFINITE_LENGTH)
+ {
+ SetLastError(CRYPT_E_ASN1_CORRUPT);
+ ret = FALSE;
+ }
+ return ret;
+}
+
/* Helper function to check *pcbStructInfo, set it to the required size, and
* optionally to allocate memory. Assumes pvStructInfo is not NULL.
* If CRYPT_DECODE_ALLOC_FLAG is set in dwFlags, *pvStructInfo will be set to a
More information about the wine-cvs
mailing list