change some parameters in the library to meet the needs of the website httpbin.org
Fork of MiniTLS-GPL by
math/sqr/fp_sqr.c@5:95f70ebfe61f, 2015-02-06 (annotated)
- Committer:
- shiyilei
- Date:
- Fri Feb 06 06:17:33 2015 +0000
- Revision:
- 5:95f70ebfe61f
- Parent:
- 0:35aa5be3b78d
change some parameters in the library to meet the needs of httpbin.org
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MiniTLS | 0:35aa5be3b78d | 1 | /* TomsFastMath, a fast ISO C bignum library. |
MiniTLS | 0:35aa5be3b78d | 2 | * |
MiniTLS | 0:35aa5be3b78d | 3 | * This project is meant to fill in where LibTomMath |
MiniTLS | 0:35aa5be3b78d | 4 | * falls short. That is speed ;-) |
MiniTLS | 0:35aa5be3b78d | 5 | * |
MiniTLS | 0:35aa5be3b78d | 6 | * This project is public domain and free for all purposes. |
MiniTLS | 0:35aa5be3b78d | 7 | * |
MiniTLS | 0:35aa5be3b78d | 8 | * Tom St Denis, tomstdenis@gmail.com |
MiniTLS | 0:35aa5be3b78d | 9 | */ |
MiniTLS | 0:35aa5be3b78d | 10 | #include <tfm.h> |
MiniTLS | 0:35aa5be3b78d | 11 | |
MiniTLS | 0:35aa5be3b78d | 12 | /* b = a*a */ |
MiniTLS | 0:35aa5be3b78d | 13 | void fp_sqr(fp_int *A, fp_int *B) |
MiniTLS | 0:35aa5be3b78d | 14 | { |
MiniTLS | 0:35aa5be3b78d | 15 | int y; |
MiniTLS | 0:35aa5be3b78d | 16 | |
MiniTLS | 0:35aa5be3b78d | 17 | /* call generic if we're out of range */ |
MiniTLS | 0:35aa5be3b78d | 18 | if (A->used + A->used > FP_SIZE) { |
MiniTLS | 0:35aa5be3b78d | 19 | fp_sqr_comba(A, B); |
MiniTLS | 0:35aa5be3b78d | 20 | return ; |
MiniTLS | 0:35aa5be3b78d | 21 | } |
MiniTLS | 0:35aa5be3b78d | 22 | |
MiniTLS | 0:35aa5be3b78d | 23 | y = A->used; |
MiniTLS | 0:35aa5be3b78d | 24 | #if defined(TFM_SQR3) |
MiniTLS | 0:35aa5be3b78d | 25 | if (y <= 3) { |
MiniTLS | 0:35aa5be3b78d | 26 | fp_sqr_comba3(A,B); |
MiniTLS | 0:35aa5be3b78d | 27 | return; |
MiniTLS | 0:35aa5be3b78d | 28 | } |
MiniTLS | 0:35aa5be3b78d | 29 | #endif |
MiniTLS | 0:35aa5be3b78d | 30 | #if defined(TFM_SQR4) |
MiniTLS | 0:35aa5be3b78d | 31 | if (y == 4) { |
MiniTLS | 0:35aa5be3b78d | 32 | fp_sqr_comba4(A,B); |
MiniTLS | 0:35aa5be3b78d | 33 | return; |
MiniTLS | 0:35aa5be3b78d | 34 | } |
MiniTLS | 0:35aa5be3b78d | 35 | #endif |
MiniTLS | 0:35aa5be3b78d | 36 | #if defined(TFM_SQR6) |
MiniTLS | 0:35aa5be3b78d | 37 | if (y <= 6) { |
MiniTLS | 0:35aa5be3b78d | 38 | fp_sqr_comba6(A,B); |
MiniTLS | 0:35aa5be3b78d | 39 | return; |
MiniTLS | 0:35aa5be3b78d | 40 | } |
MiniTLS | 0:35aa5be3b78d | 41 | #endif |
MiniTLS | 0:35aa5be3b78d | 42 | #if defined(TFM_SQR7) |
MiniTLS | 0:35aa5be3b78d | 43 | if (y == 7) { |
MiniTLS | 0:35aa5be3b78d | 44 | fp_sqr_comba7(A,B); |
MiniTLS | 0:35aa5be3b78d | 45 | return; |
MiniTLS | 0:35aa5be3b78d | 46 | } |
MiniTLS | 0:35aa5be3b78d | 47 | #endif |
MiniTLS | 0:35aa5be3b78d | 48 | #if defined(TFM_SQR8) |
MiniTLS | 0:35aa5be3b78d | 49 | if (y == 8) { |
MiniTLS | 0:35aa5be3b78d | 50 | fp_sqr_comba8(A,B); |
MiniTLS | 0:35aa5be3b78d | 51 | return; |
MiniTLS | 0:35aa5be3b78d | 52 | } |
MiniTLS | 0:35aa5be3b78d | 53 | #endif |
MiniTLS | 0:35aa5be3b78d | 54 | #if defined(TFM_SQR9) |
MiniTLS | 0:35aa5be3b78d | 55 | if (y == 9) { |
MiniTLS | 0:35aa5be3b78d | 56 | fp_sqr_comba9(A,B); |
MiniTLS | 0:35aa5be3b78d | 57 | return; |
MiniTLS | 0:35aa5be3b78d | 58 | } |
MiniTLS | 0:35aa5be3b78d | 59 | #endif |
MiniTLS | 0:35aa5be3b78d | 60 | #if defined(TFM_SQR12) |
MiniTLS | 0:35aa5be3b78d | 61 | if (y <= 12) { |
MiniTLS | 0:35aa5be3b78d | 62 | fp_sqr_comba12(A,B); |
MiniTLS | 0:35aa5be3b78d | 63 | return; |
MiniTLS | 0:35aa5be3b78d | 64 | } |
MiniTLS | 0:35aa5be3b78d | 65 | #endif |
MiniTLS | 0:35aa5be3b78d | 66 | #if defined(TFM_SQR17) |
MiniTLS | 0:35aa5be3b78d | 67 | if (y <= 17) { |
MiniTLS | 0:35aa5be3b78d | 68 | fp_sqr_comba17(A,B); |
MiniTLS | 0:35aa5be3b78d | 69 | return; |
MiniTLS | 0:35aa5be3b78d | 70 | } |
MiniTLS | 0:35aa5be3b78d | 71 | #endif |
MiniTLS | 0:35aa5be3b78d | 72 | #if defined(TFM_SMALL_SET) |
MiniTLS | 0:35aa5be3b78d | 73 | if (y <= 16) { |
MiniTLS | 0:35aa5be3b78d | 74 | fp_sqr_comba_small(A,B); |
MiniTLS | 0:35aa5be3b78d | 75 | return; |
MiniTLS | 0:35aa5be3b78d | 76 | } |
MiniTLS | 0:35aa5be3b78d | 77 | #endif |
MiniTLS | 0:35aa5be3b78d | 78 | #if defined(TFM_SQR20) |
MiniTLS | 0:35aa5be3b78d | 79 | if (y <= 20) { |
MiniTLS | 0:35aa5be3b78d | 80 | fp_sqr_comba20(A,B); |
MiniTLS | 0:35aa5be3b78d | 81 | return; |
MiniTLS | 0:35aa5be3b78d | 82 | } |
MiniTLS | 0:35aa5be3b78d | 83 | #endif |
MiniTLS | 0:35aa5be3b78d | 84 | #if defined(TFM_SQR24) |
MiniTLS | 0:35aa5be3b78d | 85 | if (y <= 24) { |
MiniTLS | 0:35aa5be3b78d | 86 | fp_sqr_comba24(A,B); |
MiniTLS | 0:35aa5be3b78d | 87 | return; |
MiniTLS | 0:35aa5be3b78d | 88 | } |
MiniTLS | 0:35aa5be3b78d | 89 | #endif |
MiniTLS | 0:35aa5be3b78d | 90 | #if defined(TFM_SQR28) |
MiniTLS | 0:35aa5be3b78d | 91 | if (y <= 28) { |
MiniTLS | 0:35aa5be3b78d | 92 | fp_sqr_comba28(A,B); |
MiniTLS | 0:35aa5be3b78d | 93 | return; |
MiniTLS | 0:35aa5be3b78d | 94 | } |
MiniTLS | 0:35aa5be3b78d | 95 | #endif |
MiniTLS | 0:35aa5be3b78d | 96 | #if defined(TFM_SQR32) |
MiniTLS | 0:35aa5be3b78d | 97 | if (y <= 32) { |
MiniTLS | 0:35aa5be3b78d | 98 | fp_sqr_comba32(A,B); |
MiniTLS | 0:35aa5be3b78d | 99 | return; |
MiniTLS | 0:35aa5be3b78d | 100 | } |
MiniTLS | 0:35aa5be3b78d | 101 | #endif |
MiniTLS | 0:35aa5be3b78d | 102 | #if defined(TFM_SQR48) |
MiniTLS | 0:35aa5be3b78d | 103 | if (y <= 48) { |
MiniTLS | 0:35aa5be3b78d | 104 | fp_sqr_comba48(A,B); |
MiniTLS | 0:35aa5be3b78d | 105 | return; |
MiniTLS | 0:35aa5be3b78d | 106 | } |
MiniTLS | 0:35aa5be3b78d | 107 | #endif |
MiniTLS | 0:35aa5be3b78d | 108 | #if defined(TFM_SQR64) |
MiniTLS | 0:35aa5be3b78d | 109 | if (y <= 64) { |
MiniTLS | 0:35aa5be3b78d | 110 | fp_sqr_comba64(A,B); |
MiniTLS | 0:35aa5be3b78d | 111 | return; |
MiniTLS | 0:35aa5be3b78d | 112 | } |
MiniTLS | 0:35aa5be3b78d | 113 | #endif |
MiniTLS | 0:35aa5be3b78d | 114 | fp_sqr_comba(A, B); |
MiniTLS | 0:35aa5be3b78d | 115 | } |
MiniTLS | 0:35aa5be3b78d | 116 | |
MiniTLS | 0:35aa5be3b78d | 117 | |
MiniTLS | 0:35aa5be3b78d | 118 | /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr.c,v $ */ |
MiniTLS | 0:35aa5be3b78d | 119 | /* $Revision: 1.1 $ */ |
MiniTLS | 0:35aa5be3b78d | 120 | /* $Date: 2006/12/31 21:25:53 $ */ |