| 1 | /************************************************************************* |
| 2 | * Copyright (C) 2002 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 | /* |
| 18 | // Purpose: |
| 19 | // Intel(R) Cryptography Primitives Library |
| 20 | // Internal BNU32 arithmetic. |
| 21 | // |
| 22 | // Contents: |
| 23 | // cpSubMulDgt_BNU32() |
| 24 | // |
| 25 | */ |
| 26 | |
| 27 | #include "owncp.h" |
| 28 | #include "pcpbnumisc.h" |
| 29 | #include "pcpbnu32misc.h" |
| 30 | #include "pcpbnu32arith.h" |
| 31 | |
| 32 | /*F* |
| 33 | // Name: cpMulDgt_BNU32 |
| 34 | // |
| 35 | // Purpose: multiply and subtract BNU32. |
| 36 | // |
| 37 | // Returns: |
| 38 | // carry |
| 39 | // |
| 40 | // Parameters: |
| 41 | // pA source |
| 42 | // nsA size of A |
| 43 | // val digit to mul |
| 44 | // pR result |
| 45 | // |
| 46 | *F*/ |
| 47 | |
| 48 | #if !((_IPP32E == _IPP32E_M7) || (_IPP32E == _IPP32E_U8) || (_IPP32E == _IPP32E_Y8) || \ |
| 49 | (_IPP32E >= _IPP32E_E9) || (_IPP32E == _IPP32E_N8)) |
| 50 | IPP_OWN_DEFN(Ipp32u, cpSubMulDgt_BNU32, (Ipp32u * pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)) |
| 51 | { |
| 52 | Ipp32u carry = 0; |
| 53 | for (; nsA > 0; nsA--) { |
| 54 | Ipp64u r = (Ipp64u)*pR - (Ipp64u)(*pA++) * val - carry; |
| 55 | *pR++ = IPP_LODWORD(r); |
| 56 | carry = 0 - IPP_HIDWORD(r); |
| 57 | } |
| 58 | return carry; |
| 59 | } |
| 60 | #endif |