Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| Encryption | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Config; |
| 4 | |
| 5 | use CodeIgniter\Config\BaseConfig; |
| 6 | |
| 7 | /** |
| 8 | * Encryption configuration. |
| 9 | * |
| 10 | * These are the settings used for encryption, if you don't pass a parameter |
| 11 | * array to the encrypter for creation/initialization. |
| 12 | */ |
| 13 | class Encryption extends BaseConfig |
| 14 | { |
| 15 | /** |
| 16 | * -------------------------------------------------------------------------- |
| 17 | * Encryption Key Starter |
| 18 | * -------------------------------------------------------------------------- |
| 19 | * |
| 20 | * If you use the Encryption class you must set an encryption key (seed). |
| 21 | * You need to ensure it is long enough for the cipher and mode you plan to use. |
| 22 | * See the user guide for more info. |
| 23 | */ |
| 24 | public string $key = ''; |
| 25 | |
| 26 | /** |
| 27 | * -------------------------------------------------------------------------- |
| 28 | * Previous Encryption Keys |
| 29 | * -------------------------------------------------------------------------- |
| 30 | * |
| 31 | * When rotating encryption keys, add old keys here to maintain ability |
| 32 | * to decrypt data encrypted with previous keys. Encryption always uses |
| 33 | * the current $key. Decryption tries current key first, then falls back |
| 34 | * to previous keys if decryption fails. |
| 35 | * |
| 36 | * In .env file, use comma-separated string: |
| 37 | * encryption.previousKeys = hex2bin:9be8c64fcea509867...,hex2bin:3f5a1d8e9c2b7a4f6... |
| 38 | * |
| 39 | * @var list<string>|string |
| 40 | */ |
| 41 | public array|string $previousKeys = ''; |
| 42 | |
| 43 | /** |
| 44 | * -------------------------------------------------------------------------- |
| 45 | * Encryption Driver to Use |
| 46 | * -------------------------------------------------------------------------- |
| 47 | * |
| 48 | * One of the supported encryption drivers. |
| 49 | * |
| 50 | * Available drivers: |
| 51 | * - OpenSSL |
| 52 | * - Sodium |
| 53 | */ |
| 54 | public string $driver = 'OpenSSL'; |
| 55 | |
| 56 | /** |
| 57 | * -------------------------------------------------------------------------- |
| 58 | * SodiumHandler's Padding Length in Bytes |
| 59 | * -------------------------------------------------------------------------- |
| 60 | * |
| 61 | * This is the number of bytes that will be padded to the plaintext message |
| 62 | * before it is encrypted. This value should be greater than zero. |
| 63 | * |
| 64 | * See the user guide for more information on padding. |
| 65 | */ |
| 66 | public int $blockSize = 16; |
| 67 | |
| 68 | /** |
| 69 | * -------------------------------------------------------------------------- |
| 70 | * Encryption digest |
| 71 | * -------------------------------------------------------------------------- |
| 72 | * |
| 73 | * HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'. |
| 74 | */ |
| 75 | public string $digest = 'SHA512'; |
| 76 | |
| 77 | /** |
| 78 | * Whether the cipher-text should be raw. If set to false, then it will be base64 encoded. |
| 79 | * This setting is only used by OpenSSLHandler. |
| 80 | * |
| 81 | * Set to false for CI3 Encryption compatibility. |
| 82 | */ |
| 83 | public bool $rawData = true; |
| 84 | |
| 85 | /** |
| 86 | * Encryption key info. |
| 87 | * This setting is only used by OpenSSLHandler. |
| 88 | * |
| 89 | * Set to 'encryption' for CI3 Encryption compatibility. |
| 90 | */ |
| 91 | public string $encryptKeyInfo = ''; |
| 92 | |
| 93 | /** |
| 94 | * Authentication key info. |
| 95 | * This setting is only used by OpenSSLHandler. |
| 96 | * |
| 97 | * Set to 'authentication' for CI3 Encryption compatibility. |
| 98 | */ |
| 99 | public string $authKeyInfo = ''; |
| 100 | |
| 101 | /** |
| 102 | * Cipher to use. |
| 103 | * This setting is only used by OpenSSLHandler. |
| 104 | * |
| 105 | * Set to 'AES-128-CBC' to decrypt encrypted data that encrypted |
| 106 | * by CI3 Encryption default configuration. |
| 107 | */ |
| 108 | public string $cipher = 'AES-256-CTR'; |
| 109 | } |