]> git.saurik.com Git - apple/security.git/blobdiff - OSX/sec/Security/SecOTRSession.c
Security-58286.1.32.tar.gz
[apple/security.git] / OSX / sec / Security / SecOTRSession.c
index a3e5e482180cf0f57b3473c02539f475f58b6cf2..07244b17a23e59c0a3cdbfea09661dd073394a84 100644 (file)
@@ -1065,7 +1065,8 @@ static OSStatus SecOTRVerifyAndExposeRaw_locked(SecOTRSessionRef session,
     SecOTRPublicDHKeyRef newKey = NULL;
     const uint8_t* bytes;
     size_t  size;
-
+    SecOTRFullDHKeyRef myKeyForMessage = NULL;
+    SecOTRPublicDHKeyRef theirKeyForMessage = NULL;
     bytes = CFDataGetBytePtr(decodedBytes);
     size = CFDataGetLength(decodedBytes);
 
@@ -1098,8 +1099,8 @@ static OSStatus SecOTRVerifyAndExposeRaw_locked(SecOTRSessionRef session,
         uint8_t *macKey;
         uint64_t *theirCounter;
 
-        SecOTRFullDHKeyRef myKeyForMessage = (myID == session->_keyID) ? session->_myKey : session->_myNextKey;
-        SecOTRPublicDHKeyRef theirKeyForMessage = (theirID == session->_theirKeyID) ? session->_theirKey : session->_theirPreviousKey;
+        myKeyForMessage = (myID == session->_keyID) ? session->_myKey : session->_myNextKey;
+        theirKeyForMessage = (theirID == session->_theirKeyID) ? session->_theirKey : session->_theirPreviousKey;
 
         SecOTRSFindKeysForMessage(session, myKeyForMessage, theirKeyForMessage, false,
                                   &messageKey, &macKey, &theirCounter);
@@ -1155,6 +1156,19 @@ static OSStatus SecOTRVerifyAndExposeRaw_locked(SecOTRSessionRef session,
     SecOTRSPrecalculateNextKeysInternal(session);
 
 fail:
+    if(result != errSecSuccess){
+        CFDataPerformWithHexString(decodedBytes, ^(CFStringRef decodedBytesString) {
+            SecOTRPublicIdentityRef myPublicID = SecOTRPublicIdentityCopyFromPrivate(kCFAllocatorDefault, session->_me, NULL);
+            SecOTRPIPerformWithSerializationString(myPublicID, ^(CFStringRef myIDString) {
+                SecOTRPIPerformWithSerializationString(session->_them, ^(CFStringRef theirIDString) {
+            secnotice("OTR","session[%p] failed to decrypt, session: %@, mk: %@, mpk: %@, tpk: %@, tk: %@, chose tktu: %@", session, session,
+                     session->_myKey, session->_myNextKey, session->_theirPreviousKey, session->_theirKey, theirKeyForMessage);
+            secnotice("OTR","session[%p] failed to decrypt, mktu: %@, mpi: %@, tpi: %@, m: %@", session, myKeyForMessage, myIDString, theirIDString, decodedBytesString);
+                });
+            });
+            CFReleaseNull(myPublicID);
+        });
+    }
     CFReleaseNull(newKey);
     return result;
 }
@@ -1278,14 +1292,19 @@ static OSStatus SecOTRVerifyAndExposeRawCompact_locked(SecOTRSessionRef session,
     SecOTRSPrecalculateNextKeysInternal(session);
 
 fail:
-#if DEBUG
     if(result != errSecSuccess){
         CFDataPerformWithHexString(decodedBytes, ^(CFStringRef decodedBytesString) {
-            secdebug("OTR","session[%p] failed to decrypt, session: %@, mk: %@, mpk: %@, tpk: %@, tk: %@, chose tktu: %@, mktu: %@, m: %@, tP: %@, tb: %hhx", session, session,
-                     session->_myKey, session->_myNextKey, session->_theirPreviousKey, session->_theirKey, theirKeyForMessage, myKeyForMessage, decodedBytesString, theirProposal, type_byte);
+            SecOTRPublicIdentityRef myPublicID = SecOTRPublicIdentityCopyFromPrivate(kCFAllocatorDefault, session->_me, NULL);
+            SecOTRPIPerformWithSerializationString(myPublicID, ^(CFStringRef myIDString) {
+                SecOTRPIPerformWithSerializationString(session->_them, ^(CFStringRef theirIDString) {
+            secnotice("OTR","session[%p] failed to decrypt, session: %@, mk: %@, mpk: %@, tpk: %@, tk: %@, chose tktu: %@", session, session,
+                     session->_myKey, session->_myNextKey, session->_theirPreviousKey, session->_theirKey, theirKeyForMessage);
+            secnotice("OTR","session[%p] failed to decrypt, mktu: %@, mpi: %@, tpi: %@, m: %@, tP: %@, tb: %hhx", session, myKeyForMessage, myIDString, theirIDString, decodedBytesString, theirProposal, type_byte);
+                });
+            });
+            CFReleaseNull(myPublicID);
         });
     }
-#endif
     CFReleaseNull(theirProposal);
     return result;
 }
@@ -1397,3 +1416,4 @@ bool SecOTRSessionProcessPacketRemote(CFDataRef sessionData, CFDataRef inputPack
     });
     return result;
 }
+