Compare commits

...

4 commits

13
main.c
View file

@ -5,7 +5,6 @@
#include <stdio.h>
#define LED_PIN PD6
#define RSA_16
void exit_blink() {
for (int i = 0; i < 4; i++) {
@ -27,24 +26,28 @@ void enter_blink() {
int main() {
SystemInit();
printf("Entering...\n");
sprand(0);
funGpioInitAll();
funPinMode(LED_PIN, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP);
enter_blink();
#ifdef RANDOM
uint64_t p = gen_prime(1 << 15, 1 << 16);
uint64_t q = gen_prime(1 << 15, 1 << 16);
uint64_t q = p;
while (p == q) p = gen_prime(1 << 15, 1 << 16);
#else
uint64_t p = 56857;
uint64_t q = 47963;
#endif
uint64_t n = p * q;
uint64_t phi_n = (p - 1) * (q - 1);
// 'e' is public. E for encrypt.
uint64_t e = prand_range(3, phi_n - 1);
uint64_t e = 0;
while (gcd(e, phi_n) != 1) e = prand_range(3, phi_n - 1);
// 'd' is our private key. D as in decrypt