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