| 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 | // cpMulDgt_BNU32() |
| 24 | // |
| 25 | */ |
| 26 | |
| 27 | #include "owncp.h" |
| 28 | #include "pcpbnumisc.h" |
| 29 | #include "pcpbnu32misc.h" |
| 30 | #include "pcpbnu32arith.h" |
| 31 | |
| 32 | |
| 33 | /*F* |
| 34 | // Name: cpMulDgt_BNU32 |
| 35 | // |
| 36 | // Purpose: multiply BNU32 digit. |
| 37 | // |
| 38 | // Returns: |
| 39 | // carry |
| 40 | // |
| 41 | // Parameters: |
| 42 | // pA source |
| 43 | // nsA size of A |
| 44 | // val carry |
| 45 | // pR result |
| 46 | // |
| 47 | *F*/ |
| 48 | IPP_OWN_DEFN(Ipp32u, cpMulDgt_BNU32, (Ipp32u * pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)) |
| 49 | { |
| 50 | Ipp32u carry = 0; |
| 51 | cpSize i; |
| 52 | for (i = 0; i < nsA; i++) { |
| 53 | Ipp64u t = (Ipp64u)val * (Ipp64u)pA[i] + carry; |
| 54 | pR[i] = IPP_LODWORD(t); |
| 55 | carry = IPP_HIDWORD(t); |
| 56 | } |
| 57 | return carry; |
| 58 | } |