Class AbstractTlsCrypto
- Namespace
- Org.BouncyCastle.Tls.Crypto.Impl
- Assembly
- BouncyCastle.Cryptography.dll
Base class for a TlsCrypto implementation that provides some needed methods from elsewhere in the impl package.
public abstract class AbstractTlsCrypto : TlsCrypto
- Inheritance
-
AbstractTlsCrypto
- Implements
- Derived
- Inherited Members
Properties
SecureRandom
Return the primary (safest) SecureRandom for this crypto.
public abstract SecureRandom SecureRandom { get; }
Property Value
- SecureRandom
a SecureRandom suitable for key generation.
Methods
AdoptSecret(TlsSecret)
Adopt the passed in secret, creating a new copy of it.
public virtual TlsSecret AdoptSecret(TlsSecret secret)
Parameters
secretTlsSecretthe secret to make a copy of.
Returns
- TlsSecret
a TlsSecret based on the original secret.
CreateCertificate(byte[])
Create a TlsCertificate from an ASN.1 binary encoding of an X.509 certificate.
public virtual TlsCertificate CreateCertificate(byte[] encoding)
Parameters
encodingbyte[]DER/BER encoding of the certificate of interest.
Returns
- TlsCertificate
a TlsCertificate.
Exceptions
- IOException
if there is an issue on decoding or constructing the certificate.
CreateCertificate(short, byte[])
Create a TlsCertificate from an ASN.1 binary encoding of a certificate.
public abstract TlsCertificate CreateCertificate(short type, byte[] encoding)
Parameters
typeshortCertificate type as per IANA TLS Certificate Types registry.
encodingbyte[]DER/BER encoding of the certificate of interest.
Returns
- TlsCertificate
a TlsCertificate.
Exceptions
- IOException
if there is an issue on decoding or constructing the certificate.
CreateCipher(TlsCryptoParameters, int, int)
Create a cipher for the specified encryption and MAC algorithms.
public abstract TlsCipher CreateCipher(TlsCryptoParameters cryptoParams, int encryptionAlgorithm, int macAlgorithm)
Parameters
cryptoParamsTlsCryptoParameterscontext specific parameters.
encryptionAlgorithmintthe encryption algorithm to be employed by the cipher.
macAlgorithmintthe MAC algorithm to be employed by the cipher.
Returns
Remarks
See enumeration classes EncryptionAlgorithm, MacAlgorithm for appropriate argument values.
Exceptions
CreateDHDomain(TlsDHConfig)
Create a domain object supporting the domain parameters described in dhConfig.
public abstract TlsDHDomain CreateDHDomain(TlsDHConfig dhConfig)
Parameters
dhConfigTlsDHConfigthe config describing the DH parameters to use.
Returns
- TlsDHDomain
a TlsDHDomain supporting the parameters in dhConfig.
CreateECDomain(TlsECConfig)
Create a domain object supporting the domain parameters described in ecConfig.
public abstract TlsECDomain CreateECDomain(TlsECConfig ecConfig)
Parameters
ecConfigTlsECConfigthe config describing the EC parameters to use.
Returns
- TlsECDomain
a TlsECDomain supporting the parameters in ecConfig.
CreateHash(int)
Create a suitable hash for the hash algorithm identifier passed in.
public abstract TlsHash CreateHash(int cryptoHashAlgorithm)
Parameters
cryptoHashAlgorithmintthe hash algorithm the hash needs to implement.
Returns
Remarks
See enumeration class CryptoHashAlgorithm for appropriate argument values.
CreateHmac(int)
Create a suitable HMAC for the MAC algorithm identifier passed in.
public abstract TlsHmac CreateHmac(int macAlgorithm)
Parameters
macAlgorithmintthe MAC algorithm the HMAC needs to match.
Returns
Remarks
See enumeration class MacAlgorithm for appropriate argument values.
CreateHmacForHash(int)
Create a suitable HMAC using the hash algorithm identifier passed in.
public abstract TlsHmac CreateHmacForHash(int cryptoHashAlgorithm)
Parameters
cryptoHashAlgorithmintthe hash algorithm the HMAC should use.
Returns
Remarks
See enumeration class CryptoHashAlgorithm for appropriate argument values.
CreateKemDomain(TlsKemConfig)
Create a domain object supporting the domain parameters described in kemConfig.
public abstract TlsKemDomain CreateKemDomain(TlsKemConfig kemConfig)
Parameters
kemConfigTlsKemConfigthe config describing the KEM parameters to use.
Returns
- TlsKemDomain
a TlsKemDomain supporting the parameters in kemConfig.
CreateNonceGenerator(byte[])
Create a nonce generator.
public abstract TlsNonceGenerator CreateNonceGenerator(byte[] additionalSeedMaterial)
Parameters
additionalSeedMaterialbyte[]context-specific seed material
Returns
Remarks
Each call should construct a new generator, and the generator should be returned from this call only after automatically seeding from this TlsCrypto's entropy source, and from the provided additional seed material. The output of each returned generator must be completely independent of the others.
CreateNonceGenerator(ReadOnlySpan<byte>)
public abstract TlsNonceGenerator CreateNonceGenerator(ReadOnlySpan<byte> additionalSeedMaterial)
Parameters
additionalSeedMaterialReadOnlySpan<byte>
Returns
CreateSecret(byte[])
Create a TlsSecret object based on provided data.
public abstract TlsSecret CreateSecret(byte[] data)
Parameters
databyte[]the data to base the TlsSecret on.
Returns
- TlsSecret
a TlsSecret based on the provided data.
CreateSrp6Client(TlsSrpConfig)
Create an SRP-6 client.
public abstract TlsSrp6Client CreateSrp6Client(TlsSrpConfig srpConfig)
Parameters
srpConfigTlsSrpConfigclient config.
Returns
- TlsSrp6Client
an initialised SRP6 client object.
CreateSrp6Server(TlsSrpConfig, BigInteger)
Create an SRP-6 server.
public abstract TlsSrp6Server CreateSrp6Server(TlsSrpConfig srpConfig, BigInteger srpVerifier)
Parameters
srpConfigTlsSrpConfigserver config.
srpVerifierBigIntegerthe SRP6 verifier value.
Returns
- TlsSrp6Server
an initialised SRP6 server object.
CreateSrp6VerifierGenerator(TlsSrpConfig)
Create an SRP-6 verifier generator.
public abstract TlsSrp6VerifierGenerator CreateSrp6VerifierGenerator(TlsSrpConfig srpConfig)
Parameters
srpConfigTlsSrpConfiggenerator config.
Returns
- TlsSrp6VerifierGenerator
an initialized SRP6 verifier generator.
GenerateRsaPreMasterSecret(ProtocolVersion)
Create a TlsSecret object containing a randomly-generated RSA PreMasterSecret
public abstract TlsSecret GenerateRsaPreMasterSecret(ProtocolVersion clientVersion)
Parameters
clientVersionProtocolVersionthe client version to place in the first 2 bytes
Returns
- TlsSecret
a TlsSecret containing the PreMasterSecret.
HasAnyStreamVerifiers(IList<SignatureAndHashAlgorithm>)
Return true if this TlsCrypto would use a stream verifier for any of the passed in algorithms.
public abstract bool HasAnyStreamVerifiers(IList<SignatureAndHashAlgorithm> signatureAndHashAlgorithms)
Parameters
signatureAndHashAlgorithmsIList<SignatureAndHashAlgorithm>A list of SignatureAndHashAlgorithm values.
Returns
- bool
true if this instance would use a stream verifier for any of the passed in algorithms, otherwise false.
Remarks
This method is only relevant to handshakes negotiating (D)TLS 1.2.
HasAnyStreamVerifiersLegacy(short[])
Return true if this TlsCrypto would use a stream verifier for any of the passed in algorithms.
public abstract bool HasAnyStreamVerifiersLegacy(short[] clientCertificateTypes)
Parameters
clientCertificateTypesshort[]An array of ClientCertificateType values.
Returns
- bool
true if this instance would use a stream verifier for any of the passed in algorithms, otherwise false.
Remarks
This method is only relevant to handshakes negotiating (D)TLS versions older than 1.2.
HasCryptoHashAlgorithm(int)
Return true if this TlsCrypto can support the passed in hash algorithm.
public abstract bool HasCryptoHashAlgorithm(int cryptoHashAlgorithm)
Parameters
cryptoHashAlgorithmintthe algorithm of interest.
Returns
- bool
true if cryptoHashAlgorithm is supported, false otherwise.
HasCryptoSignatureAlgorithm(int)
Return true if this TlsCrypto can support the passed in signature algorithm (not necessarily in combination with EVERY hash algorithm).
public abstract bool HasCryptoSignatureAlgorithm(int cryptoSignatureAlgorithm)
Parameters
cryptoSignatureAlgorithmintthe algorithm of interest.
Returns
- bool
true if cryptoSignatureAlgorithm is supported, false otherwise.
HasDHAgreement()
Return true if this TlsCrypto can support DH key agreement.
public abstract bool HasDHAgreement()
Returns
- bool
true if this instance can support DH key agreement, false otherwise.
HasECDHAgreement()
Return true if this TlsCrypto can support ECDH key agreement.
public abstract bool HasECDHAgreement()
Returns
- bool
true if this instance can support ECDH key agreement, false otherwise.
HasEncryptionAlgorithm(int)
Return true if this TlsCrypto can support the passed in block/stream encryption algorithm.
public abstract bool HasEncryptionAlgorithm(int encryptionAlgorithm)
Parameters
encryptionAlgorithmintthe algorithm of interest.
Returns
- bool
true if encryptionAlgorithm is supported, false otherwise.
HasHkdfAlgorithm(int)
Return true if this TlsCrypto can support HKDF with the passed in hash algorithm.
public abstract bool HasHkdfAlgorithm(int cryptoHashAlgorithm)
Parameters
cryptoHashAlgorithmintthe algorithm of interest.
Returns
- bool
true if HKDF is supported with cryptoHashAlgorithm, false otherwise.
HasKemAgreement()
Return true if this TlsCrypto can support KEM key agreement.
public abstract bool HasKemAgreement()
Returns
- bool
true if this instance can support KEM key agreement, false otherwise.
HasMacAlgorithm(int)
Return true if this TlsCrypto can support the passed in MAC algorithm.
public abstract bool HasMacAlgorithm(int macAlgorithm)
Parameters
macAlgorithmintthe algorithm of interest.
Returns
- bool
true if macAlgorithm is supported, false otherwise.
HasNamedGroup(int)
Return true if this TlsCrypto supports the passed in named group value.
public abstract bool HasNamedGroup(int namedGroup)
Parameters
namedGroupint
Returns
- bool
true if this instance supports the passed in named group value.
HasRsaEncryption()
Return true if this TlsCrypto can support RSA encryption/decryption.
public abstract bool HasRsaEncryption()
Returns
- bool
true if this instance can support RSA encryption/decryption, false otherwise.
HasSignatureAlgorithm(short)
Return true if this TlsCrypto can support the passed in signature algorithm (not necessarily in combination with EVERY hash algorithm).
public abstract bool HasSignatureAlgorithm(short signatureAlgorithm)
Parameters
signatureAlgorithmshort
Returns
- bool
true if signatureAlgorithm is supported, false otherwise.
HasSignatureAndHashAlgorithm(SignatureAndHashAlgorithm)
Return true if this TlsCrypto can support the passed in signature algorithm.
public abstract bool HasSignatureAndHashAlgorithm(SignatureAndHashAlgorithm sigAndHashAlgorithm)
Parameters
sigAndHashAlgorithmSignatureAndHashAlgorithmthe algorithm of interest.
Returns
- bool
true if sigAndHashAlgorithm is supported, false otherwise.
HasSignatureScheme(int)
Return true if this TlsCrypto can support the passed in signature scheme.
public abstract bool HasSignatureScheme(int signatureScheme)
Parameters
signatureSchemeintthe scheme of interest.
Returns
- bool
true if signatureScheme is supported, false otherwise.
HasSrpAuthentication()
Return true if this TlsCrypto can support SRP authentication.
public abstract bool HasSrpAuthentication()
Returns
- bool
true if this instance can support SRP authentication, false otherwise.
HkdfInit(int)
Setup an initial "secret" for a chain of HKDF calls (RFC 5869), containing a string of HashLen zeroes.
public abstract TlsSecret HkdfInit(int cryptoHashAlgorithm)
Parameters
cryptoHashAlgorithmintthe hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.