From 6882e85fe1ea14f2d00d29b61e4f6adf76b3b9d1 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Thu, 13 Jan 2022 03:06:22 +0100 Subject: [PATCH] TLS public key must be positive --- src/Helpers.cs | 3 ++- src/TlsStream.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Helpers.cs b/src/Helpers.cs index 06d00c2..cc0056a 100644 --- a/src/Helpers.cs +++ b/src/Helpers.cs @@ -14,7 +14,8 @@ namespace WTelegram public static Action Log { get; set; } = DefaultLogger; /// For serializing indented Json with fields included - public static readonly JsonSerializerOptions JsonOptions = new() { IncludeFields = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; + public static readonly JsonSerializerOptions JsonOptions = new() { IncludeFields = true, WriteIndented = true, + IgnoreReadOnlyProperties = true, DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull }; private static readonly ConsoleColor[] LogLevelToColor = new[] { ConsoleColor.DarkGray, ConsoleColor.DarkCyan, ConsoleColor.Cyan, ConsoleColor.Yellow, ConsoleColor.Red, ConsoleColor.Magenta, ConsoleColor.DarkBlue }; diff --git a/src/TlsStream.cs b/src/TlsStream.cs index 1167e17..7634835 100644 --- a/src/TlsStream.cs +++ b/src/TlsStream.cs @@ -143,6 +143,7 @@ namespace WTelegram buffer[142 + dlen] = buffer[143 + dlen] = greases[4]; buffer[219 + dlen] = buffer[220 + dlen] = greases[4]; Encryption.RNG.GetBytes(buffer, 228 + dlen, 32); // public key + buffer[228 + dlen + 31] &= 0x7F; // must be positive TlsClientHello4.CopyTo(buffer, 260 + dlen); buffer[271 + dlen] = buffer[272 + dlen] = greases[6]; buffer[288 + dlen] = buffer[289 + dlen] = greases[3];