Package org.bouncycastle.tls
Class AbstractTlsServer
java.lang.Object
org.bouncycastle.tls.AbstractTlsPeer
org.bouncycastle.tls.AbstractTlsServer
- Direct Known Subclasses:
DefaultTlsServer
,PSKTlsServer
,SRPTlsServer
Base class for a TLS server.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CertificateStatusRequest
protected int[]
protected Hashtable
protected Vector
protected boolean
protected TlsServerContext
protected boolean
protected short
protected int[]
protected ProtocolVersion[]
protected int
protected ProtocolName
protected final Hashtable
protected Vector
protected boolean
protected Vector
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected Hashtable
Deprecated.Use 'serverExtensions' directly, it is now never nullprotected short[]
This method will be called (only) if the server included an extension of type "status_request" with empty "extension_data" in the extended server hello.int[]
protected String
getExternalPSK
(Vector identities) WARNING: EXPERIMENTAL FEATURE, UNSTABLE API Return theexternal PSK
to select from the ClientHello.protected int
protected int
protected int
protected int
protected byte[]
RFC 9146 DTLS connection ID.byte[]
RFC 5077 3.3.protected Vector
int
void
getServerExtensionsForConnection
(Hashtable serverExtensions) getSessionToResume
(byte[] sessionID) Return the specified session, if available.int[]
void
init
(TlsServerContext context) protected boolean
isSelectableCipherSuite
(int cipherSuite, int availCurveBits, int availFiniteFieldBits, Vector sigAlgs) void
notifyClientCertificate
(Certificate clientCertificate) Called by the protocol handler to report the client certificate, only ifTlsServer.getCertificateRequest()
returned non-null.void
notifyClientVersion
(ProtocolVersion clientVersion) void
notifyFallback
(boolean isFallback) void
Notifies the peer that a new handshake is about to begin.void
notifyOfferedCipherSuites
(int[] offeredCipherSuites) void
notifySession
(TlsSession session) protected boolean
protected boolean
void
processClientExtensions
(Hashtable clientExtensions) void
processClientSupplementalData
(Vector clientSupplementalData) protected boolean
selectCipherSuite
(int cipherSuite) protected int
selectDH
(int minimumFiniteFieldBits) protected int
selectDHDefault
(int minimumFiniteFieldBits) protected int
selectECDH
(int minimumCurveBits) protected int
selectECDHDefault
(int minimumCurveBits) protected ProtocolName
protected ProtocolName
selectProtocolName
(Vector clientProtocolNames, Vector serverProtocolNames) protected boolean
Methods inherited from class org.bouncycastle.tls.AbstractTlsPeer
allowLegacyResumption, cancel, getCrypto, getHandshakeResendTimeMillis, getHandshakeTimeoutMillis, getHeartbeat, getHeartbeatPolicy, getKeyExchangeFactory, getMaxCertificateChainLength, getMaxHandshakeMessageSize, getPskKeyExchangeModes, getRenegotiationPolicy, getSupportedCipherSuites, getSupportedVersions, notifyAlertRaised, notifyAlertReceived, notifyCloseHandle, notifyConnectionClosed, notifyHandshakeComplete, notifySecureRenegotiation, requiresCloseNotify, requiresExtendedMasterSecret, shouldCheckSigAlgOfPeerCerts, shouldUseExtendedMasterSecret, shouldUseExtendedPadding, shouldUseGMTUnixTime
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bouncycastle.tls.TlsPeer
allowLegacyResumption, cancel, getCrypto, getHandshakeResendTimeMillis, getHandshakeTimeoutMillis, getHeartbeat, getHeartbeatPolicy, getKeyExchangeFactory, getMaxCertificateChainLength, getMaxHandshakeMessageSize, getPskKeyExchangeModes, getRenegotiationPolicy, notifyAlertRaised, notifyAlertReceived, notifyCloseHandle, notifyConnectionClosed, notifyHandshakeComplete, notifySecureRenegotiation, requiresCloseNotify, requiresExtendedMasterSecret, shouldCheckSigAlgOfPeerCerts, shouldUseExtendedMasterSecret, shouldUseExtendedPadding, shouldUseGMTUnixTime
Methods inherited from interface org.bouncycastle.tls.TlsServer
getCredentials
-
Field Details
-
context
-
protocolVersions
-
cipherSuites
protected int[] cipherSuites -
offeredCipherSuites
protected int[] offeredCipherSuites -
clientExtensions
-
encryptThenMACOffered
protected boolean encryptThenMACOffered -
maxFragmentLengthOffered
protected short maxFragmentLengthOffered -
truncatedHMacOffered
protected boolean truncatedHMacOffered -
clientSentECPointFormats
protected boolean clientSentECPointFormats -
certificateStatusRequest
-
statusRequestV2
-
trustedCAKeys
-
selectedCipherSuite
protected int selectedCipherSuite -
clientProtocolNames
-
selectedProtocolName
-
serverExtensions
-
-
Constructor Details
-
AbstractTlsServer
-
-
Method Details
-
allowCertificateStatus
protected boolean allowCertificateStatus() -
allowEncryptThenMAC
protected boolean allowEncryptThenMAC() -
allowMultiCertStatus
protected boolean allowMultiCertStatus() -
allowTruncatedHMac
protected boolean allowTruncatedHMac() -
allowTrustedCAIndication
protected boolean allowTrustedCAIndication() -
checkServerExtensions
Deprecated.Use 'serverExtensions' directly, it is now never null -
getDetailMessageNoCipherSuite
-
getMaximumDefaultCurveBits
protected int getMaximumDefaultCurveBits() -
getMaximumDefaultFiniteFieldBits
protected int getMaximumDefaultFiniteFieldBits() -
getMaximumNegotiableCurveBits
protected int getMaximumNegotiableCurveBits() -
getMaximumNegotiableFiniteFieldBits
protected int getMaximumNegotiableFiniteFieldBits() -
getProtocolNames
-
isSelectableCipherSuite
protected boolean isSelectableCipherSuite(int cipherSuite, int availCurveBits, int availFiniteFieldBits, Vector sigAlgs) -
preferLocalCipherSuites
protected boolean preferLocalCipherSuites() -
selectCipherSuite
- Throws:
IOException
-
selectDH
protected int selectDH(int minimumFiniteFieldBits) -
selectDHDefault
protected int selectDHDefault(int minimumFiniteFieldBits) -
selectECDH
protected int selectECDH(int minimumCurveBits) -
selectECDHDefault
protected int selectECDHDefault(int minimumCurveBits) -
selectProtocolName
- Throws:
IOException
-
selectProtocolName
-
shouldSelectProtocolNameEarly
protected boolean shouldSelectProtocolNameEarly() -
preferLocalClientCertificateTypes
protected boolean preferLocalClientCertificateTypes() -
getAllowedClientCertificateTypes
protected short[] getAllowedClientCertificateTypes() -
getNewConnectionID
protected byte[] getNewConnectionID()RFC 9146 DTLS connection ID. This method will be called if a connection_id extension was sent by the client. If the return value is non-null, the server will send this connection ID to the client to use in future packets. As future communication doesn't include the connection IDs length, this should either be fixed-length or include the connection ID's length. (see explanation in RFC 9146 4. "cid:")- Returns:
- The connection ID to use.
-
init
-
getProtocolVersions
- Specified by:
getProtocolVersions
in interfaceTlsPeer
-
getCipherSuites
public int[] getCipherSuites()- Specified by:
getCipherSuites
in interfaceTlsPeer
-
notifyHandshakeBeginning
Description copied from interface:TlsPeer
Notifies the peer that a new handshake is about to begin.- Specified by:
notifyHandshakeBeginning
in interfaceTlsPeer
- Overrides:
notifyHandshakeBeginning
in classAbstractTlsPeer
- Throws:
IOException
-
getSessionToResume
Description copied from interface:TlsServer
Return the specified session, if available. Note that the peer's certificate chain for the session (if any) may need to be periodically revalidated.- Specified by:
getSessionToResume
in interfaceTlsServer
- Parameters:
sessionID
- the ID of the session to resume.- Returns:
- A
TlsSession
with the specified session ID, or null. - See Also:
-
getNewSessionID
public byte[] getNewSessionID()- Specified by:
getNewSessionID
in interfaceTlsServer
-
getExternalPSK
Description copied from interface:TlsServer
WARNING: EXPERIMENTAL FEATURE, UNSTABLE API Return theexternal PSK
to select from the ClientHello. Note that this will only be called when TLS 1.3 or higher is amongst the offered protocol versions, and one or more PSKs are actually offered.- Specified by:
getExternalPSK
in interfaceTlsServer
- Parameters:
identities
- aVector
ofPskIdentity
instances.- Returns:
- the
TlsPSKExternal
corresponding to the selected identity, or null to not select any.
-
notifySession
- Specified by:
notifySession
in interfaceTlsServer
-
notifyClientVersion
- Specified by:
notifyClientVersion
in interfaceTlsServer
- Throws:
IOException
-
notifyFallback
- Specified by:
notifyFallback
in interfaceTlsServer
- Throws:
IOException
-
notifyOfferedCipherSuites
- Specified by:
notifyOfferedCipherSuites
in interfaceTlsServer
- Throws:
IOException
-
processClientExtensions
- Specified by:
processClientExtensions
in interfaceTlsServer
- Throws:
IOException
-
getServerVersion
- Specified by:
getServerVersion
in interfaceTlsServer
- Throws:
IOException
-
getSupportedGroups
- Specified by:
getSupportedGroups
in interfaceTlsServer
- Throws:
IOException
-
getSelectedCipherSuite
- Specified by:
getSelectedCipherSuite
in interfaceTlsServer
- Throws:
IOException
-
getServerExtensions
- Specified by:
getServerExtensions
in interfaceTlsServer
- Throws:
IOException
-
getServerExtensionsForConnection
- Specified by:
getServerExtensionsForConnection
in interfaceTlsServer
- Throws:
IOException
-
getServerSupplementalData
- Specified by:
getServerSupplementalData
in interfaceTlsServer
- Throws:
IOException
-
getCertificateStatus
Description copied from interface:TlsServer
This method will be called (only) if the server included an extension of type "status_request" with empty "extension_data" in the extended server hello. See RFC 3546 3.6. Certificate Status Request. If a non-nullCertificateStatus
is returned, it is sent to the client as a handshake message of type "certificate_status".- Specified by:
getCertificateStatus
in interfaceTlsServer
- Returns:
- A
CertificateStatus
to be sent to the client (or null for none). - Throws:
IOException
-
getCertificateRequest
- Specified by:
getCertificateRequest
in interfaceTlsServer
- Throws:
IOException
-
getPSKIdentityManager
- Specified by:
getPSKIdentityManager
in interfaceTlsServer
- Throws:
IOException
-
getSRPLoginParameters
- Specified by:
getSRPLoginParameters
in interfaceTlsServer
- Throws:
IOException
-
getDHConfig
- Specified by:
getDHConfig
in interfaceTlsServer
- Throws:
IOException
-
getECDHConfig
- Specified by:
getECDHConfig
in interfaceTlsServer
- Throws:
IOException
-
processClientSupplementalData
- Specified by:
processClientSupplementalData
in interfaceTlsServer
- Throws:
IOException
-
notifyClientCertificate
Description copied from interface:TlsServer
Called by the protocol handler to report the client certificate, only ifTlsServer.getCertificateRequest()
returned non-null. Note: this method is responsible for certificate verification and validation.- Specified by:
notifyClientCertificate
in interfaceTlsServer
- Parameters:
clientCertificate
- the effective client certificate (may be an empty chain).- Throws:
IOException
-
getNewSessionTicket
Description copied from interface:TlsServer
RFC 5077 3.3. NewSessionTicket Handshake Message.This method will be called (only) if a NewSessionTicket extension was sent by the server. See RFC 5077 4. Recommended Ticket Construction for recommended format and protection.
- Specified by:
getNewSessionTicket
in interfaceTlsServer
- Returns:
- The ticket.
- Throws:
IOException
-