rsaz_exp.h 4.3 KB

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