This article builds on the original post, Mango: An Adaptive Cryptographic System, which introduced the core architecture of Mango and presented its performance benchmarks.
In this follow-up, we’ll explore the adaptive encryption profile — the heart of Mango’s adaptivity — and examine how encryption behavior is shaped by transform sequences and round configurations.
🔧Anatomy of an Adaptive Encryption Profile
An adaptive encryption profile — known in Mango as an InputProfile — is the compact program that drives Mango’s encryption engine. It defines the transform sequence, round structure, and overall encryption behavior.
It defines what transforms to run, how many rounds to apply, and how aggressively the engine should operate.
Here’s what it contains:
🧱 1. Transform Sequence
A list of transform instructions — each one is a tuple of:
(byte transformId, byte transformRounds)
Example:
(8, 3), // ButterflyTx with 3 rounds
(10, 1), // SubBytesXorMaskInvTx with 1 round
(31, 1), // ButterflyWithRotationFwdTx with 1 round
(10, 1), // SubBytesXorMaskInvTx with 1 round
This sequence defines what the engine executes, in order.
Each transform is registered in the Transform Registry with a matching ID.
✅ This entire sequence is embedded into the packet header during encryption, and is automatically extracted by CryptoLib.Decrypt(…) during decryption.
🔁 2. Global Rounds (GR)
An integer defining how many times the entire sequence is repeated during encryption. Example:
6
Think of this as the outer loop:
Each global round re-applies the full sequence
Increases security (at a performance cost)
Global rounds are also stored in the header and recovered on decrypt.
🏷️ 3. Profile Name (Optional)
This is a convenience label used by the profiler or UI to identify profiles.
📝 CryptoLib does not use this field at all.
Use it for logging, debugging, or to help choose between profiles — but it has no cryptographic role.
🔐 Example Profile
"Combined", new InputProfile("Combined", new (byte, byte)[]
{
(8, 3), // ButterflyTx, rounds 3
(10, 1), // SubBytesXorMaskInvTx, rounds 1
(31, 1), // ButterflyWithRotationFwdTx, rounds 1
(9, 1), // SubBytesXorMaskFwdTx, rounds 1
(31, 1) // ButterflyWithRotationFwdTx, rounds 1
}, 6) // Global Rounds
🧠 How It’s Used
Once constructed, the profile is passed to the crypto engine:
byte[] encrypted = crypto.Encrypt(profile, input);
During encryption, Mango automatically embeds the transform sequence and global rounds into the encrypted output packet header.
During decryption, CryptoLib.Decrypt() reads this header and reconstructs the same profile to ensure reversibility.
🧩 Bringing It All Together
static void Main(string[] args)
{
// 🔐 Step 1: Create your cryptographic engine
var crypto = new CryptoLib("my password");
// 📦 Step 2: Load or define your input data
byte[] input = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
// 🔍 Step 3: Profile the input (detect type, best sequence + rounds)
InputProfile profile = InputProfiler.GetInputProfile(input);
// 🔒 Step 4: Encrypt using adaptive configuration
byte[] encrypted = crypto.Encrypt(profile, input);
// 🔓 Step 5: Decrypt (CryptoLib pulls everything it needs from the header)
byte[] decrypted = crypto.Decrypt(encrypted);
// ✅ Step 6: Verify
bool match = input.SequenceEqual(decrypted);
Console.WriteLine(match ? "✅ Decryption successful!" : "❌ Decryption failed.");
}
That’s the entire encryption flow.
Mango doesn’t ask you to hard-code transformations or guess security parameters. The InputProfiler analyzes the input and returns an optimized InputProfile — a compact “program” that drives encryption. But this profiling layer is entirely pluggable:
Mango Developer Studio ships with a built-in Workbench.
The Workbench is designed to develop Input Profiles for domain-specific data. The included InputProfiler provides optimized profiles for common data types and a robust default for unrecognized input. Developers can also handcraft profiles for sensitive domains, write custom generators, or even apply machine learning to tune sequences for specific patterns.The engine remains the same. The intelligence is in the profile.
Comments welcome—especially from researchers, engineers, and anyone working with large or domain-specific data.
🔗 GitHub: https://github.com/Luke-Tomasello/Mango-Adaptive-Cryptographic-System
