/*

Source:  http://dmitry.gr/index.php?r=05.Projects&proj=10.%20Shoving%20RSA%20into%20small%20places

License: you may use this code for any non-commercial purpose as long as you give me credit in your write-up/source. For commercial uses, contact me. One final note: trying this on something like an ATtiny, which lacks hardware multiplier will be very slow (you'll notice) but it will in fact work. Comments, suggestions, grievances, complaints, requests? [dmitrygr@gmail.com].

*/

#ifndef BIG_NUM_H
#define BIG_NUM_H

#include <stdint.h>

typedef uint32_t  nbytes_t;
//typedef uint8_t  nbytes_t;

typedef struct{
	nbytes_t nbytes;	//num bytes uzed - 1   (for 2048-bit value this will be 255)
	uint8_t* data;
}BN;

char bnExpMod(BN* dst, BN* a, BN* b, BN* n);	//a^b mod n		a and b are destroyed, n stays
char bnMul(BN* d, BN* a, BN* b);
void bnSub(BN* a, const BN* b);
char bnAdd(BN* r, const BN* a, const BN* b);

#endif // BIG_NUM_H

