Code Duplication    Length = 18-20 lines in 2 locations

src/library/sodium_compat/src/File.php 2 locations

@@ 861-880 (lines=20) @@
858
         */
859
        fseek($ifp, $first32, SEEK_SET);
860
861
        while ($mlen > 0) {
862
            $blockSize = $mlen > self::BUFFER_SIZE
863
                ? self::BUFFER_SIZE
864
                : $mlen;
865
            $plaintext = fread($ifp, $blockSize);
866
            if (!is_string($plaintext)) {
867
                throw new Error('Could not read input file');
868
            }
869
            $cBlock = ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic(
870
                $plaintext,
871
                $realNonce,
872
                $iter,
873
                $subkey
874
            );
875
            fwrite($ofp, $cBlock, $blockSize);
876
            $state->update($cBlock);
877
878
            $mlen -= $blockSize;
879
            $iter += $incr;
880
        }
881
        try {
882
            ParagonIE_Sodium_Compat::memzero($block0);
883
            ParagonIE_Sodium_Compat::memzero($subkey);
@@ 965-982 (lines=18) @@
962
        $incr = self::BUFFER_SIZE >> 6;
963
964
        /* Decrypts ciphertext, writes to output file. */
965
        while ($mlen > 0) {
966
            $blockSize = $mlen > self::BUFFER_SIZE
967
                ? self::BUFFER_SIZE
968
                : $mlen;
969
            $ciphertext = fread($ifp, $blockSize);
970
            if (!is_string($ciphertext)) {
971
                throw new Error('Could not read input file');
972
            }
973
            $pBlock = ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic(
974
                $ciphertext,
975
                $realNonce,
976
                $iter,
977
                $subkey
978
            );
979
            fwrite($ofp, $pBlock, $blockSize);
980
            $mlen -= $blockSize;
981
            $iter += $incr;
982
        }
983
        return true;
984
    }
985