 							} else {
 								var bytesLeft:uint = input.bytesAvailable - 176;
 								if (bytesLeft > 0 && bytesLeft < 15) {
-									decryptToBuffer(input, input.bytesAvailable);
+									if (!decryptToBuffer(input, input.bytesAvailable)) {
+										break;
+									}
 								} else {
-									decryptToBuffer(input, 176);
+									if (!decryptToBuffer(input, 176)) {
+										break;
+									}
 								}
 							}
 							_decryptBuffer.readBytes(packet, 0, 187);

			return output.length === 0 ? null : output;
		}
		
		private function decryptToBuffer(input:IDataInput, blockSize:int):void{
			if (_key) {
				// Clear buffer
				if (_decryptBuffer.bytesAvailable == 0) {
					_decryptBuffer.clear();
				}
				if (_key.type == "AES-128" && blockSize % 16 == 0) {
					// Save buffer position
					var currentPosition:uint = _decryptBuffer.position;
					_decryptBuffer.position += _decryptBuffer.bytesAvailable;

					_decryptBuffer.position = currentPosition;
					// Update iv
					_iv = newIv;
					
					return true;
				}
			}
			
			return false;
		}
		
		override public function endProcessFile(input:IDataInput):ByteArray
