crypto/weakcrypto/source/bigint/mont.h
changeset 0 2c201484c85f
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * CMontgomeryStructure class implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file 
       
    24  @internalComponent
       
    25 */
       
    26  
       
    27 #ifndef __MONT_H__
       
    28 #define __MONT_H__
       
    29 
       
    30 class TInteger;
       
    31 class RInteger;
       
    32 
       
    33 /** A special representation of integers allowing efficient multiplication
       
    34  * and exponentiation under special conditions.
       
    35  * @internalComponent
       
    36  */
       
    37 class CMontgomeryStructure : public CBase
       
    38 	{
       
    39 public:
       
    40 	static CMontgomeryStructure* NewL(const TInteger& aModulus);
       
    41 	static CMontgomeryStructure* NewLC(const TInteger& aModulus);
       
    42 	~CMontgomeryStructure();
       
    43 	const TInteger& ReduceL(const TInteger& aInteger) const;
       
    44 	const TInteger& MultiplyL(const TInteger& aA, const TInteger& aB) const;
       
    45 	const TInteger& ExponentiateL(const TInteger& aBase, const TInteger& aExponent) const;
       
    46 	const TInteger& SquareL(const TInteger& aA) const;
       
    47 protected:
       
    48 	void DoMultiplyL(TInteger& aResult, const TInteger& aA, const TInteger& aB) const;
       
    49 	void DoSquareL(TInteger& aResult, const TInteger& aA) const;
       
    50 	TInteger& ConvertInL(TInteger& aInteger) const;
       
    51 	TInteger& ConvertOutL(TInteger& aInteger) const;
       
    52 	CMontgomeryStructure();
       
    53 private:
       
    54 	void ConstructL(const TInteger& aModulus);
       
    55 	RInteger iModulus;
       
    56 	RInteger iModulusInv;
       
    57 	RInteger iWorkspace;
       
    58 	mutable RInteger iResult;
       
    59 	};
       
    60 
       
    61 #endif // __MONT_H__