monotone

monotone Mtn Source Tree

Root/botan/mp_madd.h

1/*************************************************
2* MPI Multiply-Add Core Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_MP_MADD_H__
7#define BOTAN_MP_MADD_H__
8
9#include <botan/mp_core.h>
10
11namespace Botan {
12
13/*************************************************
14* Multiply-Add Operation *
15*************************************************/
16inline void bigint_madd(word a, word b, word c, word d,
17 word* out_low, word* out_high)
18 {
19#if (BOTAN_MP_WORD_BITS == 8)
20 typedef Botan::u16bit dword;
21#elif (BOTAN_MP_WORD_BITS == 16)
22 typedef Botan::u32bit dword;
23#elif (BOTAN_MP_WORD_BITS == 32)
24 typedef Botan::u64bit dword;
25#elif (BOTAN_MP_WORD_BITS == 64)
26 #error BOTAN_MP_WORD_BITS can only be 64 with the mp_asm64 module
27#else
28 #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64
29#endif
30
31 dword z = (dword)a * b + c + d;
32 *out_low = (word)((z ) & MP_WORD_MAX);
33 *out_high = (word)((z >> BOTAN_MP_WORD_BITS) & MP_WORD_MAX);
34 }
35
36}
37
38#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status