Juan Lang : crypt32: Add tests for CertGetCTLContextProperty.
Alexandre Julliard
julliard at winehq.org
Tue Sep 2 08:32:48 CDT 2008
Module: wine
Branch: master
Commit: b15ee4596529269340ddfda49428fca657488b39
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b15ee4596529269340ddfda49428fca657488b39
Author: Juan Lang <juan.lang at gmail.com>
Date: Fri Aug 29 07:29:30 2008 -0700
crypt32: Add tests for CertGetCTLContextProperty.
---
dlls/crypt32/tests/ctl.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/dlls/crypt32/tests/ctl.c b/dlls/crypt32/tests/ctl.c
index 9d4eee4..bb3c2a9 100644
--- a/dlls/crypt32/tests/ctl.c
+++ b/dlls/crypt32/tests/ctl.c
@@ -173,7 +173,88 @@ static void testCreateCTL(void)
CertFreeCTLContext(ctl);
}
+static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
+ PCCTL_CONTEXT context, DWORD propID)
+{
+ BYTE hash[20] = { 0 }, hashProperty[20];
+ BOOL ret;
+ DWORD size;
+
+ memset(hash, 0, sizeof(hash));
+ memset(hashProperty, 0, sizeof(hashProperty));
+ size = sizeof(hash);
+ ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
+ ret = CertGetCTLContextProperty(context, propID, hashProperty, &size);
+ ok(ret, "CertGetCTLContextProperty failed: %08x\n", GetLastError());
+ if (ret)
+ ok(!memcmp(hash, hashProperty, size),
+ "Unexpected hash for property %d\n", propID);
+}
+
+static void testCTLProperties(void)
+{
+ PCCTL_CONTEXT ctl;
+ BOOL ret;
+ DWORD propID, numProps, access, size;
+
+ ctl = CertCreateCTLContext(X509_ASN_ENCODING,
+ signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent));
+ if (!ctl)
+ {
+ skip("CertCreateCTLContext failed: %08x\n", GetLastError());
+ return;
+ }
+
+ /* No properties as yet */
+ propID = 0;
+ numProps = 0;
+ do {
+ propID = CertEnumCTLContextProperties(ctl, propID);
+ if (propID)
+ numProps++;
+ } while (propID != 0);
+ ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
+
+ /* An implicit property */
+ ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, NULL,
+ &size);
+ todo_wine
+ ok(ret, "CertGetCTLContextProperty failed: %08x\n", GetLastError());
+ ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, &access,
+ &size);
+ todo_wine
+ ok(ret, "CertGetCTLContextProperty failed: %08x", GetLastError());
+ todo_wine
+ ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
+ "Didn't expect a persisted cert\n");
+
+ todo_wine
+ checkHash(signedCTLWithCTLInnerContent,
+ sizeof(signedCTLWithCTLInnerContent), CALG_SHA1, ctl, CERT_HASH_PROP_ID);
+
+ /* Now that the hash property is set, we should get one property when
+ * enumerating.
+ */
+ propID = 0;
+ numProps = 0;
+ do {
+ propID = CertEnumCTLContextProperties(ctl, propID);
+ if (propID)
+ numProps++;
+ } while (propID != 0);
+ todo_wine
+ ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
+
+ todo_wine
+ checkHash(signedCTLWithCTLInnerContent,
+ sizeof(signedCTLWithCTLInnerContent), CALG_MD5, ctl,
+ CERT_MD5_HASH_PROP_ID);
+
+ CertFreeCTLContext(ctl);
+}
+
START_TEST(ctl)
{
testCreateCTL();
+ testCTLProperties();
}
More information about the wine-cvs
mailing list