2 Commits
Author SHA1 Message Date
logicog 555aa9820d 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-10 07:31:35 +02:00
logicog 1c685edde5 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-10 07:31:35 +02:00
+7 -2
View File
@@ -9,9 +9,13 @@ 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++) {
@@ -20,7 +24,7 @@ void chacha20_print_block(void)
write_char(' ');
}
}
#endif
void chacha20_encrypt(void)
{
@@ -47,7 +51,7 @@ void chacha20_encrypt(void)
};
}
#ifdef CHACHA20_TEST
// Test the example of RFC 7539 Section 2.4.2
void chacha20_test(void)
{
@@ -96,3 +100,4 @@ void chacha20_test(void)
print_byte(cyphertext[i]); write_char(' ');
}
}
#endif