Code Duplication    Length = 15-15 lines in 3 locations

src/library/sodium_compat/src/Crypto.php 1 location

@@ 349-363 (lines=15) @@
346
     * @param string $key
347
     * @return string
348
     */
349
    public static function aead_xchacha20poly1305_ietf_encrypt(
350
        $message = '',
351
        $ad = '',
352
        $nonce = '',
353
        $key = ''
354
    ) {
355
        $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
356
            ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
357
            $key
358
        );
359
        $nonceLast = "\x00\x00\x00\x00" .
360
            ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
361
362
        return self::aead_chacha20poly1305_ietf_encrypt($message, $ad, $nonceLast, $subkey);
363
    }
364
365
    /**
366
     * HMAC-SHA-512-256 (a.k.a. the leftmost 256 bits of HMAC-SHA-512)

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

@@ 322-336 (lines=15) @@
319
     * @return string
320
     * @throws Error
321
     */
322
    public static function aead_xchacha20poly1305_ietf_decrypt(
323
        $message = '',
324
        $ad = '',
325
        $nonce = '',
326
        $key = ''
327
    ) {
328
        $subkey = ParagonIE_Sodium_Core32_HChaCha20::hChaCha20(
329
            ParagonIE_Sodium_Core32_Util::substr($nonce, 0, 16),
330
            $key
331
        );
332
        $nonceLast = "\x00\x00\x00\x00" .
333
            ParagonIE_Sodium_Core32_Util::substr($nonce, 16, 8);
334
335
        return self::aead_chacha20poly1305_ietf_decrypt($message, $ad, $nonceLast, $subkey);
336
    }
337
338
    /**
339
     * AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
@@ 349-363 (lines=15) @@
346
     * @param string $key
347
     * @return string
348
     */
349
    public static function aead_xchacha20poly1305_ietf_encrypt(
350
        $message = '',
351
        $ad = '',
352
        $nonce = '',
353
        $key = ''
354
    ) {
355
        $subkey = ParagonIE_Sodium_Core32_HChaCha20::hChaCha20(
356
            ParagonIE_Sodium_Core32_Util::substr($nonce, 0, 16),
357
            $key
358
        );
359
        $nonceLast = "\x00\x00\x00\x00" .
360
            ParagonIE_Sodium_Core32_Util::substr($nonce, 16, 8);
361
362
        return self::aead_chacha20poly1305_ietf_encrypt($message, $ad, $nonceLast, $subkey);
363
    }
364
365
    /**
366
     * HMAC-SHA-512-256 (a.k.a. the leftmost 256 bits of HMAC-SHA-512)