2 Commits
Author SHA1 Message Date
logicog 4e39d81992 Makefile: Lower limit of --xram-size to protect ChaCha20 space
ChaCha20 uses 256 bytes starting from 0xbf00 for its calculations.
Make sure the linker checks that this space is not overwritten.
2026-10-06 17:42:29 +02:00
logicog 7621045de1 ChaCha20 implementation for encryption
Add an implementation in 8051 assembler for the generation of a
ChaCha20 keystream and an encryption function using the keystream
in C.

A test function using the example from RFC7539 is provided in
chacha20_test.

Keys, nonce, and block counter and the pointers to the input plaintext,
its length and the output pointer are provided via a struct chacha20,
which also holds the working state of the ChaCha20 algorithm
2026-10-05 09:27:52 +02:00
+2 -7
View File
@@ -9,13 +9,9 @@ void chacha_count(void);
__xdata struct chacha20_t __at(0xbf00) chacha20;
#ifdef CHACHA20_TEST
__xdata uint8_t plaintext[256];
__xdata uint8_t cyphertext[256];
#endif
#ifdef DEBUG
void chacha20_print_block(void)
{
for (uint8_t i=0; i < 64; i++) {
@@ -24,7 +20,7 @@ void chacha20_print_block(void)
write_char(' ');
}
}
#endif
void chacha20_encrypt(void)
{
@@ -51,7 +47,7 @@ void chacha20_encrypt(void)
};
}
#ifdef CHACHA20_TEST
// Test the example of RFC 7539 Section 2.4.2
void chacha20_test(void)
{
@@ -100,4 +96,3 @@ void chacha20_test(void)
print_byte(cyphertext[i]); write_char(' ');
}
}
#endif