Source:
<code>private byte[] decryptBlockCipher(byte[] ciphertextFragment, DTLSConnectionState currentReadState) throws GeneralSecurityException { if (currentReadState == null) { throw new NullPointerException("Current read state must not be null"); } else if (ciphertextFragment == null) { throw new NullPointerException("Ciphertext must not be null"); } else if (ciphertextFragment.length % currentReadState.getRecordIvLength() != 0) { throw new GeneralSecurityException("Ciphertext doesn't fit block size!"); } else if (ciphertextFragment.length < currentReadState.getRecordIvLength() + currentReadState.getMacLength() + 1) { throw new GeneralSecurityException("Ciphertext too short!"); } DatagramReader reader = new DatagramReader(ciphertextFragment); byte[] iv = reader.readBytes(currentReadState.getRecordIvLength()); Cipher blockCipher = currentReadState.getCipherSuite().getCipher(); blockCipher.init(Cipher.DECRYPT_MODE, currentReadState.getEncryptionKey(), new IvParameterSpec(iv)); byte[] plaintext = blockCipher.doFinal(reader.readBytesLeft()); int paddingLength = plaintext[plaintext.length - 1] & 0xff; <START> int fragmentLength = plaintext.length <END> - 1 - currentReadState.getMacLength(); if (fragmentLength < paddingLength) { throw new InvalidMacException(); } fragmentLength -= paddingLength; for (int index = fragmentLength + currentReadState.getMacLength(); index < plaintext.length; ++index) { if (plaintext[index] != (byte) paddingLength) { throw new InvalidMacException(); } } byte[] content = Arrays.copyOf(plaintext, fragmentLength); byte[] macFromMessage = Arrays.copyOfRange(plaintext, fragmentLength, fragmentLength + currentReadState.getCipherSuite().getMacLength()); byte[] mac = getBlockCipherMac(currentReadState, content); if (Arrays.equals(macFromMessage, mac)) { return content; } else { throw new InvalidMacException(mac, macFromMessage); } }</code><technical_language>a detail this is more fragment length ? (but I find a name) : java int fragmentLength = plaintext.length - 1 // paddingLength byte - paddingLength - currentReadState.getMacLength(); check if java if (fragmentLength < 0) { throw new InvalidMacException(); }</technical_language>

Target:
private byte[] decryptBlockCipher(byte[] ciphertextFragment, DTLSConnectionState currentReadState) throws GeneralSecurityException { if (currentReadState == null) { throw new NullPointerException("Current read state must not be null"); } else if (ciphertextFragment == null) { throw new NullPointerException("Ciphertext must not be null"); } else if (ciphertextFragment.length % currentReadState.getRecordIvLength() != 0) { throw new GeneralSecurityException("Ciphertext doesn't fit block size!"); } else if (ciphertextFragment.length < currentReadState.getRecordIvLength() + currentReadState.getMacLength() + 1) { throw new GeneralSecurityException("Ciphertext too short!"); } DatagramReader reader = new DatagramReader(ciphertextFragment); byte[] iv = reader.readBytes(currentReadState.getRecordIvLength()); Cipher blockCipher = currentReadState.getCipherSuite().getCipher(); blockCipher.init(Cipher.DECRYPT_MODE, currentReadState.getEncryptionKey(), new IvParameterSpec(iv)); byte[] plaintext = blockCipher.doFinal(reader.readBytesLeft()); int paddingLength = plaintext[plaintext.length - 1] & 0xff; int fragmentLength = plaintext.length - 1 - paddingLength - currentReadState.getMacLength(); if (fragmentLength < 0) { throw new InvalidMacException(); } for (int index = fragmentLength + currentReadState.getMacLength(); index < plaintext.length; ++index) { if (plaintext[index] != (byte) paddingLength) { throw new InvalidMacException(); } } byte[] content = Arrays.copyOf(plaintext, fragmentLength); byte[] macFromMessage = Arrays.copyOfRange(plaintext, fragmentLength, fragmentLength + currentReadState.getCipherSuite().getMacLength()); byte[] mac = getBlockCipherMac(currentReadState, content); if (Arrays.equals(macFromMessage, mac)) { return content; } else { throw new InvalidMacException(mac, macFromMessage); } }