Skip to content

Commit a6cb142

Browse files
committed
PS-9715 [DOCS] - Update encryption functions for readability - 8.0
modified: docs/encryption-functions.md modified: docs/glossary.md
1 parent 57b4057 commit a6cb142

5 files changed

+877
-241
lines changed

docs/digest-encryption.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Cryptographic digest functions vs. encryption: critical distinctions
2+
3+
These two fundamental cryptographic technologies serve different security purposes and should not be confused in implementation:
4+
5+
* Cryptographic Digest Functions (hashes):
6+
7+
* Generate a fixed-length unique data representation that serves as a cryptographic fingerprint
8+
9+
* Provide data integrity verification by detecting modifications at the bit level
10+
11+
* Can be digitally signed to verify data origin and authenticate the source
12+
13+
* Implement mathematically irreversible one-way functions by design
14+
15+
* Common implementation error: Attempting to retrieve original data from digest values, which is mathematically impossible
16+
17+
* Encryption:
18+
19+
* Implements reversible transformation of data using cryptographic algorithms
20+
21+
* Renders data unreadable without the appropriate decryption key
22+
23+
* Ensures complete data recovery with the correct cryptographic key
24+
25+
* Common implementation error: Inadequate key management leading to permanent data loss
26+
27+
28+
### When to use which
29+
30+
Use digests when:
31+
32+
* You need to verify data hasn't changed
33+
34+
* You want to store passwords (never store actual passwords, ever!)
35+
36+
* You need to create a digital signature
37+
38+
Use encryption when:
39+
40+
* You need to keep data secret but retrieve it later
41+
42+
* You're storing sensitive information that must remain recoverable
43+
44+
* You need to securely transmit data over insecure channels
45+
46+
## Key length considerations for security-performance balance
47+
48+
Selecting appropriate cryptographic key lengths requires balancing security requirements with computational overhead. The following considerations should guide implementation decisions:
49+
50+
* Key length security characteristics:
51+
52+
* Security strength increases exponentially with bit length - a 2048-bit RSA key provides significantly higher security than a 1024-bit key
53+
54+
* Computational requirements increase proportionally with key length, affecting system performance
55+
56+
* Security margin increases logarithmically - doubling key length provides exponentially more possible combinations
57+
58+
* Common implementation error: Implementing maximum key lengths for all applications without considering performance implications
59+
60+
* Two types of cryptographic relationships:
61+
62+
* Symmetric: Same key locks and unlocks (AES, etc.)
63+
64+
* Like having one key that works on both sides of your door
65+
66+
* Blazingly fast compared to asymmetric encryption
67+
68+
* The problem: How do you securely share that key with other parties without exposing it during transmission
69+
70+
* Asymmetric: Different keys for locking and unlocking (RSA, DSA, etc.)
71+
72+
* Like a safety deposit box where you have one key and the bank has another
73+
74+
* Significantly slower (think 1000x or more) than symmetric encryption
75+
76+
* But solves the key distribution problem brilliantly
77+
78+
* This is what we're focusing on in this document
79+
80+
* Size limits that will bite you:
81+
82+
* RSA can only encrypt messages smaller than your key size (minus padding)
83+
84+
* A 2048-bit key can't encrypt a 2048-bit message - more on this particular trap later
85+
86+
* If you try to encrypt something too large, you'll get an error that explains absolutely nothing.

docs/encryption-functions-overview.md

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
## Encryption functions overview
2+
3+
This document provides comprehensive information about encryption functions that transform plaintext data into encrypted ciphertext. These functions provide robust security measures that require proper documentation to implement and maintain effectively. This guide offers the necessary information for successful implementation.
4+
5+
6+
7+
## Overview of capabilities
8+
9+
This documentation will guide you through:
10+
11+
* Implementing data encryption protocols
12+
13+
* Executing data decryption procedures
14+
15+
* Implementing digital signature authentication
16+
17+
* Avoiding common implementation pitfalls
18+
19+
20+
21+
22+
First, let's review some key terms you'll encounter throughout this guide.
23+
24+
25+
## Glossary of terms
26+
27+
Here's a quick reference guide to the cryptographic terms used in this document:
28+
29+
* **Encryption**: The process of converting readable data into a coded format that can only be decoded with the correct key.
30+
31+
* **Decryption**: The reverse process of encryption, converting coded data back to its original readable form.
32+
33+
* **Symmetric Encryption**: A type of encryption where the same key is used for both encryption and decryption, like a single key that locks and unlocks the same door.
34+
35+
* **Asymmetric Encryption**: A type of encryption that uses a pair of keys - a public key for encryption and a private key for decryption, or vice versa.
36+
37+
* **RSA** (Rivest-Shamir-Adleman): One of the most widely used asymmetric encryption algorithms, named after its creators.
38+
39+
* **DSA** (Digital Signature Algorithm): An algorithm specifically designed for creating digital signatures.
40+
41+
* **DH** (Diffie-Hellman): A method that allows two parties to establish a shared secret key over an insecure channel without sharing any secret information beforehand.
42+
43+
* **Digest/Hash**: A fixed-size string of bytes generated from input data of any size, functioning like a digital fingerprint of the data.
44+
45+
* **Digital Signature**: An electronic equivalent of a handwritten signature that uses asymmetric cryptography to verify authenticity.
46+
47+
* **Padding**: Additional data added to a message before encryption to enhance security and prevent pattern analysis.
48+
49+
* **PEM Format**: Privacy Enhanced Mail format, a common format for storing and sending cryptographic keys, certificates, and other data.
50+
51+
Now, let's examine common implementation challenges in encryption systems.
52+
53+
## Implementation challenges
54+
55+
> ⚠️ **Common encryption mistakes**
56+
>
57+
> Key management is a critical aspect of encryption systems that requires rigorous planning and careful implementation.
58+
>
59+
60+
Here are the most common implementation issues:
61+
62+
* Key loss: When decryption keys are lost, data becomes permanently inaccessible, even to authorized personnel.
63+
64+
*Algorithm-key mismatch: Using incompatible keys and algorithms results in decryption failures.
65+
66+
* Exceeding size limitations: Attempting to encrypt data larger than algorithm constraints can cause failures in both encryption and decryption processes.
67+
68+
* Insufficient documentation: Failing to properly document the encryption process and key management procedures can lead to system failures.
69+
70+
## Version updates
71+
72+
Percona Server for MySQL 8.0.41 introduces several important new features that enhance security capabilities while requiring careful implementation.
73+
74+
### Padding options for RSA encryption
75+
76+
| Padding type | Security level | Application | Characteristics |
77+
|--------------|----------------|------------------------|------------------------------------------------|
78+
| `pkcs1` | Basic | Legacy compatibility | Standard protection with known limitations |
79+
| `oaep` | High | Modern applications | Enhanced protection with additional security layers |
80+
| `no` | None | Specialized cases only | No protection, vulnerable to multiple attack vectors |
81+
82+
#### Detailed padding explanations
83+
84+
<details>
85+
<summary> `pkcs1` padding: The nostalgic option</summary>
86+
87+
Think of `pkcs1` padding as the security equivalent of a 90s-era car alarm. It adds random stuffing to your message to stop pattern analysis, making your message look different each time. It's decent protection against casual thieves but not against determined professionals with modern tools. It's like putting your valuables in a safe that shouts "HEY! I'M A SAFE!" when touched.
88+
</details>
89+
90+
<details>
91+
<summary> `oaep` padding: The recommended secure option</summary>
92+
93+
`oaep` padding (Optimal Asymmetric Encryption Padding) implements a mathematically robust random mask that significantly increases resistance to cryptanalysis (the science of breaking encryption). This method applies multiple layers of protection to the encrypted data, making it the recommended option for systems requiring high security standards. The additional computational overhead is justified by the enhanced security protections it provides.
94+
</details>
95+
96+
<details>
97+
<summary> `no` padding: Non-secure implementation option</summary>
98+
99+
The unpadded encryption implementation provides no additional cryptographic protection for the message content. This approach eliminates randomization elements, exposing the encrypted data to various cryptanalytic attacks including pattern analysis. This option should only be implemented in specialized circumstances where compatibility with specific systems is required or where separate security controls are implemented at another layer. Not recommended for standard security implementations.
100+
</details>
101+
102+
103+
### Signature padding options
104+
105+
| Padding Type | Security Level | Characteristics | Best For |
106+
|-------------|---------------|-----------------|----------|
107+
| `pkcs1` | Standard | Consistent signatures | Compatibility with older systems |
108+
| `pkcs1_pss` | High | Unique signature every time | Modern security needs |
109+
110+
<details>
111+
<summary> `pkcs1` padding: The basic signature</summary>
112+
113+
`pkcs1` padding for signatures is like signing your name the same way every time. It takes your message, creates a fingerprint, adds some standard framing, and locks it with your private key. It works fine until someone figures out how to copy your signature style, at which point your security is compromised. It's simple and compatible with older systems, but not the strongest option available.
114+
</details>
115+
116+
<details>
117+
<summary> `pkcs1_pss` padding: The signature with flair</summary>
118+
119+
`pkcs1_pss` padding is like adding a unique flourish to your signature every single time. Even when signing the exact same document twice, the signatures will look completely different - yet both will verify correctly. This makes signature forgery dramatically harder, as there's no consistent pattern to copy. If you're serious about security (and if you're reading this, you should be), this is your go-to option.
120+
</details>
121+
122+
123+
### Other new features
124+
125+
* [`encryption_udf.legacy_padding_scheme`](#encryption_udflegacy_padding_scheme) system variable - provides compatibility with legacy systems and previous implementations
126+
127+
* Character set awareness - ensures proper handling of different character encodings during encryption operations
128+
129+
Percona Server for MySQL 8.0.28-20 introduces tools for selective data encryption, allowing precise control over which data elements receive encryption protections.
130+
131+
## Character sets and component encryption UDFs
132+
133+
> 🏭 **Automated feature**
134+
>
135+
> These functions automatically manage character sets, eliminating the need for manual character encoding management during encryption operations.
136+
137+
The implementation handles complex character set conversions internally, allowing developers to focus on encryption logic rather than encoding issues.
138+
139+
### What happens to your input
140+
141+
| Input Type | What Happens | Why It Matters |
142+
|------------|--------------|----------------|
143+
| Algorithms, digest names, keys | Automatically converted to ASCII | Prevents character encoding mismatches between encryption and decryption operations |
144+
| Messages and signatures | Transformed into raw binary | Computers process binary, not human-readable formats |
145+
146+
147+
### What you get back
148+
149+
| Output Type | Format | What to Expect |
150+
|------------|--------|----------------|
151+
| Key files | Human-readable ASCII text | Viewable without terminal issues |
152+
| Encrypted messages & signatures | Binary data | Looks like gibberish (this is correct!) |
153+
154+
## External key management
155+
156+
> 🔒 **External Key Management**
157+
>
158+
> For enhanced security, cryptographic keys can be generated outside the database server using dedicated cryptographic tools and hardware.
159+
160+
Keys can be generated externally with OpenSSL and imported into the system. This approach separates key generation from the database environment, reducing the attack surface and allowing for specialized key generation hardware if required.
161+
162+
163+
### External key generation
164+
165+
| Tool | Command Example | What It Creates |
166+
|------|----------------|-----------------|
167+
| OpenSSL | `openssl genrsa -out private.pem 2048` | RSA private key |
168+
| OpenSSL | `openssl rsa -in private.pem -pubout -out public.pem` | RSA public key from private key |
169+
| OpenSSL | `openssl dsaparam -genkey 2048 -out dsaprivate.pem` | DSA private key |
170+
171+
Your OpenSSL-generated keys work seamlessly with these functions - just read the PEM file and pass its content to the encryption functions.
172+
173+
174+
### How you might break this
175+
176+
⚠️ **Common Mistakes With External Keys:**
177+
178+
* Importing a key in the wrong format
179+
180+
* Using a key type incompatible with your chosen algorithm
181+
182+
* Forgetting to remove newlines from PEM files when storing in variables
183+
184+
* Storing keys directly in your database without proper protection
185+
186+
If you encounter any of these issues, you may receive a non-descriptive error message. Ensure that your keys are correctly formatted and stored securely.
187+
188+

0 commit comments

Comments
 (0)