/* * Copyright (C) 2016 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "owndefs.h" #include "owncp.h" #include "pcpbn.h" #include "pcpeccppoint.h" #define LOG2_CACHE_LINE_SIZE (LOG_CACHE_LINE_SIZE) static int div_upper(int a, int d) { return (a+d-1)/d; } static int getNumOperations(int bitsize, int w) { int n_overhead = (1<=n_opt) break; w_opt = w_trial; n_opt = n_trial; } return w_opt; #undef LIMIT } int cpECCP_ConvertRepresentation(BNU_CHUNK_T* pInput, int inpBits, int w) { Ipp32u* pR = (Ipp32u*)pInput; Ipp16u* pR16 = (Ipp16u*)pInput; int outBits = 0; Ipp32u base = (BNU_CHUNK_T)1<>digitShift) &digitMask; Ipp32u delta = (base-digit) & ~digitMask; delta <<= digitShift; cpDec_BNU32((Ipp32u*)(pR16+chunkIdx), (Ipp32u*)(pR16+chunkIdx), (2*nsR-chunkIdx+1)/2, delta); inpBits = BITSIZE_BNU32(pR, nsR); outBits += w; } return outBits; } /* // cpsScramblePut/cpsScrambleGet // stores to/retrieves from pScrambleEntry position // pre-computed data if fixed window method is used */ void cpECCP_ScramblePut(Ipp8u* pScrambleEntry, int proposity, const IppsECCPPointState* pPoint, cpSize coordLen) { int i; Ipp8u* pCoord; BNU_CHUNK_T* pX = BN_NUMBER(ECP_POINT_X(pPoint)); BNU_CHUNK_T* pY = BN_NUMBER(ECP_POINT_Y(pPoint)); BNU_CHUNK_T* pZ = BN_NUMBER(ECP_POINT_Z(pPoint)); int coordSize = coordLen*sizeof(BNU_CHUNK_T); ZEXPAND_BNU(pX, BN_SIZE(ECP_POINT_X(pPoint)), coordLen); ZEXPAND_BNU(pY, BN_SIZE(ECP_POINT_Y(pPoint)), coordLen); ZEXPAND_BNU(pZ, BN_SIZE(ECP_POINT_Z(pPoint)), coordLen); pCoord = (Ipp8u*)pX; for(i=0; i