4#ifndef __GSLARGEINT_H__
5#define __GSLARGEINT_H__
12#if defined(__cplusplus)
21#ifndef GS_LARGEINT_BINARY_SIZE
22#define GS_LARGEINT_BINARY_SIZE (2048)
26#define GS_LARGEINT_DIGIT_TYPE gsi_u32
27#define GS_LARGEINT_DIGIT_LONG_TYPE gsi_u64
29#define GS_LARGEINT_DIGIT_SIZE_BYTES (sizeof(GS_LARGEINT_DIGIT_TYPE))
30#define GS_LARGEINT_DIGIT_SIZE_BITS (GS_LARGEINT_DIGIT_SIZE_BYTES*8)
33#define l_word GS_LARGEINT_DIGIT_TYPE
34#define l_dword GS_LARGEINT_DIGIT_LONG_TYPE
38#define GS_LARGEINT_MAX_DIGITS (GS_LARGEINT_BINARY_SIZE / GS_LARGEINT_DIGIT_SIZE_BITS)
40#define GS_LARGEINT_KARATSUBA_CUTOFF 32
44 GS_LARGEINT_DIGIT_TYPE mLength;
45 GS_LARGEINT_DIGIT_TYPE mData[GS_LARGEINT_MAX_DIGITS];
52void gsLargeIntAddToMD5(
const gsLargeInt_t * lint,
MD5_CTX * md5);
53gsi_bool gsLargeIntSetFromHexString(gsLargeInt_t *lint,
const char* hexstring);
54gsi_bool gsLargeIntPrint (FILE* logFile,
const gsLargeInt_t *lint);
55gsi_u32 gsLargeIntGetByteLength(
const gsLargeInt_t *lint);
59gsi_bool gsLargeIntPowerMod(
const gsLargeInt_t *base,
const gsLargeInt_t *power,
const gsLargeInt_t *mod, gsLargeInt_t *dest);
64gsi_bool gsLargeIntSquareMod(
const gsLargeInt_t *lint,
const gsLargeInt_t *mod, gsLargeInt_t *dest);
65gsi_bool gsLargeIntAdd (
const gsLargeInt_t *src1,
const gsLargeInt_t *src2, gsLargeInt_t *dest);
66gsi_bool gsLargeIntSub (
const gsLargeInt_t *src1,
const gsLargeInt_t *fromsrc2, gsLargeInt_t *dest);
67gsi_bool gsLargeIntMult (
const gsLargeInt_t *src1,
const gsLargeInt_t *src2, gsLargeInt_t *dest);
68gsi_bool gsLargeIntDiv (
const gsLargeInt_t *src1,
const gsLargeInt_t *divisor, gsLargeInt_t *dest, gsLargeInt_t *remainder);
71gsi_bool gsLargeIntKMult(
const gsLargeInt_t *src1,
const gsLargeInt_t *src2, gsLargeInt_t *dest);
74gsi_bool gsLargeIntReverseBytes(gsLargeInt_t *lint);
75gsi_bool gsLargeIntSetValue(gsLargeInt_t *lint, l_word value);
78gsi_bool gsLargeIntSetFromMemoryStream(gsLargeInt_t *lint,
const gsi_u8* data, gsi_u32 len);
79gsi_bool gsLargeIntWriteToMemoryStream(
const gsLargeInt_t *lint, gsi_u8* data);
84#if defined(__cplusplus)
Definition gsLargeInt.h:43