forked from defuse/php-encryption
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
54 lines (40 loc) · 2.64 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Warning: This is new code, and it hasn't received much review by experts. I have
spent many hours making it as secure as possible (extensive runtime tests,
paranoid coding practices), and auditing it for problems, but I may have missed
some issues. So be careful. Don't trust it with your life. Check out the open
GitHub issues for a list of known (possible) issues. If you find a problem with
this library, please open a GitHub issue.
This library was created after noticing how much insecure PHP encryption code
there is. I once did a Google search for "php encryption" and found insecure
code or advice on 9 of the top 10 results.
Encryption is becoming an essential component of modern websites. This library
aims to fulfil a subset of that need: Authenticated symmetric encryption of
short strings, given a random key.
This library is developed around several core values:
Rule #1: Security is prioritized over everything else.
Whenever there is a conflict between security and some other property,
security will be favored. For example, the library has runtime tests,
which make it slower, but will hopefully stop it from encrypting stuff
if the platform it's running on is broken.
Rule #2: It should be difficult to misuse the library.
We assume the developers using this library have no experience with
cryptography. We only assume that they know that the "key" is something
you need to encrypt and decrypt the messages, and that it must be
protected. Whenever possible, the library should refuse to encrypt or
decrypt messages when it is not being used correctly.
Rule #3: The library aims only to be compatible with itself.
Other PHP encryption libraries try to support every possible type of
encryption, even the insecure ones (e.g. ECB mode). Because there are so
many options, inexperienced developers must make decisions between
things like "CBC" mode and "ECB" mode, knowing nothing about either one,
which inevitably creates vulnerabilities.
This library will only support one secure mode. A developer using this
library will call "encrypt" and "decrypt" not caring about how they are
implemented.
Rule #4: The library should consist of a single PHP file and nothing more.
Some PHP encryption libraries, like libsodium-php [1], are not
straightforward to install and cannot packaged with "just download and
extract" applications. This library will always be just one PHP file
that you can put in your source tree and require().
References:
[1] https://github.com/jedisct1/libsodium-php