mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
Add a few traces and comments.
This commit is contained in:
parent
03d4816bd4
commit
2aa7f3c276
1 changed files with 31 additions and 5 deletions
|
@ -15,6 +15,21 @@
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* This file implements ASN.1 DER encoding and decoding of a limited set of
|
||||||
|
* types. It isn't a full ASN.1 implementation. Microsoft implements BER
|
||||||
|
* encoding of many of the basic types in msasn1.dll, but that interface is
|
||||||
|
* undocumented, so I implement them here.
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* "A Layman's Guide to a Subset of ASN.1, BER, and DER", by Burton Kaliski
|
||||||
|
* (available online, look for a PDF copy as the HTML versions tend to have
|
||||||
|
* translation errors.)
|
||||||
|
*
|
||||||
|
* RFC3280, http://www.faqs.org/rfcs/rfc3280.html
|
||||||
|
*
|
||||||
|
* MSDN, especially:
|
||||||
|
* http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cryptencodeobject_and_cryptdecodeobject.asp
|
||||||
*/
|
*/
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -244,6 +259,9 @@ static void *CRYPT_GetFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType,
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD type, size = 0;
|
DWORD type, size = 0;
|
||||||
|
|
||||||
|
TRACE("(%08lx %s %s %p)\n", dwCertEncodingType, debugstr_a(lpszStructType),
|
||||||
|
debugstr_a(szFuncName), lib);
|
||||||
|
|
||||||
*lib = NULL;
|
*lib = NULL;
|
||||||
r = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey);
|
r = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey);
|
||||||
HeapFree(GetProcessHeap(), 0, szKey);
|
HeapFree(GetProcessHeap(), 0, szKey);
|
||||||
|
@ -283,6 +301,7 @@ static void *CRYPT_GetFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType,
|
||||||
}
|
}
|
||||||
if (funcName != szFuncName)
|
if (funcName != szFuncName)
|
||||||
HeapFree(GetProcessHeap(), 0, (char *)funcName);
|
HeapFree(GetProcessHeap(), 0, (char *)funcName);
|
||||||
|
TRACE("returning %p\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,7 +767,8 @@ static BOOL WINAPI CRYPT_AsnEncodeName(DWORD dwCertEncodingType,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
|
if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
|
||||||
pbEncoded = *(BYTE **)pbEncoded;
|
pbEncoded = *(BYTE **)pbEncoded;
|
||||||
*pbEncoded++ = ASN_CONSTRUCTOR | ASN_SEQUENCE;
|
/* FIXME: could this be encoded using X509_SEQUENCE_OF_ANY? */
|
||||||
|
*pbEncoded++ = ASN_CONSTRUCTOR | ASN_SEQUENCEOF;
|
||||||
CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, &size);
|
CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, &size);
|
||||||
pbEncoded += size;
|
pbEncoded += size;
|
||||||
for (i = 0; ret && i < info->cRDN; i++)
|
for (i = 0; ret && i < info->cRDN; i++)
|
||||||
|
@ -1259,6 +1279,9 @@ BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
|
||||||
encodeFunc = CRYPT_AsnEncodeBits;
|
encodeFunc = CRYPT_AsnEncodeBits;
|
||||||
else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER))
|
else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER))
|
||||||
encodeFunc = CRYPT_AsnEncodeOctets;
|
encodeFunc = CRYPT_AsnEncodeOctets;
|
||||||
|
else
|
||||||
|
TRACE("OID %s not found or unimplemented, looking for DLL\n",
|
||||||
|
debugstr_a(lpszStructType));
|
||||||
if (!encodeFunc)
|
if (!encodeFunc)
|
||||||
encodeFunc = (CryptEncodeObjectExFunc)CRYPT_GetFunc(dwCertEncodingType,
|
encodeFunc = (CryptEncodeObjectExFunc)CRYPT_GetFunc(dwCertEncodingType,
|
||||||
lpszStructType, "CryptEncodeObjectEx", &lib);
|
lpszStructType, "CryptEncodeObjectEx", &lib);
|
||||||
|
@ -2273,6 +2296,8 @@ end:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MIN_ENCODED_TIME_LENGTH 10
|
||||||
|
|
||||||
static BOOL WINAPI CRYPT_AsnDecodeUtcTime(DWORD dwCertEncodingType,
|
static BOOL WINAPI CRYPT_AsnDecodeUtcTime(DWORD dwCertEncodingType,
|
||||||
LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
|
LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
|
||||||
PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
|
PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
|
||||||
|
@ -2308,8 +2333,7 @@ static BOOL WINAPI CRYPT_AsnDecodeUtcTime(DWORD dwCertEncodingType,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
len = pbEncoded[1];
|
len = pbEncoded[1];
|
||||||
/* FIXME: magic # */
|
if (len < MIN_ENCODED_TIME_LENGTH)
|
||||||
if (len < 10)
|
|
||||||
{
|
{
|
||||||
SetLastError(CRYPT_E_ASN1_CORRUPT);
|
SetLastError(CRYPT_E_ASN1_CORRUPT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2382,8 +2406,7 @@ static BOOL WINAPI CRYPT_AsnDecodeGeneralizedTime(DWORD dwCertEncodingType,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
len = pbEncoded[1];
|
len = pbEncoded[1];
|
||||||
/* FIXME: magic # */
|
if (len < MIN_ENCODED_TIME_LENGTH)
|
||||||
if (len < 10)
|
|
||||||
{
|
{
|
||||||
SetLastError(CRYPT_E_ASN1_CORRUPT);
|
SetLastError(CRYPT_E_ASN1_CORRUPT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2531,6 +2554,9 @@ BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
|
||||||
decodeFunc = CRYPT_AsnDecodeBits;
|
decodeFunc = CRYPT_AsnDecodeBits;
|
||||||
else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER))
|
else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER))
|
||||||
decodeFunc = CRYPT_AsnDecodeOctets;
|
decodeFunc = CRYPT_AsnDecodeOctets;
|
||||||
|
else
|
||||||
|
TRACE("OID %s not found or unimplemented, looking for DLL\n",
|
||||||
|
debugstr_a(lpszStructType));
|
||||||
if (!decodeFunc)
|
if (!decodeFunc)
|
||||||
decodeFunc = (CryptDecodeObjectExFunc)CRYPT_GetFunc(dwCertEncodingType,
|
decodeFunc = (CryptDecodeObjectExFunc)CRYPT_GetFunc(dwCertEncodingType,
|
||||||
lpszStructType, "CryptDecodeObjectEx", &lib);
|
lpszStructType, "CryptDecodeObjectEx", &lib);
|
||||||
|
|
Loading…
Reference in a new issue