@Test public void testEncryptTLS10Block() throws NoSuchAlgorithmException, CryptoException { context.setSelectedProtocolVersion(ProtocolVersion.TLS10); context.setSelectedCipherSuite(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA); context.setMasterSecret(ArrayConverter .hexStringToByteArray("293F23671D03203B533C7FCCE835ADD43A822FD34477CD0172129416279F5906013F152B5227A8AF68436DDA651567CE")); context.setClientRandom(ArrayConverter .hexStringToByteArray("19D50C2360B420BB3851D9D47ACB933DBE70399BF6C92DA33AF01D4FB770E98C")); context.setServerRandom(ArrayConverter .hexStringToByteArray("D4370EDB60688FCF49CA9C3A81B55B5E347E0CFC4323FB7196257B17BE344723")); record.setCleanProtocolMessageBytes(ArrayConverter.hexStringToByteArray("1400000CD424FAF2BEA85BCE69DC07D2")); record.setContentMessageType(ProtocolMessageType.HANDSHAKE); record.setProtocolVersion(ProtocolVersion.TLS10.getValue()); recordCipher = new RecordBlockCipher(context, KeySetGenerator.generateKeySet(context)); encryptor = new RecordEncryptor(recordCipher, context); encryptor.encrypt(record); assertArrayEquals(ArrayConverter.hexStringToByteArray("00000000000000001603010010"), record.getComputations() .getAuthenticatedMetaData().getValue()); assertArrayEquals(ArrayConverter.hexStringToByteArray("F4CA3F8A11CE20E1D9BE67BE9B49C2E9305035D0"), record .getComputations().getMac().getValue()); assertArrayEquals(ArrayConverter.hexStringToByteArray("1400000CD424FAF2BEA85BCE69DC07D2"), record .getComputations().getAuthenticatedNonMetaData().getValue()); assertArrayEquals(ArrayConverter.hexStringToByteArray("0B0B0B0B0B0B0B0B0B0B0B0B"), record.getComputations() .getPadding().getValue()); assertArrayEquals( ArrayConverter .hexStringToByteArray("1400000CD424FAF2BEA85BCE69DC07D2F4CA3F8A11CE20E1D9BE67BE9B49C2E9305035D00B0B0B0B0B0B0B0B0B0B0B0B"), record.getComputations().getPlainRecordBytes().getValue()); assertArrayEquals(ArrayConverter.hexStringToByteArray("A8CD0618E71B0F32F5119960197F6864"), record .getComputations().getCbcInitialisationVector().getValue()); assertArrayEquals( record.getProtocolMessageBytes().getValue(), ArrayConverter .hexStringToByteArray("8B975904A7DCF746737181652428EEDEEE9A65AE6BCA9ED0BBB5E43BF1D6C38988AC98F4A72220858A9C85B94FFE67FF")); }
@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);  }