| 1 | /* |
| 2 | Copyright (C) 1999-2007 The Botan Project. All rights reserved. |
| 3 | |
| 4 | Redistribution and use in source and binary forms, for any use, with or without |
| 5 | modification, is permitted provided that the following conditions are met: |
| 6 | |
| 7 | 1. Redistributions of source code must retain the above copyright notice, this |
| 8 | list of conditions, and the following disclaimer. |
| 9 | |
| 10 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | this list of conditions, and the following disclaimer in the documentation |
| 12 | and/or other materials provided with the distribution. |
| 13 | |
| 14 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED |
| 15 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. |
| 17 | |
| 18 | IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT, |
| 19 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 20 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 23 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 24 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | // LICENSEHEADER_END |
| 27 | namespace QCA { // WRAPNS_LINE |
| 28 | /************************************************* |
| 29 | * MPI Algorithms Header File * |
| 30 | * (C) 1999-2007 The Botan Project * |
| 31 | *************************************************/ |
| 32 | |
| 33 | #ifndef BOTAN_MP_CORE_H__ |
| 34 | #define BOTAN_MP_CORE_H__ |
| 35 | |
| 36 | } // WRAPNS_LINE |
| 37 | #include <botan/mp_types.h> |
| 38 | namespace QCA { // WRAPNS_LINE |
| 39 | |
| 40 | namespace Botan { |
| 41 | |
| 42 | /************************************************* |
| 43 | * The size of the word type, in bits * |
| 44 | *************************************************/ |
| 45 | const u32bit MP_WORD_BITS = BOTAN_MP_WORD_BITS; |
| 46 | |
| 47 | extern "C" { |
| 48 | |
| 49 | /************************************************* |
| 50 | * Addition/Subtraction Operations * |
| 51 | *************************************************/ |
| 52 | void bigint_add2(word[], u32bit, const word[], u32bit); |
| 53 | void bigint_add3(word[], const word[], u32bit, const word[], u32bit); |
| 54 | |
| 55 | word bigint_add2_nc(word[], u32bit, const word[], u32bit); |
| 56 | word bigint_add3_nc(word[], const word[], u32bit, const word[], u32bit); |
| 57 | |
| 58 | void bigint_sub2(word[], u32bit, const word[], u32bit); |
| 59 | void bigint_sub3(word[], const word[], u32bit, const word[], u32bit); |
| 60 | |
| 61 | /************************************************* |
| 62 | * Shift Operations * |
| 63 | *************************************************/ |
| 64 | void bigint_shl1(word[], u32bit, u32bit, u32bit); |
| 65 | void bigint_shl2(word[], const word[], u32bit, u32bit, u32bit); |
| 66 | void bigint_shr1(word[], u32bit, u32bit, u32bit); |
| 67 | void bigint_shr2(word[], const word[], u32bit, u32bit, u32bit); |
| 68 | |
| 69 | /************************************************* |
| 70 | * Multiplication and Squaring Operations * |
| 71 | *************************************************/ |
| 72 | word bigint_mul_add_words(word[], const word[], u32bit, word); |
| 73 | |
| 74 | void bigint_linmul2(word[], u32bit, word); |
| 75 | void bigint_linmul3(word[], const word[], u32bit, word); |
| 76 | void bigint_linmul_add(word[], u32bit, const word[], u32bit, word); |
| 77 | |
| 78 | /************************************************* |
| 79 | * Montgomery Reduction * |
| 80 | *************************************************/ |
| 81 | void bigint_monty_redc(word[], u32bit, const word[], u32bit, word); |
| 82 | |
| 83 | /************************************************* |
| 84 | * Misc Utility Operations * |
| 85 | *************************************************/ |
| 86 | u32bit bigint_divcore(word, word, word, word, word, word); |
| 87 | s32bit bigint_cmp(const word[], u32bit, const word[], u32bit); |
| 88 | word bigint_divop(word, word, word); |
| 89 | word bigint_modop(word, word, word); |
| 90 | void bigint_wordmul(word, word, word *, word *); |
| 91 | |
| 92 | /************************************************* |
| 93 | * Comba Multiplication / Squaring * |
| 94 | *************************************************/ |
| 95 | void bigint_comba_mul4(word[8], const word[4], const word[4]); |
| 96 | void bigint_comba_mul6(word[12], const word[6], const word[6]); |
| 97 | void bigint_comba_mul8(word[16], const word[8], const word[8]); |
| 98 | |
| 99 | void bigint_comba_sqr4(word[8], const word[4]); |
| 100 | void bigint_comba_sqr6(word[12], const word[6]); |
| 101 | void bigint_comba_sqr8(word[16], const word[8]); |
| 102 | } |
| 103 | |
| 104 | /************************************************* |
| 105 | * High Level Multiplication/Squaring Interfaces * |
| 106 | *************************************************/ |
| 107 | void bigint_mul(word[], u32bit, word[], const word[], u32bit, u32bit, const word[], u32bit, u32bit); |
| 108 | |
| 109 | void bigint_sqr(word[], u32bit, word[], const word[], u32bit, u32bit); |
| 110 | |
| 111 | } |
| 112 | |
| 113 | #endif |
| 114 | } // WRAPNS_LINE |
| 115 | |