refactor(deployment): Remove WireGuard VPN dependency and restore public service access
Remove WireGuard integration from production deployment to simplify infrastructure: - Remove docker-compose-direct-access.yml (VPN-bound services) - Remove VPN-only middlewares from Grafana, Prometheus, Portainer - Remove WireGuard middleware definitions from Traefik - Remove WireGuard IPs (10.8.0.0/24) from Traefik forwarded headers All monitoring services now publicly accessible via subdomains: - grafana.michaelschiemer.de (with Grafana native auth) - prometheus.michaelschiemer.de (with Basic Auth) - portainer.michaelschiemer.de (with Portainer native auth) All services use Let's Encrypt SSL certificates via Traefik.
This commit is contained in:
110
tests/debug/test-padding-sequence.php
Normal file
110
tests/debug/test-padding-sequence.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
echo "=== Padding Sequence Analysis ===\n\n";
|
||||
|
||||
$testData = 'HELLO WORLD';
|
||||
|
||||
// Build bit string
|
||||
$bits = '';
|
||||
|
||||
// 1. Mode indicator (4 bits)
|
||||
$bits .= '0100';
|
||||
|
||||
// 2. Character count (8 bits)
|
||||
$bits .= str_pad(decbin(11), 8, '0', STR_PAD_LEFT);
|
||||
|
||||
// 3. Data bytes
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$byte = ord($testData[$i]);
|
||||
$bits .= str_pad(decbin($byte), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
echo "After mode + count + data: " . strlen($bits) . " bits\n";
|
||||
|
||||
// 4. Terminator
|
||||
$requiredBits = 16 * 8; // 128 bits
|
||||
$terminatorLength = min(4, max(0, $requiredBits - strlen($bits)));
|
||||
$bits .= str_repeat('0', $terminatorLength);
|
||||
echo "After terminator: " . strlen($bits) . " bits\n";
|
||||
|
||||
// 5. Pad to multiple of 8
|
||||
$remainder = strlen($bits) % 8;
|
||||
if ($remainder !== 0) {
|
||||
$bits .= str_repeat('0', 8 - $remainder);
|
||||
}
|
||||
echo "After padding to byte: " . strlen($bits) . " bits\n";
|
||||
echo "Padding bits added: " . (8 - $remainder) . "\n\n";
|
||||
|
||||
// 6. Add pad codewords
|
||||
$padBytes = ['11101100', '00010001'];
|
||||
$padIndex = 0;
|
||||
$padSequence = '';
|
||||
while (strlen($bits) < $requiredBits) {
|
||||
$padByte = $padBytes[$padIndex % 2];
|
||||
$padSequence .= $padByte . ' ';
|
||||
$bits .= $padByte;
|
||||
$padIndex++;
|
||||
}
|
||||
|
||||
echo "Pad codewords needed: " . (($requiredBits - strlen($bits) + strlen($padSequence)) / 8) . "\n";
|
||||
echo "Pad sequence: {$padSequence}\n\n";
|
||||
|
||||
// Convert to codewords
|
||||
$codewords = [];
|
||||
for ($i = 0; $i < strlen($bits); $i += 8) {
|
||||
$byte = substr($bits, $i, 8);
|
||||
$codewords[] = bindec($byte);
|
||||
}
|
||||
|
||||
// Expected codewords
|
||||
$expected = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 174, 59, 64, 109, 236, 233];
|
||||
|
||||
echo "=== Codeword Comparison ===\n";
|
||||
for ($i = 0; $i < min(count($codewords), count($expected)); $i++) {
|
||||
$match = $codewords[$i] === $expected[$i] ? '✅' : '❌';
|
||||
$ourBits = str_pad(decbin($codewords[$i]), 8, '0', STR_PAD_LEFT);
|
||||
$expBits = str_pad(decbin($expected[$i]), 8, '0', STR_PAD_LEFT);
|
||||
echo "Codeword {$i}: ours={$codewords[$i]} ({$ourBits}) exp={$expected[$i]} ({$expBits}) {$match}\n";
|
||||
|
||||
if ($codewords[$i] !== $expected[$i] && $i >= 9) {
|
||||
// Show bit context
|
||||
$offset = $i * 8;
|
||||
echo " Context (bits " . ($offset - 8) . "-" . ($offset + 15) . "):\n";
|
||||
echo " Our: " . substr($bits, max(0, $offset - 8), 24) . "\n";
|
||||
$expectedBits = '';
|
||||
foreach ($expected as $cw) {
|
||||
$expectedBits .= str_pad(decbin($cw), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
echo " Expected: " . substr($expectedBits, max(0, $offset - 8), 24) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Show what the expected padding should be
|
||||
echo "\n=== Expected Padding Analysis ===\n";
|
||||
$expectedBits = '';
|
||||
foreach ($expected as $cw) {
|
||||
$expectedBits .= str_pad(decbin($cw), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
// Find where our data ends
|
||||
$dataEnd = 4 + 8 + (11 * 8); // mode + count + data
|
||||
echo "Data ends at bit: {$dataEnd}\n";
|
||||
echo "Expected bits 0-{$dataEnd}: " . substr($expectedBits, 0, $dataEnd) . "\n";
|
||||
echo "Our bits 0-{$dataEnd}: " . substr($bits, 0, $dataEnd) . "\n";
|
||||
|
||||
$expectedPadding = substr($expectedBits, $dataEnd);
|
||||
$ourPadding = substr($bits, $dataEnd);
|
||||
|
||||
echo "\nExpected padding: {$expectedPadding}\n";
|
||||
echo "Our padding: {$ourPadding}\n";
|
||||
|
||||
if ($expectedPadding === $ourPadding) {
|
||||
echo "\n✅ Padding matches!\n";
|
||||
} else {
|
||||
echo "\n❌ Padding doesn't match!\n";
|
||||
echo "First difference at bit " . ($dataEnd + strspn($expectedPadding ^ $ourPadding, "\0")) . "\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user