Actually implement fixed XOR (not repeating-key)
x1phosura x1phosura@x1phosura.zone
Wed, 27 Apr 2022 00:59:21 -0700
1 files changed,
38 insertions(+),
0 deletions(-)
jump to
A
set1/src/fixed-xor.c
@@ -0,0 +1,38 @@
+#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +/* +void fixed_xor_stream(uint8_t *key, size_t key_len) +{ + // +} +*/ + +void fixed_xor(const uint8_t *data, const size_t data_len, + const uint8_t key) +{ + uint8_t c; + size_t i; + + for (i = 0; i < data_len; ++i) { + c = data[i] ^ key; + putchar(c); + } +} + +int main() +{ + uint8_t data[] = "\x1c\x01\x11\x00\x1f\x01\x01\x00\x06\x1a\x02\x4b\x53" + "\x53\x50\x09\x18\x1c\x00\x00\x00\x00\x00\x00\x00"; + /* // above array XOR'd by 0x41 + uint8_t data[] = "\x5d\x40\x50\x41\x5e\x40\x40\x41\x47\x5b\x43\x0a\x12" + "\x12\x11\x48\x59\x5d\x41\x41\x41\x41\x41\x41\x41"; + */ + uint8_t key = 0x41; + + fixed_xor(data, sizeof(data)-1, key); + + return EXIT_SUCCESS; +} +