bn/asm/x86_64-mont5.pl: fix carry bug in bn_sqr8x_internal.
[openssl.git] / crypto / bn / rsaz_exp.h
1 /*
2  * Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 /*****************************************************************************
11 *                                                                            *
12 *  Copyright (c) 2012, Intel Corporation                                     *
13 *                                                                            *
14 *  All rights reserved.                                                      *
15 *                                                                            *
16 *  Redistribution and use in source and binary forms, with or without        *
17 *  modification, are permitted provided that the following conditions are    *
18 *  met:                                                                      *
19 *                                                                            *
20 *  *  Redistributions of source code must retain the above copyright         *
21 *     notice, this list of conditions and the following disclaimer.          *
22 *                                                                            *
23 *  *  Redistributions in binary form must reproduce the above copyright      *
24 *     notice, this list of conditions and the following disclaimer in the    *
25 *     documentation and/or other materials provided with the                 *
26 *     distribution.                                                          *
27 *                                                                            *
28 *  *  Neither the name of the Intel Corporation nor the names of its         *
29 *     contributors may be used to endorse or promote products derived from   *
30 *     this software without specific prior written permission.               *
31 *                                                                            *
32 *                                                                            *
33 *  THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY          *
34 *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE         *
35 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        *
36 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR            *
37 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     *
38 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
39 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
40 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
41 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
42 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
43 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
44 *                                                                            *
45 ******************************************************************************
46 * Developers and authors:                                                    *
47 * Shay Gueron (1, 2), and Vlad Krasnov (1)                                   *
48 * (1) Intel Corporation, Israel Development Center, Haifa, Israel            *
49 * (2) University of Haifa, Israel                                            *
50 *****************************************************************************/
51
52 #ifndef RSAZ_EXP_H
53 # define RSAZ_EXP_H
54
55 # undef RSAZ_ENABLED
56 # if defined(OPENSSL_BN_ASM_MONT) && \
57         (defined(__x86_64) || defined(__x86_64__) || \
58          defined(_M_AMD64) || defined(_M_X64))
59 #  define RSAZ_ENABLED
60
61 #  include <openssl/bn.h>
62
63 void RSAZ_1024_mod_exp_avx2(BN_ULONG result[16],
64                             const BN_ULONG base_norm[16],
65                             const BN_ULONG exponent[16],
66                             const BN_ULONG m_norm[16], const BN_ULONG RR[16],
67                             BN_ULONG k0);
68 int rsaz_avx2_eligible();
69
70 void RSAZ_512_mod_exp(BN_ULONG result[8],
71                       const BN_ULONG base_norm[8], const BN_ULONG exponent[8],
72                       const BN_ULONG m_norm[8], BN_ULONG k0,
73                       const BN_ULONG RR[8]);
74
75 # endif
76
77 #endif