]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_keychain/lib/KeyItem.cpp
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / lib / KeyItem.cpp
index 12f7113fa1700a05ea2419aa9c64b389d81ed39d..1f079ff570819d6736db162f9b2bf50bb1a9c519 100644 (file)
@@ -38,8 +38,8 @@
 #include <security_keychain/Globals.h>
 #include "KCEventNotifier.h"
 #include <CommonCrypto/CommonDigest.h>
 #include <security_keychain/Globals.h>
 #include "KCEventNotifier.h"
 #include <CommonCrypto/CommonDigest.h>
-#include <SecBase.h>
-#include <SecBasePriv.h>
+#include <Security/SecBase.h>
+#include <Security/SecBasePriv.h>
 #include <CoreFoundation/CFPriv.h>
 
 // @@@ This needs to be shared.
 #include <CoreFoundation/CFPriv.h>
 
 // @@@ This needs to be shared.
@@ -75,12 +75,13 @@ KeyItem *KeyItem::optional(SecKeyRef ptr)
     }
 }
 
     }
 }
 
-KeyItem::operator CFTypeRef() const throw()
+KeyItem::operator CFTypeRef() const _NOEXCEPT
 {
     StMaybeLock<Mutex> _(this->getMutexForObject());
 
     if (mWeakSecKeyRef != NULL) {
         if (_CFTryRetain(mWeakSecKeyRef) == NULL) {
 {
     StMaybeLock<Mutex> _(this->getMutexForObject());
 
     if (mWeakSecKeyRef != NULL) {
         if (_CFTryRetain(mWeakSecKeyRef) == NULL) {
+            StMaybeLock<Mutex> secKeyCDSAMutex(static_cast<CDSASecKey *>(mWeakSecKeyRef)->cdsaKeyMutex);
             // mWeakSecKeyRef is not really valid, pointing to SecKeyRef which going to die - it is somewhere between last CFRelease and entering into mutex-protected section of SecCDSAKeyDestroy.  Avoid using it, pretend that no enveloping SecKeyRef exists.  But make sure that this KeyImpl is disconnected from this about-to-die SecKeyRef, because we do not want KeyImpl connected to it to be really destroyed, it will be connected to newly created SecKeyRef (see below).
             mWeakSecKeyRef->key = NULL;
             mWeakSecKeyRef = NULL;
             // mWeakSecKeyRef is not really valid, pointing to SecKeyRef which going to die - it is somewhere between last CFRelease and entering into mutex-protected section of SecCDSAKeyDestroy.  Avoid using it, pretend that no enveloping SecKeyRef exists.  But make sure that this KeyImpl is disconnected from this about-to-die SecKeyRef, because we do not want KeyImpl connected to it to be really destroyed, it will be connected to newly created SecKeyRef (see below).
             mWeakSecKeyRef->key = NULL;
             mWeakSecKeyRef = NULL;
@@ -488,7 +489,7 @@ KeyItem::key()
         } catch(CssmError cssme) {
             mKey.release();
             secnotice("integrity", "error while checking integrity, denying access: %s", cssme.what());
         } catch(CssmError cssme) {
             mKey.release();
             secnotice("integrity", "error while checking integrity, denying access: %s", cssme.what());
-            throw cssme;
+            throw;
         }
     }
 
         }
     }
 
@@ -757,8 +758,8 @@ KeyItem::createPair(
             pubKeyHash.set(*pubKeyHashData);
             passThrough.allocator().free(pubKeyHashData);
 
             pubKeyHash.set(*pubKeyHashData);
             passThrough.allocator().free(pubKeyHashData);
 
-            auto_ptr<string> privDescription;
-            auto_ptr<string> pubDescription;
+            unique_ptr<string> privDescription;
+            unique_ptr<string> pubDescription;
             try {
                 privDescription.reset(new string(initialAccess->promptDescription()));
                 pubDescription.reset(new string(initialAccess->promptDescription()));
             try {
                 privDescription.reset(new string(initialAccess->promptDescription()));
                 pubDescription.reset(new string(initialAccess->promptDescription()));
@@ -996,8 +997,8 @@ KeyItem::importPair(
                csp.allocator().free(cssmData->Data);
                csp.allocator().free(cssmData);
 
                csp.allocator().free(cssmData->Data);
                csp.allocator().free(cssmData);
 
-               auto_ptr<string>privDescription;
-               auto_ptr<string>pubDescription;
+               unique_ptr<string>privDescription;
+               unique_ptr<string>pubDescription;
                try {
                        privDescription.reset(new string(initialAccess->promptDescription()));
                        pubDescription.reset(new string(initialAccess->promptDescription()));
                try {
                        privDescription.reset(new string(initialAccess->promptDescription()));
                        pubDescription.reset(new string(initialAccess->promptDescription()));