GOST3411_2012_256Digest.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests
  6. {
  7. public class Gost3411_2012_256Digest : Gost3411_2012Digest
  8. {
  9. private readonly static byte[] IV = {
  10. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  11. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  12. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  13. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  14. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  15. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  16. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  17. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
  18. };
  19. public override string AlgorithmName
  20. {
  21. get { return "GOST3411-2012-256"; }
  22. }
  23. public Gost3411_2012_256Digest() : base(IV)
  24. {
  25. }
  26. public Gost3411_2012_256Digest(Gost3411_2012_256Digest other) : base(IV)
  27. {
  28. Reset(other);
  29. }
  30. public override int GetDigestSize()
  31. {
  32. return 32;
  33. }
  34. public override int DoFinal(byte[] output, int outOff)
  35. {
  36. byte[] result = new byte[64];
  37. base.DoFinal(result, 0);
  38. Array.Copy(result, 32, output, outOff, 32);
  39. return 32;
  40. }
  41. public override IMemoable Copy()
  42. {
  43. return new Gost3411_2012_256Digest(this);
  44. }
  45. }
  46. }
  47. #pragma warning restore
  48. #endif