static TlsAgreementCredentials loadAgreementCredentials(TlsContext context, String[] certResources, String keyResource) throws IOException { Certificate certificate = loadCertificateChain(certResources); AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource); return new DefaultTlsAgreementCredentials(certificate, privateKey); }
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); }
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); }
/** * 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); }