@Test public void testEncryptTLS10Stream() throws NoSuchAlgorithmException, CryptoException { context.setSelectedProtocolVersion(ProtocolVersion.TLS10); context.setSelectedCipherSuite(CipherSuite.TLS_RSA_WITH_RC4_128_SHA); context.setMasterSecret(ArrayConverter .hexStringToByteArray("383BA734D8F7B678D56242DE3BB607B7C2EF8B5F2640AD4A7C8E8A740B145F952F2D844B24CD4EF594D87D3AF7E1069C")); context.setClientRandom(ArrayConverter .hexStringToByteArray("19EBAD6060B420BB3851D9D47ACB933DBE70399BF6C92DA33AF01D4FB770E98C")); context.setServerRandom(ArrayConverter .hexStringToByteArray("38EC0B0DC6860F09D55DFE8188ACD81D31E0AFD0BD1EF7177C3FB0BC867271FD")); record.setCleanProtocolMessageBytes(ArrayConverter.hexStringToByteArray("1400000C5BD2239FEE954F5C5CC2A66D")); record.setContentMessageType(ProtocolMessageType.HANDSHAKE); record.setProtocolVersion(ProtocolVersion.TLS10.getValue()); recordCipher = new RecordStreamCipher(context, KeySetGenerator.generateKeySet(context)); encryptor = new RecordEncryptor(recordCipher, context); encryptor.encrypt(record); assertArrayEquals(ArrayConverter.hexStringToByteArray("00000000000000001603010010"), record.getComputations() .getAuthenticatedMetaData().getValue()); assertArrayEquals(ArrayConverter.hexStringToByteArray("4BD82D0657D876744D05455125FF0BE1F7FA293D"), record .getComputations().getMac().getValue()); assertArrayEquals(ArrayConverter.hexStringToByteArray("1400000C5BD2239FEE954F5C5CC2A66D"), record .getComputations().getAuthenticatedNonMetaData().getValue()); assertArrayEquals( ArrayConverter .hexStringToByteArray("1400000C5BD2239FEE954F5C5CC2A66D4BD82D0657D876744D05455125FF0BE1F7FA293D"), record.getComputations().getPlainRecordBytes().getValue()); assertNull(record.getComputations().getCbcInitialisationVector()); assertNull(record.getComputations().getAdditionalPaddingLength()); assertArrayEquals( record.getProtocolMessageBytes().getValue(), ArrayConverter .hexStringToByteArray("9AF018845701F7815658788BFFB824BBCAB299C4F093152814276BD641E935CA29183ABA")); }
@Override public void encrypt(BlobRecord record) { LOGGER.debug("Encrypting BlobRecord"); RecordCipher recordCipher = getRecordMostRecentCipher(); try { recordCipher.encrypt(record); } catch (CryptoException ex) { LOGGER.warn("Could not encrypt BlobRecord. Using NullCipher", ex); try { nullCipher.encrypt(record); } catch (CryptoException ex1) { LOGGER.error("Could not encrypt with NullCipher", ex1); } } context.increaseWriteSequenceNumber(); }
RecordEncryptor extends Encryptor { @Override public void encrypt(BlobRecord record) { LOGGER.debug("Encrypting BlobRecord"); RecordCipher recordCipher = getRecordMostRecentCipher(); try { recordCipher.encrypt(record); } catch (CryptoException ex) { LOGGER.warn("Could not encrypt BlobRecord. Using NullCipher", ex); try { nullCipher.encrypt(record); } catch (CryptoException ex1) { LOGGER.error("Could not encrypt with NullCipher", ex1); } } context.increaseWriteSequenceNumber(); } }
RecordEncryptor extends Encryptor { @Override public void encrypt(BlobRecord record) { LOGGER.debug("Encrypting BlobRecord"); RecordCipher recordCipher = getRecordMostRecentCipher(); try { recordCipher.encrypt(record); } catch (CryptoException ex) { LOGGER.warn("Could not encrypt BlobRecord. Using NullCipher", ex); try { nullCipher.encrypt(record); } catch (CryptoException ex1) { LOGGER.error("Could not encrypt with NullCipher", ex1); } } context.increaseWriteSequenceNumber(); } RecordEncryptor(RecordCipher recordCipher, TlsContext context); }
RecordEncryptor extends Encryptor { @Override public void encrypt(BlobRecord record) { LOGGER.debug("Encrypting BlobRecord"); RecordCipher recordCipher = getRecordMostRecentCipher(); try { recordCipher.encrypt(record); } catch (CryptoException ex) { LOGGER.warn("Could not encrypt BlobRecord. Using NullCipher", ex); try { nullCipher.encrypt(record); } catch (CryptoException ex1) { LOGGER.error("Could not encrypt with NullCipher", ex1); } } context.increaseWriteSequenceNumber(); } RecordEncryptor(RecordCipher recordCipher, TlsContext context); @Override void encrypt(BlobRecord record); @Override void encrypt(Record record); }
RecordEncryptor extends Encryptor { @Override public void encrypt(BlobRecord record) { LOGGER.debug("Encrypting BlobRecord"); RecordCipher recordCipher = getRecordMostRecentCipher(); try { recordCipher.encrypt(record); } catch (CryptoException ex) { LOGGER.warn("Could not encrypt BlobRecord. Using NullCipher", ex); try { nullCipher.encrypt(record); } catch (CryptoException ex1) { LOGGER.error("Could not encrypt with NullCipher", ex1); } } context.increaseWriteSequenceNumber(); } RecordEncryptor(RecordCipher recordCipher, TlsContext context); @Override void encrypt(BlobRecord record); @Override void encrypt(Record record);  }