Live data from Hacker News

Building Searchable Encrypted Databases with PHP and SQL

paragonie.com

31–33 of 33 posts

Re: Building Searchable Encrypted Databases with PHP and SQL

#31
post #30

Earlier quoted context omitted.

What are some constructions you'd consider "fair"?

AEAD cipher with nonce generated from plaintext? That would have equivalent security properties except for being needlessly complicated?

So you mean something like this?

    $nonce = sodium_crypto_generichash($message, '', 24);
    $ciphertext = $nonce . sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
        $message,
        $nonce,
        $nonce,
        $key
    );
That solves the literal search problem, but none of the others.

However, in my experience[1], when it comes to deterministic encryption, most PHP developers will use ECB mode, or CBC mode with a NULL IV.

[1]: https://meta.stackoverflow.com/q/293930/2224584

Re: Building Searchable Encrypted Databases with PHP and SQL

#33

Earlier quoted context omitted.

Very big assumptions, vector of attacks tend to begin at the webserver more so than the DB. Sometimes, these DB dumps we hear off occurred over HTTP!

Right, but if you can compromise the webserver, you can get the key and defeat any application-layer encryption a PHP developer would have access to, thereby rendering any other threat models uninterestingly broken . If you can keep the webserver secure, and on separate hardware from the database, you can protect against some attacks rather than no attacks. And if your database server is used by multiple verticals wi…

Right, so if you are rolling your own, even better is to have an API that sits between the web server and the DB and handles the decrypting and encryption. In that middleware you can now add things such as rate limiting of data requests, logging, authorization, etc.
Post reply on HN