TlsNullNullCipher.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto
  5. {
  6. /// <summary>The cipher for TLS_NULL_WITH_NULL_NULL.</summary>
  7. public sealed class TlsNullNullCipher
  8. : TlsCipher
  9. {
  10. public static readonly TlsNullNullCipher Instance = new TlsNullNullCipher();
  11. public int GetCiphertextDecodeLimit(int plaintextLimit)
  12. {
  13. return plaintextLimit;
  14. }
  15. public int GetCiphertextEncodeLimit(int plaintextLength, int plaintextLimit)
  16. {
  17. return plaintextLength;
  18. }
  19. public int GetPlaintextLimit(int ciphertextLimit)
  20. {
  21. return ciphertextLimit;
  22. }
  23. public TlsEncodeResult EncodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion,
  24. int headerAllocation, byte[] plaintext, int offset, int len)
  25. {
  26. byte[] result = new byte[headerAllocation + len];
  27. Array.Copy(plaintext, offset, result, headerAllocation, len);
  28. return new TlsEncodeResult(result, 0, result.Length, contentType);
  29. }
  30. public TlsDecodeResult DecodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion,
  31. byte[] ciphertext, int offset, int len)
  32. {
  33. return new TlsDecodeResult(ciphertext, offset, len, recordType);
  34. }
  35. public void RekeyDecoder()
  36. {
  37. throw new TlsFatalAlert(AlertDescription.internal_error);
  38. }
  39. public void RekeyEncoder()
  40. {
  41. throw new TlsFatalAlert(AlertDescription.internal_error);
  42. }
  43. public bool UsesOpaqueRecordType
  44. {
  45. get { return false; }
  46. }
  47. }
  48. }
  49. #pragma warning restore
  50. #endif