crypto/weakcryptospi/source/bigint/mont.h
changeset 19 cd501b96611d
child 29 ece3df019add
equal deleted inserted replaced
15:da2ae96f639b 19:cd501b96611d
       
     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  @file 
       
    22  @internalComponent
       
    23 */
       
    24  
       
    25 #ifndef __MONT_H__
       
    26 #define __MONT_H__
       
    27 
       
    28 class TInteger;
       
    29 class RInteger;
       
    30 
       
    31 /** A special representation of integers allowing efficient multiplication
       
    32  * and exponentiation under special conditions.
       
    33  * @internalComponent
       
    34  */
       
    35 class CMontgomeryStructure : public CBase
       
    36 	{
       
    37 public:
       
    38 	static CMontgomeryStructure* NewL(const TInteger& aModulus);
       
    39 	IMPORT_C static CMontgomeryStructure* NewLC(const TInteger& aModulus);
       
    40 	~CMontgomeryStructure();
       
    41 	const TInteger& ReduceL(const TInteger& aInteger) const;
       
    42 	const TInteger& MultiplyL(const TInteger& aA, const TInteger& aB) const;
       
    43 	IMPORT_C const TInteger& ExponentiateL(const TInteger& aBase, const TInteger& aExponent) const;
       
    44 	const TInteger& SquareL(const TInteger& aA) const;
       
    45 protected:
       
    46 	void DoMultiplyL(TInteger& aResult, const TInteger& aA, const TInteger& aB) const;
       
    47 	void DoSquareL(TInteger& aResult, const TInteger& aA) const;
       
    48 	TInteger& ConvertIn(TInteger& aInteger) const;
       
    49 	TInteger& ConvertOutL(TInteger& aInteger) const;
       
    50 	CMontgomeryStructure();
       
    51 private:
       
    52 	void ConstructL(const TInteger& aModulus);
       
    53 	RInteger iModulus;
       
    54 	RInteger iModulusInv;
       
    55 	RInteger iWorkspace;
       
    56 	mutable RInteger iResult;
       
    57 	};
       
    58 
       
    59 #endif // __MONT_H__