security/nss/lib/freebl/mpi/mp_gf2m-priv.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef _MP_GF2M_PRIV_H_
michael@0 6 #define _MP_GF2M_PRIV_H_
michael@0 7
michael@0 8 #include "mpi-priv.h"
michael@0 9
michael@0 10 extern const mp_digit mp_gf2m_sqr_tb[16];
michael@0 11
michael@0 12 #if defined(MP_USE_UINT_DIGIT)
michael@0 13 #define MP_DIGIT_BITS 32
michael@0 14 /* enable fast divide and mod operations on MP_DIGIT_BITS */
michael@0 15 #define MP_DIGIT_BITS_LOG_2 5
michael@0 16 #define MP_DIGIT_BITS_MASK 0x1f
michael@0 17 #else
michael@0 18 #define MP_DIGIT_BITS 64
michael@0 19 /* enable fast divide and mod operations on MP_DIGIT_BITS */
michael@0 20 #define MP_DIGIT_BITS_LOG_2 6
michael@0 21 #define MP_DIGIT_BITS_MASK 0x3f
michael@0 22 #endif
michael@0 23
michael@0 24 /* Platform-specific macros for fast binary polynomial squaring. */
michael@0 25 #if MP_DIGIT_BITS == 32
michael@0 26 #define gf2m_SQR1(w) \
michael@0 27 mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 16 | \
michael@0 28 mp_gf2m_sqr_tb[(w) >> 20 & 0xF] << 8 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF]
michael@0 29 #define gf2m_SQR0(w) \
michael@0 30 mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 8 & 0xF] << 16 | \
michael@0 31 mp_gf2m_sqr_tb[(w) >> 4 & 0xF] << 8 | mp_gf2m_sqr_tb[(w) & 0xF]
michael@0 32 #else
michael@0 33 #define gf2m_SQR1(w) \
michael@0 34 mp_gf2m_sqr_tb[(w) >> 60 & 0xF] << 56 | mp_gf2m_sqr_tb[(w) >> 56 & 0xF] << 48 | \
michael@0 35 mp_gf2m_sqr_tb[(w) >> 52 & 0xF] << 40 | mp_gf2m_sqr_tb[(w) >> 48 & 0xF] << 32 | \
michael@0 36 mp_gf2m_sqr_tb[(w) >> 44 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 40 & 0xF] << 16 | \
michael@0 37 mp_gf2m_sqr_tb[(w) >> 36 & 0xF] << 8 | mp_gf2m_sqr_tb[(w) >> 32 & 0xF]
michael@0 38 #define gf2m_SQR0(w) \
michael@0 39 mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 56 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 48 | \
michael@0 40 mp_gf2m_sqr_tb[(w) >> 20 & 0xF] << 40 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF] << 32 | \
michael@0 41 mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 8 & 0xF] << 16 | \
michael@0 42 mp_gf2m_sqr_tb[(w) >> 4 & 0xF] << 8 | mp_gf2m_sqr_tb[(w) & 0xF]
michael@0 43 #endif
michael@0 44
michael@0 45 /* Multiply two binary polynomials mp_digits a, b.
michael@0 46 * Result is a polynomial with degree < 2 * MP_DIGIT_BITS - 1.
michael@0 47 * Output in two mp_digits rh, rl.
michael@0 48 */
michael@0 49 void s_bmul_1x1(mp_digit *rh, mp_digit *rl, const mp_digit a, const mp_digit b);
michael@0 50
michael@0 51 /* Compute xor-multiply of two binary polynomials (a1, a0) x (b1, b0)
michael@0 52 * result is a binary polynomial in 4 mp_digits r[4].
michael@0 53 * The caller MUST ensure that r has the right amount of space allocated.
michael@0 54 */
michael@0 55 void s_bmul_2x2(mp_digit *r, const mp_digit a1, const mp_digit a0, const mp_digit b1,
michael@0 56 const mp_digit b0);
michael@0 57
michael@0 58 /* Compute xor-multiply of two binary polynomials (a2, a1, a0) x (b2, b1, b0)
michael@0 59 * result is a binary polynomial in 6 mp_digits r[6].
michael@0 60 * The caller MUST ensure that r has the right amount of space allocated.
michael@0 61 */
michael@0 62 void s_bmul_3x3(mp_digit *r, const mp_digit a2, const mp_digit a1, const mp_digit a0,
michael@0 63 const mp_digit b2, const mp_digit b1, const mp_digit b0);
michael@0 64
michael@0 65 /* Compute xor-multiply of two binary polynomials (a3, a2, a1, a0) x (b3, b2, b1, b0)
michael@0 66 * result is a binary polynomial in 8 mp_digits r[8].
michael@0 67 * The caller MUST ensure that r has the right amount of space allocated.
michael@0 68 */
michael@0 69 void s_bmul_4x4(mp_digit *r, const mp_digit a3, const mp_digit a2, const mp_digit a1,
michael@0 70 const mp_digit a0, const mp_digit b3, const mp_digit b2, const mp_digit b1,
michael@0 71 const mp_digit b0);
michael@0 72
michael@0 73 #endif /* _MP_GF2M_PRIV_H_ */

mercurial