private static byte[] DecryptDataWithPublicKeyHashPrefix(byte[] sebData, bool forEditing, ref X509Certificate2 sebFileCertificateRef) { X509Certificate2 certificateFromStore = SEBProtectionController.GetCertificateFromStore(SEBConfigFileManager.GetPrefixDataFromData(ref sebData, 20)); if (certificateFromStore == null) { int num = (int)SEBMessageBox.Show(SEBUIStrings.errorDecryptingSettings, SEBUIStrings.certificateNotFoundInStore, MessageBoxIcon.Hand, MessageBoxButtons.OK, forEditing); return((byte[])null); } if (forEditing) { sebFileCertificateRef = certificateFromStore; } sebData = SEBProtectionController.DecryptDataWithCertificate(sebData, certificateFromStore); return(sebData); }
/// ---------------------------------------------------------------------------------------- /// <summary> /// Helper method which fetches the public key hash from a byte array, /// retrieves the according cryptographic identity from the certificate store /// and returns the decrypted bytes /// </summary> /// ---------------------------------------------------------------------------------------- private static byte[] DecryptDataWithPublicKeyHashPrefix(byte[] sebData, bool forEditing, ref X509Certificate2 sebFileCertificateRef) { // Get 20 bytes public key hash prefix // and remaining data with the prefix stripped byte[] publicKeyHash = GetPrefixDataFromData(ref sebData, PUBLIC_KEY_HASH_LENGTH); X509Certificate2 certificateRef = SEBProtectionController.GetCertificateFromStore(publicKeyHash); if (certificateRef == null) { SEBMessageBox.Show(SEBUIStrings.errorDecryptingSettings, SEBUIStrings.certificateNotFoundInStore, MessageBoxIcon.Error, MessageBoxButtons.OK, neverShowTouchOptimized: forEditing); return null; } // If these settings are being decrypted for editing, we will return the decryption certificate reference // in the variable which was passed as reference when calling this method if (forEditing) sebFileCertificateRef = certificateRef; sebData = SEBProtectionController.DecryptDataWithCertificate(sebData, certificateRef); return sebData; }