os/security/crypto/weakcryptospi/source/asymmetric/dhkeypairshim.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2006-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 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @internalComponent
    22  @released
    23 */
    24 
    25 #ifndef __DHKEYPAIRSHIM_H__
    26 #define __DHKEYPAIRSHIM_H__
    27 
    28 #include "asymmetrickeys.h"
    29 
    30 	
    31 /** 
    32 * This class is capable of generating a Diffie-Hellman (DH) public/private key pair using the new crypto SPI interface.
    33 */
    34 NONSHARABLE_CLASS(CDHKeyPairShim) : public CDHKeyPair
    35 	{
    36 public:
    37 	/**
    38 	 * Creates a new DH key pair from a random large integer,
    39 	 * and a specified large prime and generator.
    40 	 *
    41 	 * The returned pointer is put onto the cleanup stack.
    42 	 *
    43 	 * @param aN	The DH parameter, n (a large prime)
    44 	 * @param aG	The DH parameter, g (the generator)
    45 	 * @return A pointer to a CDHKeyPairShim instance
    46 	 * 
    47 	 * @leave KErrArgument	If aG is out of bounds 
    48 	 */
    49 	static CDHKeyPairShim* NewLC(RInteger& aN, RInteger& aG);
    50 
    51 	/**
    52 	 * Creates a new DH key pair from a specified 
    53 	 * large prime, generator, and random large integer.
    54 	 *
    55 	 * The returned pointer is put onto the cleanup stack.
    56 	 *
    57 	 * @param aN	The DH parameter, n (a large prime)
    58 	 * @param aG	The DH parameter, g (the generator)
    59 	 * @param ax	The DH value, x (a random large integer)
    60 	 * @return A pointer to a CDHKeyPairShim instance
    61 	 * 
    62 	 * @leave KErrArgument	If either aG or ax are out of bounds 
    63 	 */
    64 	static CDHKeyPairShim* NewLC(RInteger& aN, RInteger& aG, RInteger& ax);
    65 
    66 	/** The destructor frees all resources owned by the object, prior to its destruction. */
    67 	~CDHKeyPairShim(void);
    68 protected:
    69 	/** Default constructor */
    70 	CDHKeyPairShim(void);
    71 
    72 	/** 
    73 	 * Constructor
    74 	 *
    75 	 * @param aN	The DH parameter, n (a large prime)
    76 	 * @param aG	The DH parameter, g (the generator)
    77 	 */
    78 	void ConstructL(RInteger& aN, RInteger& aG);
    79 
    80 	/** 
    81 	 * Constructor
    82 	 *
    83 	 * @param aN	The DH parameter, n (a large prime)
    84 	 * @param aG	The DH parameter, g (the generator)
    85 	 * @param ax	The DH value, x (a random large integer)
    86 	 */
    87 	void ConstructL(RInteger& aN, RInteger& aG, RInteger& ax);
    88 	
    89 	/**
    90 	Creates the DH keypair from the given parameters
    91 	@param aN	The DH parameter, n (a large prime)
    92 	@param aG	The DH parameter, g (the generator)
    93 	@param ax	The DH value, x (a random large integer)
    94 	@param xIncluded if the x is included or not.
    95 	*/
    96 	void KeyConstructorL(RInteger& aN, RInteger& aG, RInteger& ax, TBool xIncluded);
    97 	
    98 private:
    99 	CDHKeyPairShim(const CDHKeyPairShim&);
   100 	CDHKeyPairShim& operator=(const CDHKeyPairShim&);
   101 	};
   102 
   103 #endif	//	__DHKEYPAIRSHIM_H__