DatagramReader reader = new DatagramReader(byteArray);
// create explicit nonce from values provided in DTLS record
byte[] explicitNonce = generateExplicitNonce();
// retrieve actual explicit nonce as contained in GenericAEADCipher struct (8 bytes long)
byte[] explicitNonceUsed = reader.readBytes(8);
if (!Arrays.equals(explicitNonce, explicitNonceUsed) && LOGGER.isLoggable(Level.FINE)) {
StringBuffer b = new StringBuffer("The explicit nonce used by the sender does not match the values provided in the DTLS record");
b.append("\nUsed : ").append(ByteArrayUtils.toHexString(explicitNonceUsed));
b.append("\nExpected: ").append(ByteArrayUtils.toHexString(explicitNonce));
LOGGER.log(Level.FINE, b.toString());