diff -r 000000000000 -r 2c201484c85f crypto/weakcrypto/source/bigint/words.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/crypto/weakcrypto/source/bigint/words.h Wed Jul 08 11:25:26 2009 +0100 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +/** + @file + @internalComponent +*/ + +#ifndef __BIGINT_WORDS_H__ +#define __BIGINT_WORDS_H__ + +#include "../common/inlines.h" + +inline void ArraySetBit(TUint* aS, TUint aJ) + { + aS[aJ/WORD_BITS] |= (1L << (aJ%WORD_BITS)); + } + +inline TUint CountWords(const TUint *X, TUint N) + { + while (N && X[N-1]==0) + N--; + return N; + } + +inline void SetWords(TUint *r, TUint a, TUint n) + { + Mem::Fill(r, WordsToBytes(n), a); + } + +inline void CopyWords(TUint *r, const TUint *a, TUint n) + { + Mem::Copy(r, a, WordsToBytes(n)); + } + +inline TUint ShiftWordsLeftByBits(TUint *r, TUint n, TUint shiftBits) + { + assert (shiftBits> (WORD_BITS-shiftBits); + } + return carry; + } + +inline TUint ShiftWordsRightByBits(TUint *r, TUint n, TUint shiftBits) +{ + assert (shiftBits=0; i--) + { + u = r[i]; + r[i] = (u >> shiftBits) | carry; + carry = u << (WORD_BITS-shiftBits); + } + return carry; + } + +inline TUint CryptoMin(TUint aLeft, TUint aRight) + { + return(aLeft=shiftWords; i--) + r[i] = r[i-shiftWords]; + SetWords(r, 0, shiftWords); + } + } + +inline void ShiftWordsRightByWords(TUint *r, TUint n, TUint shiftWords) + { + shiftWords = CryptoMin(shiftWords, n); + if (shiftWords) + { + for (TUint i=0; i+shiftWords