org.bouncycastle.tls.PSKTlsClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bctls-fips Show documentation
Show all versions of bctls-fips Show documentation
The Bouncy Castle Java APIs for the TLS, including a JSSE provider. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
package org.bouncycastle.tls;
import java.io.IOException;
import org.bouncycastle.tls.crypto.TlsCrypto;
public class PSKTlsClient
extends AbstractTlsClient
{
private static final int[] DEFAULT_CIPHER_SUITES = new int[]
{
CipherSuite.TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256,
CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,
CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA256,
CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA
};
protected TlsPSKIdentity pskIdentity;
public PSKTlsClient(TlsCrypto crypto, byte[] identity, byte[] psk)
{
this(crypto, new BasicTlsPSKIdentity(identity, psk));
}
public PSKTlsClient(TlsCrypto crypto, TlsPSKIdentity pskIdentity)
{
super(crypto);
this.pskIdentity = pskIdentity;
}
protected int[] getSupportedCipherSuites()
{
return TlsUtils.getSupportedCipherSuites(context.getCrypto(), DEFAULT_CIPHER_SUITES);
}
public ProtocolVersion[] getSupportedVersions()
{
// TODO[tls13] Consider whether this class should offer TLSv13
return ProtocolVersion.TLSv12.downTo(ProtocolVersion.TLSv10);
}
public TlsPSKIdentity getPSKIdentity()
{
return pskIdentity;
}
public TlsAuthentication getAuthentication() throws IOException
{
/*
* Note: This method is not called unless a server certificate is sent, which may be the
* case e.g. for RSA_PSK key exchange.
*/
throw new TlsFatalAlert(AlertDescription.internal_error);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy