Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: test-lpc1768 oldheating gps motorhome ... more
bignum/bignum.h@61:d4fc276a824e, 2019-09-26 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu Sep 26 07:20:30 2019 +0000
- Revision:
- 61:d4fc276a824e
- Parent:
- 60:b4f337685ec4
Added 512 bit big numbers to existing 1024 and 2048 bit.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 60:b4f337685ec4 | 1 | #include <stdint.h> |
| andrewboyson | 60:b4f337685ec4 | 2 | #include <stdbool.h> |
| andrewboyson | 60:b4f337685ec4 | 3 | |
| andrewboyson | 60:b4f337685ec4 | 4 | //Assembly instructions |
| andrewboyson | 60:b4f337685ec4 | 5 | extern void BnZer2048(uint32_t* acc); |
| andrewboyson | 60:b4f337685ec4 | 6 | extern void BnInc2048(uint32_t* acc); |
| andrewboyson | 60:b4f337685ec4 | 7 | extern bool BnShr2048(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 60:b4f337685ec4 | 8 | extern bool BnShl2048(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 60:b4f337685ec4 | 9 | extern void BnCpy2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 10 | extern void BnOrr2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 11 | extern void BnAdd2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 12 | extern void BnSub2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 13 | extern bool BnIse2048( uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 14 | extern bool BnIne2048( uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 15 | extern int BnCmp2048(uint32_t* lhs, uint32_t* rhs); |
| andrewboyson | 60:b4f337685ec4 | 16 | |
| andrewboyson | 60:b4f337685ec4 | 17 | extern void BnZer1024(uint32_t* acc); |
| andrewboyson | 60:b4f337685ec4 | 18 | extern void BnInc1024(uint32_t* acc); |
| andrewboyson | 60:b4f337685ec4 | 19 | extern bool BnShr1024(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 60:b4f337685ec4 | 20 | extern bool BnShl1024(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 60:b4f337685ec4 | 21 | extern void BnCpy1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 22 | extern void BnOrr1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 23 | extern void BnAdd1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 24 | extern void BnSub1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 25 | extern bool BnIse1024( uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 26 | extern bool BnIne1024( uint32_t* value); |
| andrewboyson | 60:b4f337685ec4 | 27 | extern int BnCmp1024(uint32_t* lhs, uint32_t* rhs); |
| andrewboyson | 60:b4f337685ec4 | 28 | |
| andrewboyson | 61:d4fc276a824e | 29 | extern void BnZer512 (uint32_t* acc); |
| andrewboyson | 61:d4fc276a824e | 30 | extern void BnInc512 (uint32_t* acc); |
| andrewboyson | 61:d4fc276a824e | 31 | extern bool BnShr512 (uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 61:d4fc276a824e | 32 | extern bool BnShl512 (uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 61:d4fc276a824e | 33 | extern void BnCpy512 (uint32_t* acc, uint32_t* value); |
| andrewboyson | 61:d4fc276a824e | 34 | extern void BnOrr512 (uint32_t* acc, uint32_t* value); |
| andrewboyson | 61:d4fc276a824e | 35 | extern void BnAdd512 (uint32_t* acc, uint32_t* value); |
| andrewboyson | 61:d4fc276a824e | 36 | extern void BnSub512 (uint32_t* acc, uint32_t* value); |
| andrewboyson | 61:d4fc276a824e | 37 | extern bool BnIse512 ( uint32_t* value); |
| andrewboyson | 61:d4fc276a824e | 38 | extern bool BnIne512 ( uint32_t* value); |
| andrewboyson | 61:d4fc276a824e | 39 | extern int BnCmp512 (uint32_t* lhs, uint32_t* rhs); |
| andrewboyson | 61:d4fc276a824e | 40 | |
| andrewboyson | 60:b4f337685ec4 | 41 | // Text functions |
| andrewboyson | 60:b4f337685ec4 | 42 | extern void BnParseHex2048(uint32_t* n, const char* p); |
| andrewboyson | 60:b4f337685ec4 | 43 | extern void BnAsHttp2048 (uint32_t* n); |
| andrewboyson | 60:b4f337685ec4 | 44 | extern void BnParseHex1024(uint32_t* n, const char* p); |
| andrewboyson | 60:b4f337685ec4 | 45 | extern void BnAsHttp1024 (uint32_t* n); |
| andrewboyson | 60:b4f337685ec4 | 46 | |
| andrewboyson | 60:b4f337685ec4 | 47 | // Arithmetic operations |
| andrewboyson | 60:b4f337685ec4 | 48 | extern void Bn1024Mul2048(uint32_t* a1024, uint32_t* b1024, uint32_t* r2048); |
| andrewboyson | 60:b4f337685ec4 | 49 | extern void BnRem1024(int numSize, uint32_t* n, uint32_t* d1024, uint32_t* r1024); |
| andrewboyson | 60:b4f337685ec4 | 50 | |
| andrewboyson | 61:d4fc276a824e | 51 | extern void Bn512Mul1024(uint32_t* a512, uint32_t* b512, uint32_t* r1024); |
| andrewboyson | 61:d4fc276a824e | 52 | extern void BnRem512(int numSize, uint32_t* n, uint32_t* d512, uint32_t* r512); |
| andrewboyson | 61:d4fc276a824e | 53 | |
| andrewboyson | 60:b4f337685ec4 | 54 | //Asynchronous operations |
| andrewboyson | 61:d4fc276a824e | 55 | extern void BnModExpStart1024 (uint32_t m[32], uint32_t e[32], uint32_t n[32], uint32_t r[32], int messageSize, uint32_t* message, uint32_t* exponent, uint32_t* modulus); |
| andrewboyson | 60:b4f337685ec4 | 56 | extern bool BnModExpIterate1024(uint32_t m[32], uint32_t e[32], uint32_t n[32], uint32_t r[32]); //Returns true if finished |
| andrewboyson | 61:d4fc276a824e | 57 | extern void BnModExpStart512 (uint32_t m[16], uint32_t e[16], uint32_t n[16], uint32_t r[16], int messageSize, uint32_t* message, uint32_t* exponent, uint32_t* modulus); |
| andrewboyson | 61:d4fc276a824e | 58 | extern bool BnModExpIterate512 (uint32_t m[16], uint32_t e[16], uint32_t n[16], uint32_t r[16]); //Returns true if finished |
| andrewboyson | 60:b4f337685ec4 | 59 |