Support TLS 1.3 in test class
import org.bouncycastle.tls.SignatureAlgorithm;
import org.bouncycastle.tls.TlsCredentialedDecryptor;
import org.bouncycastle.tls.TlsCredentialedSigner;
+import org.bouncycastle.tls.TlsCredentials;
import org.bouncycastle.tls.TlsFatalAlert;
import org.bouncycastle.tls.TlsUtils;
import org.bouncycastle.tls.crypto.TlsCertificate;
@@ -40,6 +41,20 @@ protected Vector getProtocolNames()
return protocolNames;
}
+ public TlsCredentials getCredentials() throws IOException
+ {
+ /*
+ * TODO[tls13] Should really be finding the first client-supported signature scheme that the
+ * server also supports and has credentials for.
+ */
+ if (TlsUtils.isTLSv13(context))
+ {
+ return getRSASignerCredentials();
+ }
+
+ return super.getCredentials();
+ }
+
public void notifyAlertRaised(short alertLevel, short alertDescription, String message, Throwable cause)
{
PrintStream out = (alertLevel == AlertLevel.fatal) ? System.err : System.out;
@@ -73,9 +88,6 @@ public ProtocolVersion getServerVersion() throws IOException
public CertificateRequest getCertificateRequest() throws IOException
{
- short[] certificateTypes = new short[]{ ClientCertificateType.rsa_sign,
- ClientCertificateType.dss_sign, ClientCertificateType.ecdsa_sign };
-
Vector serverSigAlgs = null;
if (TlsUtils.isSignatureAlgorithmsExtensionAllowed(context.getServerVersion()))
{
@@ -90,8 +102,25 @@ public CertificateRequest getCertificateRequest() throws IOException
// All the CA certificates are currently configured with this subject
certificateAuthorities.addElement(new X500Name("CN=BouncyCastle TLS Test CA"));
+ if (TlsUtils.isTLSv13(context))
+ {
+ // TODO[tls13] Support for non-empty request context
+ byte[] certificateRequestContext = TlsUtils.EMPTY_BYTES;
+
+ // TODO[tls13] Add TlsTestConfig.serverCertReqSigAlgsCert
+ Vector serverSigAlgsCert = null;
+
+ return new CertificateRequest(certificateRequestContext, serverSigAlgs, serverSigAlgsCert,
+ certificateAuthorities);
+ }
+ else
+ {
+ short[] certificateTypes = new short[]{ ClientCertificateType.rsa_sign,
+ ClientCertificateType.dss_sign, ClientCertificateType.ecdsa_sign };
+
return new CertificateRequest(certificateTypes, serverSigAlgs, certificateAuthorities);
}
+ }
public void notifyClientCertificate(org.bouncycastle.tls.Certificate clientCertificate) throws IOException
{
