Module: wine Branch: master Commit: 2ffc042ebf50351a8bb02dbedf2d9d032b5a8382 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ffc042ebf50351a8bb02dbedf...
Author: Juan Lang juan.lang@gmail.com Date: Tue Jan 27 09:00:03 2009 -0800
crypt32: Implement PFXIsPFXBlob.
---
dlls/crypt32/crypt32.spec | 1 + dlls/crypt32/decode.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/dlls/crypt32/crypt32.spec b/dlls/crypt32/crypt32.spec index fcffab2..3f5db87 100644 --- a/dlls/crypt32/crypt32.spec +++ b/dlls/crypt32/crypt32.spec @@ -219,6 +219,7 @@ @ stdcall PFXExportCertStore(ptr ptr ptr long) @ stdcall PFXExportCertStoreEx(ptr ptr ptr ptr long) @ stub PFXImportCertStore +@ stdcall PFXIsPFXBlob(ptr) @ stub RegCreateHKCUKeyExU @ stub RegCreateKeyExU @ stub RegDeleteValueU diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index d917d9b..bc0ee17 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -5511,3 +5511,38 @@ BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, TRACE_(crypt)("returning %d\n", ret); return ret; } + +BOOL WINAPI PFXIsPFXBlob(CRYPT_DATA_BLOB *pPFX) +{ + BOOL ret; + + TRACE("(%p)\n", pPFX); + + /* A PFX blob is an asn.1-encoded sequence, consisting of at least a + * version integer of length 1 (3 encoded byes) and at least one other + * datum (two encoded bytes), plus at least two bytes for the outer + * sequence. Thus, even an empty PFX blob is at least 7 bytes in length. + */ + if (pPFX->cbData < 7) + ret = FALSE; + else if (pPFX->pbData[0] == ASN_SEQUENCE) + { + DWORD len; + + if ((ret = CRYPT_GetLengthIndefinite(pPFX->pbData, pPFX->cbData, &len))) + { + BYTE lenLen = GET_LEN_BYTES(pPFX->pbData[1]); + + /* Need at least three bytes for the integer version */ + if (pPFX->cbData < 1 + lenLen + 3) + ret = FALSE; + else if (pPFX->pbData[1 + lenLen] != ASN_INTEGER || /* Tag */ + pPFX->pbData[1 + lenLen + 1] != 1 || /* Definite length */ + pPFX->pbData[1 + lenLen + 2] != 3) /* PFX version */ + ret = FALSE; + } + } + else + ret = FALSE; + return ret; +}