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@55:975f706c67d2, 2019-06-21 (annotated)
- Committer:
- andrewboyson
- Date:
- Fri Jun 21 14:27:57 2019 +0000
- Revision:
- 55:975f706c67d2
- Parent:
- 54:9b3b189bc82c
Updated big number library to use a more understandable division algorithm. Put more routines into assembler. Net result is an improvement of speed from 4 minutes to about 20 seconds.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 52:88d594aca377 | 1 | #include <stdint.h> |
| andrewboyson | 52:88d594aca377 | 2 | #include <stdbool.h> |
| andrewboyson | 52:88d594aca377 | 3 | |
| andrewboyson | 52:88d594aca377 | 4 | //Assembly instructions |
| andrewboyson | 53:3888bf121010 | 5 | extern void BnZer2048(uint32_t* acc); |
| andrewboyson | 53:3888bf121010 | 6 | extern void BnInc2048(uint32_t* acc); |
| andrewboyson | 55:975f706c67d2 | 7 | extern bool BnShr2048(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 55:975f706c67d2 | 8 | extern bool BnShl2048(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 53:3888bf121010 | 9 | extern void BnCpy2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 53:3888bf121010 | 10 | extern void BnOrr2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 53:3888bf121010 | 11 | extern void BnAdd2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 53:3888bf121010 | 12 | extern void BnSub2048(uint32_t* acc, uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 13 | extern bool BnIse2048 (uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 14 | extern bool BnIne2048 (uint32_t* value); |
| andrewboyson | 53:3888bf121010 | 15 | extern int BnCmp2048(uint32_t* lhs, uint32_t* rhs); |
| andrewboyson | 52:88d594aca377 | 16 | |
| andrewboyson | 55:975f706c67d2 | 17 | extern void BnZer1024(uint32_t* acc); |
| andrewboyson | 55:975f706c67d2 | 18 | extern void BnInc1024(uint32_t* acc); |
| andrewboyson | 55:975f706c67d2 | 19 | extern bool BnShr1024(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 55:975f706c67d2 | 20 | extern bool BnShl1024(uint32_t* acc, bool bitIn); //Returns bit shifted out |
| andrewboyson | 55:975f706c67d2 | 21 | extern void BnCpy1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 22 | extern void BnOrr1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 23 | extern void BnAdd1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 24 | extern void BnSub1024(uint32_t* acc, uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 25 | extern bool BnIse1024 (uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 26 | extern bool BnIne1024 (uint32_t* value); |
| andrewboyson | 55:975f706c67d2 | 27 | extern int BnCmp1024(uint32_t* lhs, uint32_t* rhs); |
| andrewboyson | 55:975f706c67d2 | 28 | |
| andrewboyson | 53:3888bf121010 | 29 | // Text functions |
| andrewboyson | 55:975f706c67d2 | 30 | extern void BnParseHex2048(uint32_t* n, const char* p); |
| andrewboyson | 55:975f706c67d2 | 31 | extern void BnAsHttp2048 (uint32_t* n); |
| andrewboyson | 55:975f706c67d2 | 32 | extern void BnParseHex1024(uint32_t* n, const char* p); |
| andrewboyson | 55:975f706c67d2 | 33 | extern void BnAsHttp1024 (uint32_t* n); |
| andrewboyson | 52:88d594aca377 | 34 | |
| andrewboyson | 52:88d594aca377 | 35 | // Arithmetic operations |
| andrewboyson | 55:975f706c67d2 | 36 | extern void Bn1024Mul2048(uint32_t* a1024, uint32_t* b1024, uint32_t* r2048); |
| andrewboyson | 55:975f706c67d2 | 37 | extern void BnRem1024(int numSize, uint32_t* n, uint32_t* d1024, uint32_t* r1024); |
| andrewboyson | 52:88d594aca377 | 38 | |
| andrewboyson | 52:88d594aca377 | 39 | // Asynchronous operations |
| andrewboyson | 52:88d594aca377 | 40 | #define BIGNUM_CALC_NONE 0 |
| andrewboyson | 52:88d594aca377 | 41 | #define BIGNUM_CALC_STARTED 1 |
| andrewboyson | 52:88d594aca377 | 42 | #define BIGNUM_CALC_FINISHED 2 |
| andrewboyson | 52:88d594aca377 | 43 | extern void BnAsyncMain(void); |
| andrewboyson | 52:88d594aca377 | 44 | |
| andrewboyson | 54:9b3b189bc82c | 45 | extern int BnExpModStatus; |
| andrewboyson | 54:9b3b189bc82c | 46 | extern int BnExpModProgress; |
| andrewboyson | 54:9b3b189bc82c | 47 | extern uint64_t BnMulHr; |
| andrewboyson | 54:9b3b189bc82c | 48 | extern uint64_t BnModHr; |
| andrewboyson | 54:9b3b189bc82c | 49 | extern void BnExpModStart(uint32_t* message, uint32_t* exponent, uint32_t* modulus, uint32_t* result); |
| andrewboyson | 52:88d594aca377 | 50 | |
| andrewboyson | 52:88d594aca377 | 51 |