Java 类org.bouncycastle.crypto.tls.ProtocolVersion 实例源码

项目:rtcdcjava    文件:DTLSTransportFactory.java   
static DTLSTransport createServerTransport(final RTCCertificate rtcCertificate,
                                           final DatagramTransport transport) throws IOException {

    final DefaultTlsServer defaultTlsServer = new DefaultTlsServer() {

        private final AsymmetricKeyParameter privateKeyAsymKeyParam = PrivateKeyFactory.createKey(rtcCertificate.getKeyPair()
                                                                                                                .getPrivate()
                                                                                                                .getEncoded());
        private final Certificate cCert = new Certificate(new org.bouncycastle.asn1.x509.Certificate[]{rtcCertificate.getCertificate().toASN1Structure()});

        @Override
        protected ProtocolVersion getMaximumVersion() {
            return ProtocolVersion.DTLSv10;
        }

        @Override
        protected ProtocolVersion getMinimumVersion() {
            return ProtocolVersion.DTLSv10;
        }

        @Override
        protected TlsSignerCredentials getRSASignerCredentials() throws IOException {
            return new DefaultTlsSignerCredentials(this.context,
                                                   this.cCert,
                                                   this.privateKeyAsymKeyParam);
        }
    };

    return new DTLSServerProtocol(SECURE_RANDOM).accept(defaultTlsServer,
                                                        transport);
}
项目:rtcdcjava    文件:DTLSTransportFactory.java   
static DTLSTransport createClientTransport(final DatagramTransport transport) throws IOException {

        final DefaultTlsClient defaultTlsClient = new DefaultTlsClient() {

            @Override
            public ProtocolVersion getClientVersion() {
                return ProtocolVersion.DTLSv10;
            }

            @Override
            public ProtocolVersion getMinimumVersion() {
                return ProtocolVersion.DTLSv10;
            }

            @Override
            public TlsAuthentication getAuthentication() throws IOException {

                return new ServerOnlyTlsAuthentication() {
                    @Override
                    public void notifyServerCertificate(final Certificate serverCertificate) throws IOException {
                        //TODO Check if certificate is signed by a trusted party.
                    }
                };
            }
        };

        return new DTLSClientProtocol(SECURE_RANDOM).connect(defaultTlsClient,
                                                             transport);
    }
项目:TLS-Attacker    文件:PseudoRandomFunctionTest.java   
/**
 * Test of compute method, of class PseudoRandomFunction.
 * 
 * @param mockedTlsContext
 * @param mockedParameters
 */
@Test
public void testComputeForTls12(@Mocked final TlsContext mockedTlsContext,
        @Mocked final SecurityParameters mockedParameters) {
    // Record expectations if/as needed:
    new Expectations() {
        {
            mockedTlsContext.getServerVersion();
            result = ProtocolVersion.TLSv12;
        }
        {
            mockedTlsContext.getSecurityParameters();
            result = mockedParameters;
        }
        {
            mockedParameters.getPrfAlgorithm();
            result = 1;
        }
    };

    byte[] secret = new byte[48];
    String label = "master secret";
    byte[] seed = new byte[60];
    Random r = new Random();
    r.nextBytes(seed);
    int size = 48;

    byte[] result1 = TlsUtils.PRF(mockedTlsContext, secret, label, seed, size);
    byte[] result2 = PseudoRandomFunction.compute(PRFAlgorithm.TLS_PRF_SHA256, secret, label, seed, size);

    assertArrayEquals(result1, result2);

    new Expectations() {
        {
            mockedParameters.getPrfAlgorithm();
            result = 2;
        }
    };

    result1 = TlsUtils.PRF(mockedTlsContext, secret, label, seed, size);
    result2 = PseudoRandomFunction.compute(PRFAlgorithm.TLS_PRF_SHA384, secret, label, seed, size);

    assertArrayEquals(result1, result2);
}
项目:irma_future_id    文件:TlsClientTest.java   
public void notifyServerVersion(ProtocolVersion serverVersion) throws IOException
{
    super.notifyServerVersion(serverVersion);

    System.out.println("Negotiated " + serverVersion);
}
项目:irma_future_id    文件:MockDTLSClient.java   
public ProtocolVersion getClientVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:irma_future_id    文件:MockDTLSClient.java   
public ProtocolVersion getMinimumVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:irma_future_id    文件:MockDTLSServer.java   
protected ProtocolVersion getMaximumVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:irma_future_id    文件:MockDTLSServer.java   
protected ProtocolVersion getMinimumVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:bc-java    文件:TlsClientTest.java   
public void notifyServerVersion(ProtocolVersion serverVersion) throws IOException
{
    super.notifyServerVersion(serverVersion);

    System.out.println("Negotiated " + serverVersion);
}
项目:bc-java    文件:MockDTLSClient.java   
public ProtocolVersion getClientVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:bc-java    文件:MockDTLSClient.java   
public ProtocolVersion getMinimumVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:bc-java    文件:MockDTLSServer.java   
protected ProtocolVersion getMaximumVersion()
{
    return ProtocolVersion.DTLSv10;
}
项目:bc-java    文件:MockDTLSServer.java   
protected ProtocolVersion getMinimumVersion()
{
    return ProtocolVersion.DTLSv10;
}