Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DetectFraming()

Framing System.Net.Security.SslStream.DetectFraming ( ReadOnlySpan< byte > bytes)
inlineprivate

Definition at line 1761 of file SslStream.cs.

1762 {
1763 int num = -1;
1764 if (bytes[0] == 22 || bytes[0] == 23 || bytes[0] == 21)
1765 {
1766 if (bytes.Length < 3)
1767 {
1768 return Framing.Invalid;
1769 }
1770 num = (bytes[1] << 8) | bytes[2];
1771 if (num < 768 || num >= 1280)
1772 {
1773 return Framing.Invalid;
1774 }
1775 return Framing.SinceSSL3;
1776 }
1777 if (bytes.Length < 3)
1778 {
1779 return Framing.Invalid;
1780 }
1781 if (bytes[2] > 8)
1782 {
1783 return Framing.Invalid;
1784 }
1785 if (bytes[2] == 1)
1786 {
1787 if (bytes.Length >= 5)
1788 {
1789 num = (bytes[3] << 8) | bytes[4];
1790 }
1791 }
1792 else if (bytes[2] == 4 && bytes.Length >= 7)
1793 {
1794 num = (bytes[5] << 8) | bytes[6];
1795 }
1796 if (num != -1)
1797 {
1798 if (_framing == Framing.Unknown)
1799 {
1800 if (num != 2 && (num < 512 || num >= 1280))
1801 {
1802 return Framing.Invalid;
1803 }
1804 }
1805 else if (num != 2)
1806 {
1807 return Framing.Invalid;
1808 }
1809 }
1810 if (!_context.IsServer || _framing == Framing.Unified)
1811 {
1812 return Framing.BeforeSSL3;
1813 }
1814 return Framing.Unified;
1815 }

References System.Net.Security.SslStream._context, System.Net.Security.SslStream._framing, System.bytes, and System.Net.Security.SecureChannel.IsServer.

Referenced by System.Net.Security.SslStream.ReceiveBlobAsync< TIOAdapter >().