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

项目:irma_future_id    文件:TlsTestUtils.java   
static TlsAgreementCredentials loadAgreementCredentials(TlsContext context,
                                                        String[] certResources, String keyResource)
    throws IOException
{

    Certificate certificate = loadCertificateChain(certResources);
    AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource);

    return new DefaultTlsAgreementCredentials(certificate, privateKey);
}
项目:irma_future_id    文件:TlsTestUtils.java   
static TlsEncryptionCredentials loadEncryptionCredentials(TlsContext context,
                                                          String[] certResources, String keyResource)
    throws IOException
{

    Certificate certificate = loadCertificateChain(certResources);
    AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource);

    return new DefaultTlsEncryptionCredentials(context, certificate, privateKey);
}
项目:irma_future_id    文件:TlsTestUtils.java   
static TlsSignerCredentials loadSignerCredentials(TlsContext context, String[] certResources,
                                                  String keyResource)
    throws IOException
{

    Certificate certificate = loadCertificateChain(certResources);
    AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource);

    return new DefaultTlsSignerCredentials(context, certificate, privateKey);
}
项目:bc-java    文件:TlsTestUtils.java   
static TlsAgreementCredentials loadAgreementCredentials(TlsContext context,
                                                        String[] certResources, String keyResource)
    throws IOException
{

    Certificate certificate = loadCertificateChain(certResources);
    AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource);

    return new DefaultTlsAgreementCredentials(certificate, privateKey);
}
项目:bc-java    文件:TlsTestUtils.java   
static TlsEncryptionCredentials loadEncryptionCredentials(TlsContext context,
                                                          String[] certResources, String keyResource)
    throws IOException
{

    Certificate certificate = loadCertificateChain(certResources);
    AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource);

    return new DefaultTlsEncryptionCredentials(context, certificate, privateKey);
}
项目:bc-java    文件:TlsTestUtils.java   
static TlsSignerCredentials loadSignerCredentials(TlsContext context, String[] certResources,
                                                  String keyResource)
    throws IOException
{

    Certificate certificate = loadCertificateChain(certResources);
    AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource);

    return new DefaultTlsSignerCredentials(context, certificate, privateKey);
}
项目: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);
}