|
1 |
| -# Encryption functions |
| 1 | +# Encryption user-defined functions |
2 | 2 |
|
3 | 3 | Percona Server for MySQL 8.0.28-20 adds encryption functions and variables to manage the encryption range. The functions may take an algorithm argument. Encryption converts plaintext into ciphertext using a key and an encryption algorithm.
|
4 | 4 |
|
| 5 | +## Version updates |
| 6 | + |
| 7 | +Percona Server for MySQL 8.0.40 adds the following: |
| 8 | + |
| 9 | +* Support for `PKCS1 OAEP` padding for RSA encrypt and decrypt operations |
| 10 | + |
| 11 | + <details> |
| 12 | + <summary> `PKCS1 OAEP` padding explanation</summary> |
| 13 | + PKCS1 OAEP (Optimal Asymmetric Encryption Padding) is a cryptographic technique used to add randomness to a message before encryption. This randomness helps to increase the security of the encrypted message. OAEP padding adds a layer of security by making it more difficult for attackers to exploit weaknesses in the encryption algorithm or to recover the original message. |
| 14 | + </details> |
| 15 | + |
| 16 | +* Support for `PKCS1 PSS` padding for RSA sign and verify operations |
| 17 | + |
| 18 | + <details> |
| 19 | + <summary> `PKCS1 PSS` padding explanation</summary> |
| 20 | + PKCS PSS (Probabilistic Signature Scheme) is a cryptographic algorithm used to add randomness to a message before signing it with a private key. This randomness helps to increase the security of the signature and make it more resistant to various attacks. |
| 21 | + </details> |
| 22 | + |
| 23 | +* [`encryption_udf.legacy_paddding_scheme`](#encryption_udflegacy_paddding_scheme) system variable |
| 24 | + |
| 25 | + |
5 | 26 | You can also use the user-defined functions with the PEM format keys generated externally by the OpenSSL utility.
|
6 | 27 |
|
7 | 28 | A digest uses plaintext and generates a hash value. This hash value can verify if the plaintext is unmodified. You can also sign or verify on digests to ensure that the original plaintext was not modified. You cannot decrypt the original text from the hash value.
|
@@ -64,7 +85,7 @@ A plaintext as a string.
|
64 | 85 |
|
65 | 86 | The following are the function’s parameters:
|
66 | 87 |
|
67 |
| -* algorithm - the encryption algorithm supports RSA to decrypt the string. |
| 88 | +* algorithm - the encryption algorithm supports RSA to decrypt the string. Percona Server for MySQL 8.0.40 added support for PKCS1 OAEP padding for RSA encrypt operations |
68 | 89 |
|
69 | 90 | * key_str - a string in the PEM format. The key string must have the following attributes:
|
70 | 91 |
|
@@ -116,7 +137,7 @@ A signature is a binary string.
|
116 | 137 |
|
117 | 138 | The parameters are the following:
|
118 | 139 |
|
119 |
| -* algorithm - the encryption algorithm supports either RSA or DSA to encrypt the string. |
| 140 | +* algorithm - the encryption algorithm supports either RSA or DSA to encrypt the string. Percona Server for MySQL 8.0.40 added support for PKCS1 PSS padding for RSA sign operations. |
120 | 141 |
|
121 | 142 | * digest_str - the digest binary string that is signed. Invoking create_digest generates the digest.
|
122 | 143 |
|
@@ -158,7 +179,7 @@ A `1` (success) or a `0` (failure).
|
158 | 179 |
|
159 | 180 | The parameters are the following:
|
160 | 181 |
|
161 |
| -* algorithm - supports either ‘RSA’ or ‘DSA’. |
| 182 | +* algorithm - supports either ‘RSA’ or ‘DSA’. Percona Server for MySQL 8.0.40 added support for PKCS1 PSS padding for RSA verify operations. |
162 | 183 |
|
163 | 184 | * digest_str - invoking create_digest generates this digest binary string.
|
164 | 185 |
|
@@ -308,6 +329,37 @@ The variable sets the threshold limits for create_asymmetric_priv_key user-defin
|
308 | 329 |
|
309 | 330 | The range for this variable is from 1,024 to 9,984. The default value is 9,984.
|
310 | 331 |
|
| 332 | +### encryption_udf.legacy_paddding_scheme |
| 333 | + |
| 334 | +The variable enables or disables the legacy padding scheme for certain encryption operations. |
| 335 | + |
| 336 | +| Option | Description | |
| 337 | +|--------------|------------------| |
| 338 | +| command-line | Yes | |
| 339 | +| scope | Global | |
| 340 | +| data type | Boolean | |
| 341 | +| default | OFF | |
| 342 | + |
| 343 | +This system variable is a BOOLEAN type and is set to `OFF` by default. |
| 344 | + |
| 345 | +This variable controls how the functions `asymmetric_encrypt()`, `asymmetric_decrypt()`, `asymmetric_sign()`, and `asymmetric_verify()` behave when you don’t explicitly set the padding parameter. |
| 346 | + |
| 347 | + • When encryption_udf.legacy_padding_scheme is OFF: |
| 348 | + |
| 349 | + • asymmetric_encrypt() and asymmetric_decrypt() use OAEP padding. |
| 350 | + |
| 351 | + • asymmetric_sign() and asymmetric_verify() use PKCS1_PSS padding. |
| 352 | + |
| 353 | + • When encryption_udf.legacy_padding_scheme is ON: |
| 354 | + |
| 355 | + • asymmetric_encrypt() and asymmetric_decrypt() use PKCS1 padding. |
| 356 | + |
| 357 | + • asymmetric_sign() and asymmetric_verify() use PKCS1 padding. |
| 358 | + |
| 359 | +The `asymmetric_encrypt()` and `asymmetric_decrypt()` functions accept an extra optional parameter, padding. You can set it to `no`, `pkcs1`, or `oaep`. If you don’t specify this parameter, it defaults based on the `encryption_udf.legacy_padding_scheme` value. Note that when using `OAEP` padding, the maximum message length you can encrypt is <key_size_in_bytes> - 42. The padding parameter is only valid with the RSA algorithm. |
| 360 | + |
| 361 | +Similarly, `asymmetric_sign()` and `asymmetric_verify()` also have an optional padding parameter, which can be either `pkcs1` or `pkcs1_pss`. If not explicitly set, it follows the default based on `encryption_udf.legacy_padding_scheme`. You can only use the padding parameter with RSA algorithms. |
| 362 | + |
311 | 363 | ### encryption_udf.rsa_bits_threshold
|
312 | 364 |
|
313 | 365 | The variable sets the threshold limits for the create_asymmetric_priv_key user-defined function when the function is invoked with the RSA parameter and takes precedence over the OpenSSL maximum length value.
|
|
0 commit comments