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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/mpi/mp_gf2m-priv.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef _MP_GF2M_PRIV_H_
     1.9 +#define _MP_GF2M_PRIV_H_
    1.10 +
    1.11 +#include "mpi-priv.h"
    1.12 +
    1.13 +extern const mp_digit mp_gf2m_sqr_tb[16];
    1.14 +
    1.15 +#if defined(MP_USE_UINT_DIGIT)
    1.16 +#define MP_DIGIT_BITS 32
    1.17 +/* enable fast divide and mod operations on MP_DIGIT_BITS */
    1.18 +#define MP_DIGIT_BITS_LOG_2 5
    1.19 +#define MP_DIGIT_BITS_MASK 0x1f
    1.20 +#else
    1.21 +#define MP_DIGIT_BITS 64
    1.22 +/* enable fast divide and mod operations on MP_DIGIT_BITS */
    1.23 +#define MP_DIGIT_BITS_LOG_2 6
    1.24 +#define MP_DIGIT_BITS_MASK 0x3f
    1.25 +#endif
    1.26 +
    1.27 +/* Platform-specific macros for fast binary polynomial squaring. */
    1.28 +#if MP_DIGIT_BITS == 32
    1.29 +#define gf2m_SQR1(w) \
    1.30 +    mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 16 | \
    1.31 +    mp_gf2m_sqr_tb[(w) >> 20 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF]
    1.32 +#define gf2m_SQR0(w) \
    1.33 +    mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >>  8 & 0xF] << 16 | \
    1.34 +    mp_gf2m_sqr_tb[(w) >>  4 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w)       & 0xF]
    1.35 +#else
    1.36 +#define gf2m_SQR1(w) \
    1.37 +    mp_gf2m_sqr_tb[(w) >> 60 & 0xF] << 56 | mp_gf2m_sqr_tb[(w) >> 56 & 0xF] << 48 | \
    1.38 +    mp_gf2m_sqr_tb[(w) >> 52 & 0xF] << 40 | mp_gf2m_sqr_tb[(w) >> 48 & 0xF] << 32 | \
    1.39 +    mp_gf2m_sqr_tb[(w) >> 44 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 40 & 0xF] << 16 | \
    1.40 +    mp_gf2m_sqr_tb[(w) >> 36 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w) >> 32 & 0xF]
    1.41 +#define gf2m_SQR0(w) \
    1.42 +    mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 56 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 48 | \
    1.43 +    mp_gf2m_sqr_tb[(w) >> 20 & 0xF] << 40 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF] << 32 | \
    1.44 +    mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >>  8 & 0xF] << 16 | \
    1.45 +    mp_gf2m_sqr_tb[(w) >>  4 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w)       & 0xF]
    1.46 +#endif
    1.47 +
    1.48 +/* Multiply two binary polynomials mp_digits a, b.
    1.49 + * Result is a polynomial with degree < 2 * MP_DIGIT_BITS - 1.
    1.50 + * Output in two mp_digits rh, rl.
    1.51 + */
    1.52 +void s_bmul_1x1(mp_digit *rh, mp_digit *rl, const mp_digit a, const mp_digit b);
    1.53 +
    1.54 +/* Compute xor-multiply of two binary polynomials  (a1, a0) x (b1, b0)  
    1.55 + * result is a binary polynomial in 4 mp_digits r[4].
    1.56 + * The caller MUST ensure that r has the right amount of space allocated.
    1.57 + */
    1.58 +void s_bmul_2x2(mp_digit *r, const mp_digit a1, const mp_digit a0, const mp_digit b1,
    1.59 +	const mp_digit b0);
    1.60 +
    1.61 +/* Compute xor-multiply of two binary polynomials  (a2, a1, a0) x (b2, b1, b0)  
    1.62 + * result is a binary polynomial in 6 mp_digits r[6].
    1.63 + * The caller MUST ensure that r has the right amount of space allocated.
    1.64 + */
    1.65 +void s_bmul_3x3(mp_digit *r, const mp_digit a2, const mp_digit a1, const mp_digit a0, 
    1.66 +	const mp_digit b2, const mp_digit b1, const mp_digit b0);
    1.67 +
    1.68 +/* Compute xor-multiply of two binary polynomials  (a3, a2, a1, a0) x (b3, b2, b1, b0)  
    1.69 + * result is a binary polynomial in 8 mp_digits r[8].
    1.70 + * The caller MUST ensure that r has the right amount of space allocated.
    1.71 + */
    1.72 +void s_bmul_4x4(mp_digit *r, const mp_digit a3, const mp_digit a2, const mp_digit a1, 
    1.73 +	const mp_digit a0, const mp_digit b3, const mp_digit b2, const mp_digit b1, 
    1.74 +	const mp_digit b0);
    1.75 +
    1.76 +#endif /* _MP_GF2M_PRIV_H_ */

mercurial