byte[] cryptoKey = key.cryptoKey; if(cryptoKey.length < Node.SYMMETRIC_KEY_LENGTH) throw new CHKDecodeException("Crypto key too short"); try { Cipher cipher = Cipher.getInstance("AES/CTR/NOPADDING", Rijndael.AesCtrProvider); int size = ((plaintext[data.length] & 0xff) << 8) + (plaintext[data.length + 1] & 0xff); if((size > 32768) || (size < 0)) { throw new CHKDecodeException("Invalid size: "+size); throw new CHKDecodeException("HMAC is wrong, wrong decryption key?"); throw new CHKDecodeException("Problem with JCA, should be impossible!", e);
byte[] cryptoKey = key.cryptoKey; if(cryptoKey.length < Node.SYMMETRIC_KEY_LENGTH) throw new CHKDecodeException("Crypto key too short"); Rijndael aes; try { int size = ((lengthBytes[0] & 0xff) << 8) + (lengthBytes[1] & 0xff); if((size > 32768) || (size < 0)) { throw new CHKDecodeException("Invalid size: "+size); byte[] hashCheck = hmac.doFinal(); if(!Arrays.equals(hash, hashCheck)) { throw new CHKDecodeException("HMAC is wrong, wrong decryption key?"); throw new CHKDecodeException("Problem with JCA, should be impossible!", e);
throw new CHKDecodeException("Crypto key too short"); cipher.initialize(key.cryptoKey); PCFBMode pcfb = PCFBMode.create(cipher); throw new CHKDecodeException("Check failed: Decrypted IV == H(decryption key)"); throw new CHKDecodeException("Invalid size: "+size);
Logger.minor(Key.class, "Decompressing "+inputLength+" bytes in decode with codec "+compressionAlgorithm); final int inputOffset = (shortLength ? 2 : 4); if(inputLength < inputOffset + 1) throw new CHKDecodeException("No bytes to decompress"); COMPRESSOR_TYPE decompressor = COMPRESSOR_TYPE.getCompressorByMetadataID(compressionAlgorithm); if (decompressor==null) throw new CHKDecodeException("Unknown compression algorithm: "+compressionAlgorithm); InputStream inputStream = null; OutputStream outputStream = null;