1
$\begingroup$

Modern Laravel uses OpenSSL to provide AES-256-CBC encryption along with a MAC. However, I was under the impression that this is not a particularly secure approach.

  • Why does Laravel only support AES-256-CBC?

While I'm not using this feature for sensitive data, I'd still like to follow best practices.

$\endgroup$
  • $\begingroup$ Oddly, the Encrypter source seems to indicate the default is AES-128-CBC -> public function __construct($key, $cipher = 'AES-128-CBC'). $\endgroup$ – puzzlepalace Feb 11 at 20:11
  • 2
    $\begingroup$ Another thing to note is that the IV used to encrypt in CBC mode is also the key for the HMAC computation on the ciphertext. $\endgroup$ – puzzlepalace Feb 11 at 20:16
1
$\begingroup$

I see two reasons:

  • The addition of good libraries/modes is quite recent (Libsodium is only available since 7.2+ and AES-XXX-GCM with 7.1+).
  • Encrypted messages in Laravel don't have a version marker that would allow more than one scheme to coexist on a given installation. It mean that a given site must stick with one encryption scheme / key or all the existing encrypted messages will become unreadable. It makes upgrading encryption in Laravel quite hard.

...and since the current scheme (AES-256-CBC + HMAC-256) is fairly competent, Taylor is sticking with it.

$\endgroup$
1
$\begingroup$

Well, this may not be a good answer but also long to be a comment. The following quotes from LaravelAEAD

This package replaces, when installed and enabled, the default encryption implementation of Laravel, which currently supports only two variants of the same block cipher, AES-128-CBC and AES-256-CBC.

The reason for only having two options is probably based on PHP history itself, like the (not so much) recent depreciation of MCrypt.

and from LaravelAEAD's definition;

LaravelAEAD is a library which provides Advanced Encryption with Associated Data (AEAD) for Laravel.

Authenticated encryption assure the confidentiality and authenticity of data. In TLS 1.3 we have GCM and CCM modes, these are current practices.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.