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