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: * CMontgomeryStructure class implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __MONT_H__ sl@0: #define __MONT_H__ sl@0: sl@0: class TInteger; sl@0: class RInteger; sl@0: sl@0: /** A special representation of integers allowing efficient multiplication sl@0: * and exponentiation under special conditions. sl@0: * @internalComponent sl@0: */ sl@0: class CMontgomeryStructure : public CBase sl@0: { sl@0: public: sl@0: static CMontgomeryStructure* NewL(const TInteger& aModulus); sl@0: IMPORT_C static CMontgomeryStructure* NewLC(const TInteger& aModulus); sl@0: ~CMontgomeryStructure(); sl@0: const TInteger& ReduceL(const TInteger& aInteger) const; sl@0: const TInteger& MultiplyL(const TInteger& aA, const TInteger& aB) const; sl@0: IMPORT_C const TInteger& ExponentiateL(const TInteger& aBase, const TInteger& aExponent) const; sl@0: const TInteger& SquareL(const TInteger& aA) const; sl@0: protected: sl@0: void DoMultiplyL(TInteger& aResult, const TInteger& aA, const TInteger& aB) const; sl@0: void DoSquareL(TInteger& aResult, const TInteger& aA) const; sl@0: TInteger& ConvertInL(TInteger& aInteger) const; sl@0: TInteger& ConvertOutL(TInteger& aInteger) const; sl@0: CMontgomeryStructure(); sl@0: private: sl@0: void ConstructL(const TInteger& aModulus); sl@0: RInteger iModulus; sl@0: RInteger iModulusInv; sl@0: RInteger iWorkspace; sl@0: mutable RInteger iResult; sl@0: }; sl@0: sl@0: #endif // __MONT_H__