BcTlsEd25519Signer.cs 1022 B

12345678910111213141516171819202122232425262728293031
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers;
  6. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto.Impl.BC
  7. {
  8. public class BcTlsEd25519Signer
  9. : BcTlsSigner
  10. {
  11. public BcTlsEd25519Signer(BcTlsCrypto crypto, Ed25519PrivateKeyParameters privateKey)
  12. : base(crypto, privateKey)
  13. {
  14. }
  15. public override TlsStreamSigner GetStreamSigner(SignatureAndHashAlgorithm algorithm)
  16. {
  17. if (algorithm == null || SignatureScheme.From(algorithm) != SignatureScheme.ed25519)
  18. throw new InvalidOperationException("Invalid algorithm: " + algorithm);
  19. Ed25519Signer signer = new Ed25519Signer();
  20. signer.Init(true, m_privateKey);
  21. return new BcTlsStreamSigner(signer);
  22. }
  23. }
  24. }
  25. #pragma warning restore
  26. #endif