#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.Collections.Generic;
using System.IO;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto
{
/// Service and object creation interface for the primitive types and services that are associated with
/// cryptography in the API.
public interface TlsCrypto
{
/// Return true if this TlsCrypto would use a stream verifier for any of the passed in algorithms.
///
/// This method is only relevant to handshakes negotiating (D)TLS 1.2.
/// A list of
/// values.
/// true if this instance would use a stream verifier for any of the passed in algorithms, otherwise
/// false.
bool HasAnyStreamVerifiers(IList signatureAndHashAlgorithms);
/// Return true if this TlsCrypto would use a stream verifier for any of the passed in algorithms.
///
/// This method is only relevant to handshakes negotiating (D)TLS versions older than 1.2.
/// An array of values.
/// true if this instance would use a stream verifier for any of the passed in algorithms, otherwise
/// false.
bool HasAnyStreamVerifiersLegacy(short[] clientCertificateTypes);
/// Return true if this TlsCrypto can support the passed in hash algorithm.
/// the algorithm of interest.
/// true if cryptoHashAlgorithm is supported, false otherwise.
bool HasCryptoHashAlgorithm(int cryptoHashAlgorithm);
/// Return true if this TlsCrypto can support the passed in signature algorithm (not necessarily in
/// combination with EVERY hash algorithm).
/// the algorithm of interest.
/// true if cryptoSignatureAlgorithm is supported, false otherwise.
bool HasCryptoSignatureAlgorithm(int cryptoSignatureAlgorithm);
/// Return true if this TlsCrypto can support DH key agreement.
/// true if this instance can support DH key agreement, false otherwise.
bool HasDHAgreement();
/// Return true if this TlsCrypto can support ECDH key agreement.
/// true if this instance can support ECDH key agreement, false otherwise.
bool HasECDHAgreement();
/// Return true if this TlsCrypto can support the passed in block/stream encryption algorithm.
///
/// the algorithm of interest.
/// true if encryptionAlgorithm is supported, false otherwise.
bool HasEncryptionAlgorithm(int encryptionAlgorithm);
/// Return true if this TlsCrypto can support HKDF with the passed in hash algorithm.
/// the algorithm of interest.
/// true if HKDF is supported with cryptoHashAlgorithm, false otherwise.
bool HasHkdfAlgorithm(int cryptoHashAlgorithm);
/// Return true if this TlsCrypto can support the passed in MAC algorithm.
/// the algorithm of interest.
/// true if macAlgorithm is supported, false otherwise.
bool HasMacAlgorithm(int macAlgorithm);
/// Return true if this TlsCrypto supports the passed in named group
/// value.
/// true if this instance supports the passed in named group value.
///
bool HasNamedGroup(int namedGroup);
/// Return true if this TlsCrypto can support RSA encryption/decryption.
/// true if this instance can support RSA encryption/decryption, false otherwise.
bool HasRsaEncryption();
/// Return true if this TlsCrypto can support the passed in signature algorithm (not necessarily in
/// combination with EVERY hash algorithm).
/// true if signatureAlgorithm is supported, false otherwise.
bool HasSignatureAlgorithm(short signatureAlgorithm);
/// Return true if this TlsCrypto can support the passed in signature algorithm.
/// the algorithm of interest.
/// true if sigAndHashAlgorithm is supported, false otherwise.
bool HasSignatureAndHashAlgorithm(SignatureAndHashAlgorithm sigAndHashAlgorithm);
/// Return true if this TlsCrypto can support the passed in signature scheme.
/// the scheme of interest.
/// true if signatureScheme is supported, false otherwise.
bool HasSignatureScheme(int signatureScheme);
/// Return true if this TlsCrypto can support SRP authentication.
/// true if this instance can support SRP authentication, false otherwise.
bool HasSrpAuthentication();
/// Create a TlsSecret object based on provided data.
/// the data to base the TlsSecret on.
/// a TlsSecret based on the provided data.
TlsSecret CreateSecret(byte[] data);
/// Create a TlsSecret object containing a randomly-generated RSA PreMasterSecret
/// the client version to place in the first 2 bytes
/// a TlsSecret containing the PreMasterSecret.
TlsSecret GenerateRsaPreMasterSecret(ProtocolVersion clientVersion);
/// Return the primary (safest) SecureRandom for this crypto.
/// a SecureRandom suitable for key generation.
SecureRandom SecureRandom { get; }
/// Create a TlsCertificate from an ASN.1 binary encoding of an X.509 certificate.
/// DER/BER encoding of the certificate of interest.
/// a TlsCertificate.
/// if there is an issue on decoding or constructing the certificate.
TlsCertificate CreateCertificate(byte[] encoding);
/// Create a TlsCertificate from an ASN.1 binary encoding of a certificate.
/// Certificate type as per IANA TLS Certificate Types registry.
/// DER/BER encoding of the certificate of interest.
/// a TlsCertificate.
/// if there is an issue on decoding or constructing the certificate.
TlsCertificate CreateCertificate(short type, byte[] encoding);
/// Create a cipher for the specified encryption and MAC algorithms.
///
/// See enumeration classes , for appropriate
/// argument values.
///
/// context specific parameters.
/// the encryption algorithm to be employed by the cipher.
/// the MAC algorithm to be employed by the cipher.
/// a implementing the encryption and MAC algorithms.
///
TlsCipher CreateCipher(TlsCryptoParameters cryptoParams, int encryptionAlgorithm, int macAlgorithm);
/// Create a domain object supporting the domain parameters described in dhConfig.
/// the config describing the DH parameters to use.
/// a TlsDHDomain supporting the parameters in dhConfig.
TlsDHDomain CreateDHDomain(TlsDHConfig dhConfig);
/// Create a domain object supporting the domain parameters described in ecConfig.
/// the config describing the EC parameters to use.
/// a TlsECDomain supporting the parameters in ecConfig.
TlsECDomain CreateECDomain(TlsECConfig ecConfig);
/// Adopt the passed in secret, creating a new copy of it.
/// the secret to make a copy of.
/// a TlsSecret based on the original secret.
TlsSecret AdoptSecret(TlsSecret secret);
/// Create a suitable hash for the hash algorithm identifier passed in.
///
/// See enumeration class for appropriate argument values.
///
/// the hash algorithm the hash needs to implement.
/// a .
TlsHash CreateHash(int cryptoHashAlgorithm);
/// Create a suitable HMAC for the MAC algorithm identifier passed in.
///
/// See enumeration class for appropriate argument values.
///
/// the MAC algorithm the HMAC needs to match.
/// a .
TlsHmac CreateHmac(int macAlgorithm);
/// Create a suitable HMAC using the hash algorithm identifier passed in.
///
/// See enumeration class for appropriate argument values.
///
/// the hash algorithm the HMAC should use.
/// a .
TlsHmac CreateHmacForHash(int cryptoHashAlgorithm);
/// Create a nonce generator.
///
/// Each call should construct a new generator, and the generator should be returned from this call only after
/// automatically seeding from this 's entropy source, and from the provided additional
/// seed material. The output of each returned generator must be completely independent of the others.
///
/// context-specific seed material
/// a .
TlsNonceGenerator CreateNonceGenerator(byte[] additionalSeedMaterial);
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
TlsNonceGenerator CreateNonceGenerator(ReadOnlySpan additionalSeedMaterial);
#endif
/// Create an SRP-6 client.
/// client config.
/// an initialised SRP6 client object.
TlsSrp6Client CreateSrp6Client(TlsSrpConfig srpConfig);
/// Create an SRP-6 server.
/// server config.
/// the SRP6 verifier value.
/// an initialised SRP6 server object.
TlsSrp6Server CreateSrp6Server(TlsSrpConfig srpConfig, BigInteger srpVerifier);
/// Create an SRP-6 verifier generator.
/// generator config.
/// an initialized SRP6 verifier generator.
TlsSrp6VerifierGenerator CreateSrp6VerifierGenerator(TlsSrpConfig srpConfig);
/// Setup an initial "secret" for a chain of HKDF calls (RFC 5869), containing a string of HashLen
/// zeroes.
/// the hash algorithm to instantiate HMAC with. See
/// for values.
TlsSecret HkdfInit(int cryptoHashAlgorithm);
}
}
#pragma warning restore
#endif