aboutsummaryrefslogtreecommitdiffstats
path: root/src/mp_misc.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 22:40:27 +0000
committerlloyd <[email protected]>2008-09-28 22:40:27 +0000
commitc32a8e6c7ecf97fc9423e6a967ce3d98b0689404 (patch)
treed9d41c74dd0f99f43119ae355f461fae1f3bf32c /src/mp_misc.cpp
parent31204986023619c385d378e79a6511bb81ef7b78 (diff)
Move all BigInt stuff into bigint/. Currently all asm modules are disabled;
configure.pl doesn't understand how to handle this yet (replace logic only understands stuff in src, not how one module can replace another modules src, or anything about prioritizing). Move some hex and base64 stuff out of charset.cpp and into their codec directories.
Diffstat (limited to 'src/mp_misc.cpp')
-rw-r--r--src/mp_misc.cpp92
1 files changed, 0 insertions, 92 deletions
diff --git a/src/mp_misc.cpp b/src/mp_misc.cpp
deleted file mode 100644
index db9c8cda0..000000000
--- a/src/mp_misc.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*************************************************
-* MP Misc Functions Source File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
-
-#include <botan/mp_core.h>
-#include <botan/mp_asm.h>
-
-namespace Botan {
-
-extern "C" {
-
-/*************************************************
-* Core Division Operation *
-*************************************************/
-u32bit bigint_divcore(word q, word y1, word y2,
- word x1, word x2, word x3)
- {
- word y0 = 0;
- y2 = word_madd2(q, y2, &y0);
- y1 = word_madd2(q, y1, &y0);
-
- if(y0 > x1) return 1;
- if(y0 < x1) return 0;
- if(y1 > x2) return 1;
- if(y1 < x2) return 0;
- if(y2 > x3) return 1;
- if(y2 < x3) return 0;
- return 0;
- }
-
-/*************************************************
-* Compare two MP integers *
-*************************************************/
-s32bit bigint_cmp(const word x[], u32bit x_size,
- const word y[], u32bit y_size)
- {
- if(x_size < y_size) { return (-bigint_cmp(y, y_size, x, x_size)); }
-
- while(x_size > y_size)
- {
- if(x[x_size-1])
- return 1;
- x_size--;
- }
- for(u32bit j = x_size; j > 0; --j)
- {
- if(x[j-1] > y[j-1]) return 1;
- if(x[j-1] < y[j-1]) return -1;
- }
- return 0;
- }
-
-/*************************************************
-* Do a 2-word/1-word Division *
-*************************************************/
-word bigint_divop(word n1, word n0, word d)
- {
- word high = n1 % d, quotient = 0;
-
- for(u32bit j = 0; j != MP_WORD_BITS; ++j)
- {
- word high_top_bit = (high & MP_WORD_TOP_BIT);
-
- high <<= 1;
- high |= (n0 >> (MP_WORD_BITS-1-j)) & 1;
- quotient <<= 1;
-
- if(high_top_bit || high >= d)
- {
- high -= d;
- quotient |= 1;
- }
- }
-
- return quotient;
- }
-
-/*************************************************
-* Do a 2-word/1-word Modulo *
-*************************************************/
-word bigint_modop(word n1, word n0, word d)
- {
- word z = bigint_divop(n1, n0, d);
- word dummy = 0;
- z = word_madd2(z, d, &dummy);
- return (n0-z);
- }
-
-}
-
-}