Skip to content

Commit

Permalink
Merge pull request #112 from Slamdunk/libsodium_references_only
Browse files Browse the repository at this point in the history
Refer to libsodium constants and functions
  • Loading branch information
paragonie-security committed Jan 20, 2021
2 parents b97f72b + b9643f1 commit efdef62
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Protocol/Version2.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ public static function aeadEncrypt(
$nonce = $nonceForUnitTesting;
} else {
$nonce = \random_bytes(
\ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
\SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
);
}
$nonce = \sodium_crypto_generichash(
$plaintext,
$nonce,
\ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
\SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
);
$ciphertext = \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
$ciphertext = \sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
$plaintext,
Util::preAuthEncode($header, $nonce, $footer),
$nonce,
Expand Down Expand Up @@ -340,14 +340,14 @@ public static function aeadDecrypt(
$nonce = Binary::safeSubstr(
$decoded,
0,
\ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
\SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
);
$ciphertext = Binary::safeSubstr(
$decoded,
\ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES,
$len - \ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
\SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES,
$len - \SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES
);
return \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt(
return \sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(
$ciphertext,
Util::preAuthEncode($header, $nonce, $footer),
$nonce,
Expand Down

0 comments on commit efdef62

Please sign in to comment.