[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [rsaenh-test]: import&export of a plaintext public key + algID check
From:       "Karsten Elfenbein" <kelfe () gmx ! de>
Date:       2006-09-29 18:09:53
Message-ID: 000201c6e3f2$76cfd2c0$6e080a0a () elfe1
[Download RAW message or body]

* test for importing a PlainPublicKey
* test for the correct ALG_ID after the import
* test for the correct PlainPublicKey after exporting the key again

Karsten

["rsa1.diff" (application/octet-stream)]

diff --git a/dlls/rsaenh/tests/rsaenh.c b/dlls/rsaenh/tests/rsaenh.c
index 90caeb4..2162562 100644
--- a/dlls/rsaenh/tests/rsaenh.c
+++ b/dlls/rsaenh/tests/rsaenh.c
@@ -1142,6 +1142,42 @@ static void test_rsa_encrypt(void)
 
     CryptDestroyKey(hRSAKey);
 }
+
+static void test_import_export(void)
+{
+    DWORD dwLen, dwDataLen;
+    HCRYPTKEY hPublicKey;
+    BOOL result;
+    ALG_ID algID;
+    BYTE emptyKey[2048];
+    static BYTE abPlainPublicKey[84] = {
+        0x06, 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00,
+        0x52, 0x53, 0x41, 0x31, 0x00, 0x02, 0x00, 0x00,
+        0x01, 0x00, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+        0x11, 0x11, 0x11, 0x11
+    };
+
+    dwLen=84;
+    result = CryptImportKey(hProv, abPlainPublicKey, dwLen, 0, 0, &hPublicKey);
+    ok(result, "failed to import the public key\n");
+
+    dwDataLen=sizeof(algID);
+    result = CryptGetKeyParam(hPublicKey, KP_ALGID, (LPBYTE)&algID, &dwDataLen, 0);
+    ok(result, "failed to get the KP_ALGID from the imported public key\n");
+    ok(algID == CALG_RSA_KEYX, "Expected CALG_RSA_KEYX, got %x\n", algID);
+        
+    result = CryptExportKey(hPublicKey, 0, PUBLICKEYBLOB, 0, emptyKey, &dwLen);
+    ok(result, "failed to export the fresh imported public key\n");
+    ok(dwLen == 84, "Expected exported key to be 84 bytes long but got %ld bytes.",dwLen);
+    ok(!memcmp(emptyKey, abPlainPublicKey, dwLen), "exported key is different from the imported key\n");
+}
         
 static void test_schannel_provider(void)
 {
@@ -1586,6 +1622,7 @@ START_TEST(rsaenh)
     test_import_private();
     test_verify_signature();
     test_rsa_encrypt();
+    test_import_export();
     test_enum_container();
     clean_up_environment();
     test_schannel_provider();




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic