throw new InvalidCipherTextException("unable to recover ephemeral public key: " + e.getMessage(), e);
throw new InvalidCipherTextException("Length of input must be greater than the MAC"); throw new InvalidCipherTextException("Invalid MAC.");
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in[in.length - 1] & 0xff; if (count > in.length) { throw new InvalidCipherTextException("pad block corrupted"); } return count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in[in.length - 1] & 0xff; if (count > in.length) { throw new InvalidCipherTextException("pad block corrupted"); } return count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in[in.length - 1] & 0xff; if (count > in.length) { throw new InvalidCipherTextException("pad block corrupted"); } return count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in[in.length - 1] & 0xff; if (count > in.length) { throw new InvalidCipherTextException("pad block corrupted"); } return count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in.length - 1; while (count > 0 && in[count] == 0) { count--; } if (in[count] != (byte)0x80) { throw new InvalidCipherTextException("pad block corrupted"); } return in.length - count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in.length - 1; while (count > 0 && in[count] == 0) { count--; } if (in[count] != (byte)0x80) { throw new InvalidCipherTextException("pad block corrupted"); } return in.length - count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in[in.length - 1] & 0xff; byte countAsbyte = (byte)count; // constant time version boolean failed = (count > in.length | count == 0); for (int i = 0; i < in.length; i++) { failed |= (in.length - i <= count) & (in[i] != countAsbyte); } if (failed) { throw new InvalidCipherTextException("pad block corrupted"); } return count; } }
/** * return the number of pad bytes present in the block. */ public int padCount(byte[] in) throws InvalidCipherTextException { int count = in[in.length - 1] & 0xff; if (count > in.length || count == 0) { throw new InvalidCipherTextException("pad block corrupted"); } for (int i = 1; i <= count; i++) { if (in[in.length - i] != count) { throw new InvalidCipherTextException("pad block corrupted"); } } return count; } }
private byte[] computeMessage(GF2Vector mr) throws InvalidCipherTextException { byte[] mrBytes = mr.getEncoded(); // find first non-zero byte int index; for (index = mrBytes.length - 1; index >= 0 && mrBytes[index] == 0; index--) { ; } // check if padding byte is valid if (index<0 || mrBytes[index] != 0x01) { throw new InvalidCipherTextException("Bad Padding: invalid ciphertext"); } // extract and return message byte[] mBytes = new byte[index]; System.arraycopy(mrBytes, 0, mBytes, 0, index); return mBytes; }
/** * Process a packet of data for either CCM decryption or encryption. * * @param in data for processing. * @param inOff offset at which data starts in the input array. * @param inLen length of the data in the input array. * @return a byte array containing the processed input.. * @throws IllegalStateException if the cipher is not appropriately set up. * @throws InvalidCipherTextException if the input data is truncated or the mac check fails. */ public byte[] processPacket(byte[] in, int inOff, int inLen) throws IllegalStateException, InvalidCipherTextException { byte[] output; if (forEncryption) { output = new byte[inLen + macSize]; } else { if (inLen < macSize) { throw new InvalidCipherTextException("data too short"); } output = new byte[inLen - macSize]; } processPacket(in, inOff, inLen, output, 0); return output; }
} catch (InvalidCipherTextException ice) { logger.error("Error InvalidCipherTextException: " + keyPath + keyName); throw new InvalidCipherTextException("Error InvalidCipherTextException");
.getAsString()); if (!Arrays.equals(newMac, mac)) { throw new InvalidCipherTextException("mac is not valid");
public static byte[] aesDecrypt(byte[] ivCiphertext, byte[] myPrivateKey, byte[] theirPublicKey, byte[] nonce) { try { if (ivCiphertext.length < 16 || ivCiphertext.length % 16 != 0) { throw new InvalidCipherTextException("invalid ciphertext"); } byte[] iv = Arrays.copyOfRange(ivCiphertext, 0, 16); byte[] ciphertext = Arrays.copyOfRange(ivCiphertext, 16, ivCiphertext.length); byte[] dhSharedSecret = new byte[32]; Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey); for (int i = 0; i < 32; i++) { dhSharedSecret[i] ^= nonce[i]; } byte[] key = sha256().digest(dhSharedSecret); PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher( new AESEngine())); CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv); aes.init(false, ivAndKey); byte[] output = new byte[aes.getOutputSize(ciphertext.length)]; int plaintextLength = aes.processBytes(ciphertext, 0, ciphertext.length, output, 0); plaintextLength += aes.doFinal(output, plaintextLength); byte[] result = new byte[plaintextLength]; System.arraycopy(output, 0, result, 0, result.length); return result; } catch (InvalidCipherTextException e) { throw new RuntimeException(e.getMessage(), e); } }
public static byte[] aesDecrypt(byte[] ivCiphertext, byte[] myPrivateKey, byte[] theirPublicKey, byte[] nonce) { try { if (ivCiphertext.length < 16 || ivCiphertext.length % 16 != 0) { throw new InvalidCipherTextException("invalid ciphertext"); } byte[] iv = Arrays.copyOfRange(ivCiphertext, 0, 16); byte[] ciphertext = Arrays.copyOfRange(ivCiphertext, 16, ivCiphertext.length); byte[] dhSharedSecret = new byte[32]; Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey); for (int i = 0; i < 32; i++) { dhSharedSecret[i] ^= nonce[i]; } byte[] key = sha256().digest(dhSharedSecret); PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher( new AESEngine())); CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv); aes.init(false, ivAndKey); byte[] output = new byte[aes.getOutputSize(ciphertext.length)]; int plaintextLength = aes.processBytes(ciphertext, 0, ciphertext.length, output, 0); plaintextLength += aes.doFinal(output, plaintextLength); byte[] result = new byte[plaintextLength]; System.arraycopy(output, 0, result, 0, result.length); return result; } catch (InvalidCipherTextException e) { throw new RuntimeException(e.getMessage(), e); } }
if (s.isInfinity()) throw new InvalidCipherTextException("[h]C1 at infinity"); throw new InvalidCipherTextException("invalid cipher text");
this.pubParam = keyParser.readKey(bIn); } catch (IOException e) { throw new InvalidCipherTextException("unable to recover ephemeral public key: " + e.getMessage(), e);
throw new InvalidCipherTextException("Bad Padding: invalid ciphertext");
throw new InvalidCipherTextException("Bad Padding: Invalid ciphertext.");