AbstractTlsSigner.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using Org.BouncyCastle.Crypto;
  4. using Org.BouncyCastle.Crypto.Parameters;
  5. namespace Org.BouncyCastle.Crypto.Tls
  6. {
  7. public abstract class AbstractTlsSigner
  8. : TlsSigner
  9. {
  10. protected TlsContext mContext;
  11. public virtual void Init(TlsContext context)
  12. {
  13. this.mContext = context;
  14. }
  15. public virtual byte[] GenerateRawSignature(AsymmetricKeyParameter privateKey, byte[] md5AndSha1)
  16. {
  17. return GenerateRawSignature(null, privateKey, md5AndSha1);
  18. }
  19. public abstract byte[] GenerateRawSignature(SignatureAndHashAlgorithm algorithm,
  20. AsymmetricKeyParameter privateKey, byte[] hash);
  21. public virtual bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey, byte[] md5AndSha1)
  22. {
  23. return VerifyRawSignature(null, sigBytes, publicKey, md5AndSha1);
  24. }
  25. public abstract bool VerifyRawSignature(SignatureAndHashAlgorithm algorithm, byte[] sigBytes,
  26. AsymmetricKeyParameter publicKey, byte[] hash);
  27. public virtual ISigner CreateSigner(AsymmetricKeyParameter privateKey)
  28. {
  29. return CreateSigner(null, privateKey);
  30. }
  31. public abstract ISigner CreateSigner(SignatureAndHashAlgorithm algorithm, AsymmetricKeyParameter privateKey);
  32. public virtual ISigner CreateVerifyer(AsymmetricKeyParameter publicKey)
  33. {
  34. return CreateVerifyer(null, publicKey);
  35. }
  36. public abstract ISigner CreateVerifyer(SignatureAndHashAlgorithm algorithm, AsymmetricKeyParameter publicKey);
  37. public abstract bool IsValidPublicKey(AsymmetricKeyParameter publicKey);
  38. }
  39. }
  40. #endif