DefaultSignatureResult.cs 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Operators
  5. {
  6. public class DefaultSignatureResult
  7. : IBlockResult
  8. {
  9. private readonly ISigner mSigner;
  10. public DefaultSignatureResult(ISigner signer)
  11. {
  12. this.mSigner = signer;
  13. }
  14. public byte[] Collect()
  15. {
  16. return mSigner.GenerateSignature();
  17. }
  18. public int Collect(byte[] sig, int sigOff)
  19. {
  20. byte[] signature = Collect();
  21. signature.CopyTo(sig, sigOff);
  22. return signature.Length;
  23. }
  24. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  25. public int Collect(Span<byte> destination)
  26. {
  27. byte[] result = Collect();
  28. result.CopyTo(destination);
  29. return result.Length;
  30. }
  31. #endif
  32. }
  33. }
  34. #pragma warning restore
  35. #endif