| 1 | /************************************************************************* |
| 2 | * Copyright (C) 2021 Intel Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | *************************************************************************/ |
| 16 | |
| 17 | #if !defined(_IFMA_ARITH_N384R1_H_) |
| 18 | #define _IFMA_ARITH_N384R1_H_ |
| 19 | |
| 20 | #include "owndefs.h" |
| 21 | |
| 22 | #if (_IPP32E >= _IPP32E_K1) |
| 23 | |
| 24 | #include "ifma_alias_avx512.h" |
| 25 | |
| 26 | #define ifma_amm52_n384 OWNAPI(ifma_amm52_n384) |
| 27 | #define ifma_add52_n384 OWNAPI(ifma_add52_n384) |
| 28 | #define ifma_fastred52_n384 OWNAPI(ifma_fastred52_n384) |
| 29 | #define ifma_tomont52_n384 OWNAPI(ifma_tomont52_n384) |
| 30 | #define ifma_frommont52_n384 OWNAPI(ifma_frommont52_n384) |
| 31 | #define ifma_aminv52_n384 OWNAPI(ifma_aminv52_n384) |
| 32 | |
| 33 | /** |
| 34 | * \brief |
| 35 | * |
| 36 | * Montgomery multiplication |
| 37 | * |
| 38 | * a * b * R mod n, where R = 2^(5*52) mod n |
| 39 | * |
| 40 | * \param[in] a first value (in radix 2^52) |
| 41 | * \param[in] b second value (in radix 2^52) |
| 42 | */ |
| 43 | IPP_OWN_DECL(m512, ifma_amm52_n384, (const m512 a, const m512 b)) |
| 44 | |
| 45 | /** |
| 46 | * \brief |
| 47 | * |
| 48 | * A + B (in 2^52 radix) |
| 49 | * |
| 50 | * \param[in] a first value (in radix 2^52) |
| 51 | * \param[in] b second value (in radix 2^52) |
| 52 | */ |
| 53 | IPP_OWN_DECL(m512, ifma_add52_n384, (const m512 a, const m512 b)) |
| 54 | |
| 55 | /** |
| 56 | * \brief |
| 57 | * |
| 58 | * Reduction modulo n (subgroup order). |
| 59 | * |
| 60 | * (a >= n384) ? a - n384 : a |
| 61 | * |
| 62 | * \param[in] a value (in radix 2^52) |
| 63 | */ |
| 64 | IPP_OWN_DECL(m512, ifma_fastred52_n384, (const m512 a)) |
| 65 | |
| 66 | /** |
| 67 | * \brief |
| 68 | * |
| 69 | * Conversion to Montgomery domain modulo n (subgroup order). |
| 70 | * |
| 71 | * a * R mod n, where R = 2^(5*52) mod n |
| 72 | * |
| 73 | * \param[in] a value (in radix 2^52) |
| 74 | */ |
| 75 | IPP_OWN_DECL(m512, ifma_tomont52_n384, (const m512 a)) |
| 76 | |
| 77 | /** |
| 78 | * \brief |
| 79 | * |
| 80 | * Conversion from Montgomery domain modulo n (subgroup order). |
| 81 | * |
| 82 | * a mod n |
| 83 | * |
| 84 | * \param[in] p value (in radix 2^52) |
| 85 | */ |
| 86 | IPP_OWN_DECL(m512, ifma_frommont52_n384, (const m512 a)) |
| 87 | |
| 88 | /** |
| 89 | * \brief |
| 90 | * |
| 91 | * Modular inverse modulo n (subgroup order). |
| 92 | * |
| 93 | * 1/z mod n |
| 94 | * |
| 95 | * \param[in] z value (in radix 2^52) |
| 96 | */ |
| 97 | IPP_OWN_DECL(m512, ifma_aminv52_n384, (const m512 z)) |
| 98 | |
| 99 | #endif // (_IPP32E >= _IPP32E_K1) |
| 100 | |
| 101 | #endif // _IFMA_ARITH_N384R1_H_ |