public static bool ParseMessage(string hashAndMessage, byte[] hiddenMessageBinary, bool ignoreHmac, out DateTime timeStamp, out byte[] message) { timeStamp = DateTime.MinValue; bool flag = false; message = null; try { byte[] array = CryptoMessage.Decode(hashAndMessage ?? string.Empty); byte[] array2; flag = CryptoMessage.ParseMessage(array, hiddenMessageBinary, out array2); if (flag || ignoreHmac) { long ticks = BitConverter.ToInt64(array2, 0); timeStamp = new DateTime(ticks, DateTimeKind.Utc); int num = array2.Length - 8; message = new byte[num]; Array.Copy(array2, 8, message, 0, num); } else { ExTraceGlobals.CryptoTracer.TraceDebug(2L, "{0}.{1}: failed: messageString={2}, hiddenMessage={3}", new object[] { "Clients.Common.CryptoMessage", "ParseMessage", hashAndMessage, CryptoMessage.GetHexString(hiddenMessageBinary) }); } } catch (Exception ex) { flag = false; ExTraceGlobals.CryptoTracer.TraceDebug(3L, "{0}.{1}: Exception: messageString={2}, hiddenMessage={3}, exception={3}", new object[] { "Clients.Common.CryptoMessage", "ParseMessage", hashAndMessage, CryptoMessage.GetHexString(hiddenMessageBinary), ex }); } return(flag); }
private static byte[] Init() { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 112, "Init", "f:\\15.00.1497\\sources\\dev\\clients\\src\\common\\CryptoMessage.cs"); byte[] array = ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest().ObjectGuid.ToByteArray(); byte[] array2 = topologyConfigurationSession.GetDatabasesContainerId().ObjectGuid.ToByteArray(); byte[] array3 = new byte[array.Length + array2.Length]; array.CopyTo(array3, 0); array2.CopyTo(array3, array.Length); if (ExTraceGlobals.CryptoTracer.IsTraceEnabled(TraceType.DebugTrace)) { using (SHA256Cng sha256Cng = new SHA256Cng()) { byte[] bytes = sha256Cng.ComputeHash(array3); ExTraceGlobals.CryptoTracer.TraceDebug <string, string, string>(0L, "{0}.{1}: adObjectIdsBinaryHash={2}", "Clients.Common.CryptoMessage", "CryptoMessage()", CryptoMessage.GetHexString(bytes)); sha256Cng.Clear(); } } return(array3); }