/* ecc_chudnovsky.c */
/*
This file is part of the ARM-Crypto-Lib.
- Copyright (C) 2006-2012 Daniel Otte (daniel.otte@rub.de)
+ Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#if 1
#include <stdio.h>
#include "bigint_io.h"
-#include "uart_i.h"
+#include "uart.h"
#include <avr/pgmspace.h>
#endif
#define putchar(a)
#endif
-uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t* p, size_t length_B){
+uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t *p, size_t length_B){
if(!(p->x.wordv = malloc(length_B))){
+ printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
return 1;
}
if(!(p->y.wordv = malloc(length_B))){
+ printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
free(p->x.wordv);
return 1;
}
if(!(p->z1.wordv = malloc(length_B))){
+ printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
free(p->x.wordv);
free(p->y.wordv);
return 1;
}
if(!(p->z2.wordv = malloc(length_B))){
+ printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
free(p->x.wordv);
free(p->y.wordv);
free(p->z1.wordv);
return 1;
}
if(!(p->z3.wordv = malloc(length_B))){
+ printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
free(p->x.wordv);
free(p->y.wordv);
free(p->z1.wordv);
return 0;
}
-void ecc_chudnovsky_point_free(ecc_chudnovsky_point_t* p){
+void ecc_chudnovsky_point_free(ecc_chudnovsky_point_t *p){
free(p->x.wordv);
free(p->y.wordv);
free(p->z1.wordv);
uint8_t ecc_chudnovsky_double_and_add(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
- const ecc_curve_sp_t* curve){
+ const ecc_curve_sp_t *curve){
uint16_t i;
uint8_t s = 0;
bigint_word_t v, t;
return 0;
}
-uint8_t bigint_to_naf(uint8_t* dest, uint16_t *length, const bigint_t *src){
+uint8_t bigint_to_naf(uint8_t *dest, uint16_t *length, const bigint_t *src){
if(src->length_W == 0){
*dest = 0;
*length = 2;
return 0;
}
-void print_naf(uint8_t* naf, uint16_t length){
+void print_naf(uint8_t *naf, uint16_t length){
if(!length){
return;
}
uint8_t ecc_chudnovsky_naf_multiplication(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
- const ecc_curve_sp_t* curve){
+ const ecc_curve_sp_t *curve){
if(k->length_W == 0 || p->y.length_W == 0){
bigint_set_zero(&dest->y);
return 0;
}
bigint_to_naf(t, &i, k);
- printf(" naf: ");
- print_naf(t, i);
+ // printf(" naf: ");
+ // print_naf(t, i);
--i;
dest->y.length_W = 0;
uint8_t ecc_chudnovsky_multiplication(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
- const ecc_curve_sp_t* curve){
+ const ecc_curve_sp_t *curve){
return ecc_chudnovsky_naf_multiplication(dest, k, p, curve);
}
const ecc_chudnovsky_point_t *p,
const bigint_t *l,
const ecc_chudnovsky_point_t *q,
- const ecc_curve_sp_t* curve){
+ const ecc_curve_sp_t *curve){
return ecc_chudnovsky_naf_multiplication(dest, k, p, curve);
}