#include <stdlib.h>
#include <string.h>
#include "bigint.h"
+#include "bigint_io.h"
#include "rsa_basic.h"
#include "cli.h"
+#include "uart_lowlevel.h"
void rsa_enc(bigint_t* data, rsa_publickey_t* key){
+/*
+ cli_putstr("\r\n -->rsa_enc()\r\n m = ");
+ bigint_print_hex(data);
+ cli_putstr("\r\n e = ");
+ bigint_print_hex(key->exponent);
+ cli_putstr("\r\n n = ");
+ bigint_print_hex(key->modulus);
+*/
bigint_expmod_u(data, data, key->exponent, key->modulus);
}
m1.wordv = malloc(key->components[0]->length_B * sizeof(bigint_word_t));
m2.wordv = malloc(key->components[1]->length_B * sizeof(bigint_word_t));
if(!m1.wordv || !m2.wordv){
+ cli_putstr("\r\nERROR: OOM!");
free(m1.wordv);
free(m2.wordv);
return 1;
while(BIGINT_NEG_MASK & m1.info){
bigint_add_s(&m1, &m1, key->components[0]);
}
+
bigint_reduce(&m1, key->components[0]);
bigint_mul_u(data, &m1, key->components[4]);
bigint_reduce(data, key->components[0]);