sl@0: /* sl@0: * Copyright (c) 2006-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: @released sl@0: */ sl@0: sl@0: #ifndef __DHKEYPAIRSHIM_H__ sl@0: #define __DHKEYPAIRSHIM_H__ sl@0: sl@0: #include "asymmetrickeys.h" sl@0: sl@0: sl@0: /** sl@0: * This class is capable of generating a Diffie-Hellman (DH) public/private key pair using the new crypto SPI interface. sl@0: */ sl@0: NONSHARABLE_CLASS(CDHKeyPairShim) : public CDHKeyPair sl@0: { sl@0: public: sl@0: /** sl@0: * Creates a new DH key pair from a random large integer, sl@0: * and a specified large prime and generator. sl@0: * sl@0: * The returned pointer is put onto the cleanup stack. sl@0: * sl@0: * @param aN The DH parameter, n (a large prime) sl@0: * @param aG The DH parameter, g (the generator) sl@0: * @return A pointer to a CDHKeyPairShim instance sl@0: * sl@0: * @leave KErrArgument If aG is out of bounds sl@0: */ sl@0: static CDHKeyPairShim* NewLC(RInteger& aN, RInteger& aG); sl@0: sl@0: /** sl@0: * Creates a new DH key pair from a specified sl@0: * large prime, generator, and random large integer. sl@0: * sl@0: * The returned pointer is put onto the cleanup stack. sl@0: * sl@0: * @param aN The DH parameter, n (a large prime) sl@0: * @param aG The DH parameter, g (the generator) sl@0: * @param ax The DH value, x (a random large integer) sl@0: * @return A pointer to a CDHKeyPairShim instance sl@0: * sl@0: * @leave KErrArgument If either aG or ax are out of bounds sl@0: */ sl@0: static CDHKeyPairShim* NewLC(RInteger& aN, RInteger& aG, RInteger& ax); sl@0: sl@0: /** The destructor frees all resources owned by the object, prior to its destruction. */ sl@0: ~CDHKeyPairShim(void); sl@0: protected: sl@0: /** Default constructor */ sl@0: CDHKeyPairShim(void); sl@0: sl@0: /** sl@0: * Constructor sl@0: * sl@0: * @param aN The DH parameter, n (a large prime) sl@0: * @param aG The DH parameter, g (the generator) sl@0: */ sl@0: void ConstructL(RInteger& aN, RInteger& aG); sl@0: sl@0: /** sl@0: * Constructor sl@0: * sl@0: * @param aN The DH parameter, n (a large prime) sl@0: * @param aG The DH parameter, g (the generator) sl@0: * @param ax The DH value, x (a random large integer) sl@0: */ sl@0: void ConstructL(RInteger& aN, RInteger& aG, RInteger& ax); sl@0: sl@0: /** sl@0: Creates the DH keypair from the given parameters sl@0: @param aN The DH parameter, n (a large prime) sl@0: @param aG The DH parameter, g (the generator) sl@0: @param ax The DH value, x (a random large integer) sl@0: @param xIncluded if the x is included or not. sl@0: */ sl@0: void KeyConstructorL(RInteger& aN, RInteger& aG, RInteger& ax, TBool xIncluded); sl@0: sl@0: private: sl@0: CDHKeyPairShim(const CDHKeyPairShim&); sl@0: CDHKeyPairShim& operator=(const CDHKeyPairShim&); sl@0: }; sl@0: sl@0: #endif // __DHKEYPAIRSHIM_H__