-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryption_diagram.html
More file actions
564 lines (495 loc) · 20.7 KB
/
encryption_diagram.html
File metadata and controls
564 lines (495 loc) · 20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Encryption & Embedding Flow — Secure LSB Steganography</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Syne:wght@400;600;700;800&display=swap');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0d0f14;
--surface: #141720;
--surface2: #1c2030;
--border: #252a3a;
--accent: #4f8ef7;
--accent2: #f7934f;
--accent3: #4ff7a8;
--accent4: #f74f7e;
--text: #e2e8f8;
--muted: #6b7394;
--mono: 'JetBrains Mono', monospace;
--sans: 'Syne', sans-serif;
}
body {
background: var(--bg);
color: var(--text);
font-family: var(--sans);
min-height: 100vh;
padding: 48px 24px 80px;
overflow-x: hidden;
}
/* ── Noise texture overlay ── */
body::before {
content: '';
position: fixed; inset: 0;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
pointer-events: none; z-index: 0;
}
.page { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; }
/* ── Header ── */
header { text-align: center; margin-bottom: 64px; }
header .eyebrow {
font-family: var(--mono);
font-size: 11px; letter-spacing: 0.2em;
color: var(--accent); text-transform: uppercase;
margin-bottom: 14px;
}
header h1 {
font-size: clamp(28px, 4vw, 48px);
font-weight: 800; line-height: 1.1;
letter-spacing: -0.02em;
}
header h1 span { color: var(--accent); }
header p {
margin-top: 14px; font-size: 15px;
color: var(--muted); max-width: 560px; margin-inline: auto;
line-height: 1.7;
}
/* ── Section label ── */
.section-label {
font-family: var(--mono);
font-size: 10px; letter-spacing: 0.18em;
color: var(--muted); text-transform: uppercase;
margin-bottom: 20px;
}
/* ── Flow diagram ── */
.flow { display: flex; flex-direction: column; gap: 0; }
.row {
display: flex; align-items: stretch;
gap: 0; position: relative;
}
/* Arrow connector between rows */
.row-connector {
display: flex; justify-content: center;
height: 36px; position: relative;
}
.row-connector::before {
content: '';
position: absolute; top: 0; left: 50%;
transform: translateX(-50%);
width: 2px; height: 24px;
background: linear-gradient(to bottom, var(--border), var(--accent));
}
.row-connector::after {
content: '▼';
position: absolute; bottom: 0; left: 50%;
transform: translateX(-50%);
font-size: 10px; color: var(--accent);
}
/* ── Box base ── */
.box {
border: 1px solid var(--border);
border-radius: 10px;
padding: 18px 22px;
background: var(--surface);
position: relative;
flex: 1;
transition: border-color 0.2s, transform 0.2s;
}
.box:hover { border-color: var(--accent); transform: translateY(-2px); }
.box .box-label {
font-family: var(--mono);
font-size: 9px; letter-spacing: 0.15em;
text-transform: uppercase; margin-bottom: 6px;
}
.box .box-title {
font-size: 15px; font-weight: 700; margin-bottom: 4px;
}
.box .box-desc {
font-size: 12px; color: var(--muted); line-height: 1.5;
}
/* colour variants */
.box.blue { border-color: #1e3a5f; }
.box.blue .box-label { color: var(--accent); }
.box.blue:hover { border-color: var(--accent); }
.box.orange { border-color: #5f3a1e; }
.box.orange .box-label { color: var(--accent2); }
.box.orange:hover { border-color: var(--accent2); }
.box.green { border-color: #1e5f3a; }
.box.green .box-label { color: var(--accent3); }
.box.green:hover { border-color: var(--accent3); }
.box.red { border-color: #5f1e2e; }
.box.red .box-label { color: var(--accent4); }
.box.red:hover { border-color: var(--accent4); }
/* ── Inline arrow between boxes in a row ── */
.h-arrow {
display: flex; align-items: center; justify-content: center;
width: 48px; flex-shrink: 0;
color: var(--muted); font-size: 18px;
position: relative;
}
.h-arrow::before {
content: '';
position: absolute; top: 50%; left: 6px; right: 6px;
height: 1px; background: var(--border);
transform: translateY(-50%);
}
.h-arrow span {
background: var(--bg); padding: 0 4px;
font-size: 14px; position: relative; z-index: 1;
color: var(--muted);
}
/* ── Byte layout strip ── */
.byte-strip {
display: flex; align-items: stretch;
border: 1px solid var(--border);
border-radius: 10px; overflow: hidden;
background: var(--surface2);
}
.byte-field {
flex: var(--flex, 1);
padding: 12px 14px;
border-right: 1px solid var(--border);
position: relative;
transition: background 0.15s;
}
.byte-field:last-child { border-right: none; }
.byte-field:hover { background: #1e2436; }
.byte-field .bf-size {
font-family: var(--mono); font-size: 10px;
font-weight: 700; margin-bottom: 3px;
}
.byte-field .bf-name {
font-size: 12px; font-weight: 600; margin-bottom: 2px;
}
.byte-field .bf-note {
font-size: 10px; color: var(--muted); line-height: 1.4;
}
.bf-version { --flex: 0.4; } .bf-version .bf-size { color: var(--muted); }
.bf-salt { --flex: 1; } .bf-salt .bf-size { color: var(--accent); }
.bf-nonce { --flex: 0.8; } .bf-nonce .bf-size { color: var(--accent2); }
.bf-ct { --flex: 2.5; } .bf-ct .bf-size { color: var(--accent3); }
.bf-tag { --flex: 1; } .bf-tag .bf-size { color: var(--accent4); }
.bf-len { --flex: 0.6; } .bf-len .bf-size { color: var(--muted); }
/* ── Nested ciphertext detail ── */
.ct-inner {
margin-top: 8px;
border: 1px dashed #252a3a;
border-radius: 6px; padding: 8px 10px;
background: #10131a;
}
.ct-inner-label {
font-family: var(--mono); font-size: 9px;
color: var(--muted); letter-spacing: 0.12em;
text-transform: uppercase; margin-bottom: 6px;
}
.ct-parts { display: flex; gap: 6px; flex-wrap: wrap; }
.ct-part {
font-family: var(--mono); font-size: 10px;
padding: 3px 8px; border-radius: 4px;
background: var(--surface); border: 1px solid var(--border);
color: var(--accent3);
}
/* ── Two-column layout ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* ── Legend ── */
.legend {
display: flex; flex-wrap: wrap; gap: 20px;
padding: 20px 24px;
border: 1px solid var(--border);
border-radius: 10px; background: var(--surface);
margin-top: 8px;
}
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot {
width: 10px; height: 10px; border-radius: 50%;
flex-shrink: 0;
}
/* ── Section wrapper ── */
.section { margin-bottom: 48px; }
/* ── Highlight badge ── */
.badge {
display: inline-block;
font-family: var(--mono); font-size: 10px;
padding: 2px 8px; border-radius: 4px;
font-weight: 600; letter-spacing: 0.05em;
margin-left: 6px; vertical-align: middle;
}
.badge-blue { background: #1e3a5f; color: var(--accent); }
.badge-orange { background: #5f3a1e; color: var(--accent2); }
.badge-green { background: #1e5f3a; color: var(--accent3); }
.badge-red { background: #5f1e2e; color: var(--accent4); }
/* ── Animations ── */
@keyframes fadeUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.animate { animation: fadeUp 0.5s ease both; }
.d1 { animation-delay: 0.05s; }
.d2 { animation-delay: 0.12s; }
.d3 { animation-delay: 0.19s; }
.d4 { animation-delay: 0.26s; }
.d5 { animation-delay: 0.33s; }
.d6 { animation-delay: 0.40s; }
.d7 { animation-delay: 0.47s; }
/* ── Divider ── */
.divider {
border: none; border-top: 1px solid var(--border);
margin: 48px 0;
}
/* ── Footer ── */
footer {
text-align: center; margin-top: 64px;
font-family: var(--mono); font-size: 11px;
color: var(--muted); letter-spacing: 0.1em;
}
@media (max-width: 700px) {
.two-col { grid-template-columns: 1fr; }
.byte-strip { flex-direction: column; }
.byte-field { border-right: none; border-bottom: 1px solid var(--border); }
.byte-field:last-child { border-bottom: none; }
.row { flex-direction: column; }
.h-arrow { width: 100%; height: 32px; }
}
</style>
</head>
<body>
<div class="page">
<!-- Header -->
<header class="animate d1">
<div class="eyebrow">Hide - A Secure LSB Steganography Tool · v1.0</div>
<h1>Encryption & <span>Embedding</span> Flow</h1>
<p>How plaintext becomes an encrypted, authenticated bitstream hidden inside an image's least significant bits.</p>
</header>
<!-- ════════════════════════════════════════
SECTION 1 — INPUT PHASE
════════════════════════════════════════ -->
<div class="section animate d2">
<div class="section-label">Phase 1 — Inputs</div>
<div class="row" style="gap:16px;">
<div class="box blue">
<div class="box-label">User input</div>
<div class="box-title">Plaintext</div>
<div class="box-desc">UTF-8 encoded text to be hidden. Wrapped with start marker + end marker before encryption.</div>
</div>
<div class="h-arrow"><span>+</span></div>
<div class="box orange">
<div class="box-label">User input</div>
<div class="box-title">Password</div>
<div class="box-desc">Optional. If provided, enables AES-256-GCM encryption. Empty = plain embedding.</div>
</div>
<div class="h-arrow"><span>+</span></div>
<div class="box green">
<div class="box-label">Source file</div>
<div class="box-title">Cover Image</div>
<div class="box-desc">Any RGB image. Converted to NumPy array. Each pixel channel contributes 1 LSB.</div>
</div>
</div>
</div>
<div class="row-connector animate d2"></div>
<!-- ════════════════════════════════════════
SECTION 2 — KEY DERIVATION
════════════════════════════════════════ -->
<div class="section animate d3">
<div class="section-label">Phase 2 — Key Derivation (encrypted path only)</div>
<div class="two-col">
<div class="box orange">
<div class="box-label">os.urandom(16)</div>
<div class="box-title">Random Salt <span class="badge badge-orange">128 bit</span></div>
<div class="box-desc">Generated fresh for every single operation. Prevents precomputed rainbow-table attacks. Stored in the payload header — no secret.</div>
</div>
<div class="box orange">
<div class="box-label">Argon2id · RFC 9106 offline profile</div>
<div class="box-title">Key Derivation</div>
<div class="box-desc">
Password + Salt → 256-bit AES key<br>
<br>
<span style="font-family:var(--mono);font-size:11px;color:var(--muted)">
Memory: 256 MB<br>
Iterations: 4<br>
Lanes: 4<br>
Output: 32 bytes
</span>
</div>
</div>
</div>
</div>
<div class="row-connector animate d3"></div>
<!-- ════════════════════════════════════════
SECTION 3 — ENCRYPTION
════════════════════════════════════════ -->
<div class="section animate d4">
<div class="section-label">Phase 3 — Authenticated Encryption</div>
<div class="row" style="gap:16px;">
<div class="box blue">
<div class="box-label">Plaintext assembly</div>
<div class="box-title">Inner Plaintext</div>
<div class="box-desc">
<code style="font-family:var(--mono);font-size:11px;color:var(--accent3)">
start_marker + plaintext + end_marker
</code>
<br><br>
Markers live <em>inside</em> the ciphertext — no structure is visible in raw image data.
</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box red">
<div class="box-label">os.urandom(12)</div>
<div class="box-title">Random Nonce <span class="badge badge-orange">96 bit</span></div>
<div class="box-desc">NIST-recommended 96-bit nonce for GCM. Fresh per operation. Stored in payload header.</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box red">
<div class="box-label">AES-256-GCM</div>
<div class="box-title">Encrypt + Authenticate</div>
<div class="box-desc">
Key + Nonce + Plaintext → Ciphertext + 128-bit Auth Tag<br><br>
The auth tag is verified <strong>before</strong> any decryption on extraction. Tampered or corrupt images are always rejected.
</div>
</div>
</div>
</div>
<div class="row-connector animate d4"></div>
<!-- ════════════════════════════════════════
SECTION 4 — PAYLOAD ASSEMBLY
════════════════════════════════════════ -->
<div class="section animate d5">
<div class="section-label">Phase 4 — Binary Payload Assembly</div>
<p style="font-size:12px;color:var(--muted);margin-bottom:14px;">
All fields concatenated in order into a single byte sequence. The 4-byte length prefix enables exact extraction — no guessing, no trailing garbage reaching the GCM tag check.
</p>
<div class="byte-strip">
<div class="byte-field bf-len">
<div class="bf-size">4 B</div>
<div class="bf-name">Length</div>
<div class="bf-note">Big-endian uint32. Byte count of everything that follows.</div>
</div>
<div class="byte-field bf-version">
<div class="bf-size">1 B</div>
<div class="bf-name">Version</div>
<div class="bf-note"><code style="font-family:var(--mono)">0x01</code> encrypted<br><code style="font-family:var(--mono)">0x00</code> plain</div>
</div>
<div class="byte-field bf-salt">
<div class="bf-size" style="color:var(--accent)">16 B</div>
<div class="bf-name">Argon2id Salt</div>
<div class="bf-note">Random per operation. Used to re-derive key on extraction.</div>
</div>
<div class="byte-field bf-nonce">
<div class="bf-size" style="color:var(--accent2)">12 B</div>
<div class="bf-name">AES-GCM Nonce</div>
<div class="bf-note">96-bit random nonce. NIST recommended size.</div>
</div>
<div class="byte-field bf-ct">
<div class="bf-size" style="color:var(--accent3)">N B</div>
<div class="bf-name">Ciphertext</div>
<div class="bf-note">
Encrypted UTF-8 payload.
<div class="ct-inner">
<div class="ct-inner-label">Decrypts to</div>
<div class="ct-parts">
<span class="ct-part">start_marker</span>
<span class="ct-part">plaintext</span>
<span class="ct-part">end_marker</span>
</div>
</div>
</div>
</div>
<div class="byte-field bf-tag">
<div class="bf-size" style="color:var(--accent4)">16 B</div>
<div class="bf-name">GCM Auth Tag</div>
<div class="bf-note">128-bit integrity proof. Verified before any plaintext is released.</div>
</div>
</div>
</div>
<div class="row-connector animate d5"></div>
<!-- ════════════════════════════════════════
SECTION 5 — LSB EMBEDDING
════════════════════════════════════════ -->
<div class="section animate d6">
<div class="section-label">Phase 5 — LSB Embedding (NumPy vectorised)</div>
<div class="row" style="gap:16px;">
<div class="box green">
<div class="box-label">numpy.unpackbits</div>
<div class="box-title">Bytes → Bit Array</div>
<div class="box-desc">
Payload bytes are unpacked into a flat array of individual bits (MSB first).
<br><br>
<code style="font-family:var(--mono);font-size:11px;color:var(--accent3)">
np.unpackbits(payload)
</code>
</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box green">
<div class="box-label">Vectorised bit masking</div>
<div class="box-title">Write to Pixel LSBs</div>
<div class="box-desc">
Each pixel channel's LSB is replaced with one payload bit.<br><br>
<code style="font-family:var(--mono);font-size:11px;color:var(--accent3)">
flat[:n] = (flat[:n] & 0xFE) | bits
</code>
<br><br>
Maximum visual change per channel: ±1 — imperceptible.
</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box green">
<div class="box-label">Lossless PNG output</div>
<div class="box-title">Stego Image</div>
<div class="box-desc">Saved as PNG — lossless compression preserves every LSB exactly. JPEG would destroy the payload.</div>
</div>
</div>
</div>
<hr class="divider">
<!-- ════════════════════════════════════════
EXTRACTION OVERVIEW
════════════════════════════════════════ -->
<div class="section animate d7">
<div class="section-label">Extraction — Reverse Path</div>
<div class="row" style="gap:16px; flex-wrap: wrap;">
<div class="box blue" style="flex: 1 1 160px;">
<div class="box-label">Step 1</div>
<div class="box-title">Read LSBs</div>
<div class="box-desc">Flatten image array, mask LSB of every channel byte.</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box blue" style="flex: 1 1 160px;">
<div class="box-label">Step 2</div>
<div class="box-title">Read Length</div>
<div class="box-desc">First 32 bits → uint32 payload length. Slice exactly that many bytes.</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box orange" style="flex: 1 1 160px;">
<div class="box-label">Step 3</div>
<div class="box-title">Re-derive Key</div>
<div class="box-desc">Extract salt from payload header. Run Argon2id with password + salt → 256-bit key.</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box red" style="flex: 1 1 160px;">
<div class="box-label">Step 4</div>
<div class="box-title">Verify & Decrypt</div>
<div class="box-desc">GCM tag verified first. On success, ciphertext decrypted. Wrong password → uniform error.</div>
</div>
<div class="h-arrow"><span>→</span></div>
<div class="box green" style="flex: 1 1 160px;">
<div class="box-label">Step 5</div>
<div class="box-title">Extract Text</div>
<div class="box-desc">Strip start/end markers from inner plaintext. Return UTF-8 string to GUI.</div>
</div>
</div>
</div>
<!-- Legend -->
<div class="legend animate d7">
<div class="legend-item"><div class="legend-dot" style="background:var(--accent)"></div> User input / plaintext domain</div>
<div class="legend-item"><div class="legend-dot" style="background:var(--accent2)"></div> Key derivation (Argon2id)</div>
<div class="legend-item"><div class="legend-dot" style="background:var(--accent4)"></div> Cryptographic operations (AES-GCM)</div>
<div class="legend-item"><div class="legend-dot" style="background:var(--accent3)"></div> Steganographic embedding / image domain</div>
<div class="legend-item"><div class="legend-dot" style="background:var(--muted)"></div> Structural metadata (length prefix, version)</div>
</div>
<footer>
Hide - A Secure LSB Steganography Tool v1.0 · AES-256-GCM + Argon2id · LSB Steganography
</footer>
</div>
</body>
</html>