Skip to content

Commit e462416

Browse files
committed
wip
1 parent 19bb9f2 commit e462416

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

docs/core/plugins/var_expand_crypt.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,38 @@ It requires a functional [[link,lib_dcrypt]] backend.
1111

1212
For dovecot-auth process this plugin is automatically usable.
1313

14+
This plugin adds `encrypt` and `decrypt` filters.
15+
1416
## Settings
1517

1618
There are no `dovecot.conf` settings for this plugin.
1719

18-
## Syntax
19-
20-
```[dovecot.conf]
21-
args=encrypted_value=%{encrypt;key=value,iv=value,noiv=yes,algo=algorithm,format=base64|hex:field}
22-
args=decrypted_value=%{decrypt;key=value,iv=value,noiv=yes,algo=algorithm,format=base64|hex:field}
23-
```
24-
2520
### Parameters
2621

27-
| Key | Value |
28-
| --- | ----- |
29-
| `algo` | Algorithm name (defaults to `aes-256-cbc`) |
30-
| `format` | Return format |
31-
| `iv` | hex-encoded value |
32-
| `key` | hex-encoded value |
33-
| `noiv` | Whether iv is included in return value |
34-
35-
Decrypt expects input in base64 or hex format.
22+
| Key | Value |
23+
| ------------------ | ----------------------------------------------------------------------------------------------------------- |
24+
| key | Encryption key, if no salt is given, must be hex encoded and match the expected length of chosen algorithm. |
25+
| iv | Initialization vector, provide if no salt is given and algorithm requires one. Must be hex encoded and match the expected length of chosen algorithm. |
26+
| salt | If provided, will use hash algorithm to create cipher key and IV with PBKDF2 algorithm. |
27+
| hash | Hash to use in PBKDF2. Defaults to SHA-256. |
28+
| rounds | Number of rounds to use in PBKDF2. Defaults to 1000. |
29+
| algorithm | Encryption algorithm. Expects OpenSSL naming. Some algorithms are not usable due to system or functional restrictions. |
30+
| raw | When set to 1, will return encrypted result in binary. |
3631

3732
::: tip
38-
It is usually best to leave iv management to Dovecot, and not use
39-
`iv` and `noiv` options at all.
33+
For better security, use key and salt to generate proper pseudorandom cipher key and IV.
4034
:::
4135

42-
### Return Formats
36+
### Usage
4337

44-
Without `noiv`, encrypt returns `iv$encrypted$`.
38+
To encrypt data, usually the easiest way is to do just `%{value|encrypt(key=key)}`.
39+
This produces output that can be decrypted with `%{encrypted_value|decrypt(key=key)`.
4540

46-
With `noiv`, just encrypted data is returned. Field(s) are encoded using
47-
format.
41+
### Return Formats
4842

49-
`key` and `iv` must be the length required by the given `algo`.
43+
If raw is zero or not used, the return value will be Dovecot specific `iv$data$` format. In case salt was used, the format is `s=salt$data$`.
5044

51-
## Example
45+
###
5246

5347
```
5448
%{encrypt;key=f1f2f3f4f5f6f7f8f1f2f3f4f5f6f7f8f1f2f3f4f5f6f7f8f1f2f3f4f5f6f7f8:password} = 93736a0f910df27f89210e096e1d639a$966c2b4f3e7487f6acdb836f8d1dc3e0$

0 commit comments

Comments
 (0)