~ubuntu-branches/ubuntu/trusty/xulrunner/trusty

« back to all changes in this revision

Viewing changes to security/nss-fips/lib/freebl/mpi/mp_gf2m-priv.h

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-25 13:04:18 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080825130418-ck1i2ms384tzb9m0
Tags: 1.8.1.16+nobinonly-0ubuntu1
* New upstream release (taken from upstream CVS), LP: #254618.
* Fix MFSA 2008-35, MFSA 2008-34, MFSA 2008-33, MFSA 2008-32, MFSA 2008-31,
  MFSA 2008-30, MFSA 2008-29, MFSA 2008-28, MFSA 2008-27, MFSA 2008-25,
  MFSA 2008-24, MFSA 2008-23, MFSA 2008-22, MFSA 2008-21, MFSA 2008-26 also
  known as CVE-2008-2933, CVE-2008-2785, CVE-2008-2811, CVE-2008-2810,
  CVE-2008-2809, CVE-2008-2808, CVE-2008-2807, CVE-2008-2806, CVE-2008-2805,
  CVE-2008-2803, CVE-2008-2802, CVE-2008-2801, CVE-2008-2800, CVE-2008-2798.
* Drop 89_bz419350_attachment_306066 patch, merged upstream.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Mozilla Public License Version
 
6
 * 1.1 (the "License"); you may not use this file except in compliance with
 
7
 * the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/MPL/
 
9
 *
 
10
 * Software distributed under the License is distributed on an "AS IS" basis,
 
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
 * for the specific language governing rights and limitations under the
 
13
 * License.
 
14
 *
 
15
 * The Original Code is the Multi-precision Binary Polynomial Arithmetic Library.
 
16
 *
 
17
 * The Initial Developer of the Original Code is
 
18
 * Sun Microsystems, Inc.
 
19
 * Portions created by the Initial Developer are Copyright (C) 2003
 
20
 * the Initial Developer. All Rights Reserved.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Sheueling Chang Shantz <sheueling.chang@sun.com> and
 
24
 *   Douglas Stebila <douglas@stebila.ca> of Sun Laboratories.
 
25
 *
 
26
 * Alternatively, the contents of this file may be used under the terms of
 
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
28
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
30
 * of those above. If you wish to allow use of your version of this file only
 
31
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
32
 * use your version of this file under the terms of the MPL, indicate your
 
33
 * decision by deleting the provisions above and replace them with the notice
 
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
35
 * the provisions above, a recipient may use your version of this file under
 
36
 * the terms of any one of the MPL, the GPL or the LGPL.
 
37
 *
 
38
 * ***** END LICENSE BLOCK ***** */
 
39
 
 
40
#ifndef _MP_GF2M_PRIV_H_
 
41
#define _MP_GF2M_PRIV_H_
 
42
 
 
43
#include "mpi-priv.h"
 
44
 
 
45
extern const mp_digit mp_gf2m_sqr_tb[16];
 
46
 
 
47
#if defined(MP_USE_UINT_DIGIT)
 
48
#define MP_DIGIT_BITS 32
 
49
#else
 
50
#define MP_DIGIT_BITS 64
 
51
#endif
 
52
 
 
53
/* Platform-specific macros for fast binary polynomial squaring. */
 
54
#if MP_DIGIT_BITS == 32
 
55
#define gf2m_SQR1(w) \
 
56
    mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 16 | \
 
57
    mp_gf2m_sqr_tb[(w) >> 20 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF]
 
58
#define gf2m_SQR0(w) \
 
59
    mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >>  8 & 0xF] << 16 | \
 
60
    mp_gf2m_sqr_tb[(w) >>  4 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w)       & 0xF]
 
61
#else
 
62
#define gf2m_SQR1(w) \
 
63
    mp_gf2m_sqr_tb[(w) >> 60 & 0xF] << 56 | mp_gf2m_sqr_tb[(w) >> 56 & 0xF] << 48 | \
 
64
    mp_gf2m_sqr_tb[(w) >> 52 & 0xF] << 40 | mp_gf2m_sqr_tb[(w) >> 48 & 0xF] << 32 | \
 
65
    mp_gf2m_sqr_tb[(w) >> 44 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 40 & 0xF] << 16 | \
 
66
    mp_gf2m_sqr_tb[(w) >> 36 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w) >> 32 & 0xF]
 
67
#define gf2m_SQR0(w) \
 
68
    mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 56 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 48 | \
 
69
    mp_gf2m_sqr_tb[(w) >> 20 & 0xF] << 40 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF] << 32 | \
 
70
    mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >>  8 & 0xF] << 16 | \
 
71
    mp_gf2m_sqr_tb[(w) >>  4 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w)       & 0xF]
 
72
#endif
 
73
 
 
74
/* Multiply two binary polynomials mp_digits a, b.
 
75
 * Result is a polynomial with degree < 2 * MP_DIGIT_BITS - 1.
 
76
 * Output in two mp_digits rh, rl.
 
77
 */
 
78
void s_bmul_1x1(mp_digit *rh, mp_digit *rl, const mp_digit a, const mp_digit b);
 
79
 
 
80
/* Compute xor-multiply of two binary polynomials  (a1, a0) x (b1, b0)  
 
81
 * result is a binary polynomial in 4 mp_digits r[4].
 
82
 * The caller MUST ensure that r has the right amount of space allocated.
 
83
 */
 
84
void s_bmul_2x2(mp_digit *r, const mp_digit a1, const mp_digit a0, const mp_digit b1,
 
85
        const mp_digit b0);
 
86
 
 
87
/* Compute xor-multiply of two binary polynomials  (a2, a1, a0) x (b2, b1, b0)  
 
88
 * result is a binary polynomial in 6 mp_digits r[6].
 
89
 * The caller MUST ensure that r has the right amount of space allocated.
 
90
 */
 
91
void s_bmul_3x3(mp_digit *r, const mp_digit a2, const mp_digit a1, const mp_digit a0, 
 
92
        const mp_digit b2, const mp_digit b1, const mp_digit b0);
 
93
 
 
94
/* Compute xor-multiply of two binary polynomials  (a3, a2, a1, a0) x (b3, b2, b1, b0)  
 
95
 * result is a binary polynomial in 8 mp_digits r[8].
 
96
 * The caller MUST ensure that r has the right amount of space allocated.
 
97
 */
 
98
void s_bmul_4x4(mp_digit *r, const mp_digit a3, const mp_digit a2, const mp_digit a1, 
 
99
        const mp_digit a0, const mp_digit b3, const mp_digit b2, const mp_digit b1, 
 
100
        const mp_digit b0);
 
101
 
 
102
#endif /* _MP_GF2M_PRIV_H_ */