Juan Lang : rsaenh: Use helper function to install keys.

Alexandre Julliard julliard at winehq.org
Thu Jan 29 09:15:03 CST 2009


Module: wine
Branch: master
Commit: 30764edd12716a425621862e39c4b061e0dd6bdc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=30764edd12716a425621862e39c4b061e0dd6bdc

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Jan 28 21:45:12 2009 -0800

rsaenh: Use helper function to install keys.

---

 dlls/rsaenh/rsaenh.c |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c
index 4dc8aa6..c775082 100644
--- a/dlls/rsaenh/rsaenh.c
+++ b/dlls/rsaenh/rsaenh.c
@@ -2443,6 +2443,23 @@ BOOL WINAPI RSAENH_CPExportKey(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTKEY hPubK
 }
 
 /******************************************************************************
+ * release_and_install_key [Internal]
+ *
+ * Release an existing key, if present, and replaces it with a new one.
+ *
+ * PARAMS
+ *  hProv     [I] Key container into which the key is to be imported.
+ *  src       [I] Key which will replace *dest
+ *  dest      [I] Points to key to be released and replaced with src
+ */
+static void release_and_install_key(HCRYPTPROV hProv, HCRYPTKEY src,
+                                    HCRYPTKEY *dest)
+{
+    RSAENH_CPDestroyKey(hProv, *dest);
+    copy_handle(&handle_table, src, RSAENH_MAGIC_KEY, dest);
+}
+
+/******************************************************************************
  * CPImportKey (RSAENH.@)
  *
  * Import a BLOB'ed key into a key container.
@@ -2517,16 +2534,14 @@ BOOL WINAPI RSAENH_CPImportKey(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDat
                 case AT_SIGNATURE:
                 case CALG_RSA_SIGN:
                     TRACE("installing signing key\n");
-                    RSAENH_CPDestroyKey(hProv, pKeyContainer->hSignatureKeyPair);
-                    copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY,
-                                &pKeyContainer->hSignatureKeyPair);
+                    release_and_install_key(hProv, *phKey,
+                                            &pKeyContainer->hSignatureKeyPair);
                     break;
                 case AT_KEYEXCHANGE:
                 case CALG_RSA_KEYX:
                     TRACE("installing key exchange key\n");
-                    RSAENH_CPDestroyKey(hProv, pKeyContainer->hKeyExchangeKeyPair);
-                    copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY,
-                                &pKeyContainer->hKeyExchangeKeyPair);
+                    release_and_install_key(hProv, *phKey,
+                                            &pKeyContainer->hKeyExchangeKeyPair);
                     break;
                 }
             }
@@ -2558,9 +2573,8 @@ BOOL WINAPI RSAENH_CPImportKey(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDat
                 case AT_KEYEXCHANGE:
                 case CALG_RSA_KEYX:
                     TRACE("installing public key\n");
-                    RSAENH_CPDestroyKey(hProv, pKeyContainer->hKeyExchangeKeyPair);
-                    copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY,
-                                &pKeyContainer->hKeyExchangeKeyPair);
+                    release_and_install_key(hProv, *phKey,
+                                            &pKeyContainer->hKeyExchangeKeyPair);
                     break;
                 }
             }




More information about the wine-cvs mailing list