os/security/crypto/weakcryptospi/source/asymmetric/dhkeypairshim.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @internalComponent
sl@0
    22
 @released
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef __DHKEYPAIRSHIM_H__
sl@0
    26
#define __DHKEYPAIRSHIM_H__
sl@0
    27
sl@0
    28
#include "asymmetrickeys.h"
sl@0
    29
sl@0
    30
	
sl@0
    31
/** 
sl@0
    32
* This class is capable of generating a Diffie-Hellman (DH) public/private key pair using the new crypto SPI interface.
sl@0
    33
*/
sl@0
    34
NONSHARABLE_CLASS(CDHKeyPairShim) : public CDHKeyPair
sl@0
    35
	{
sl@0
    36
public:
sl@0
    37
	/**
sl@0
    38
	 * Creates a new DH key pair from a random large integer,
sl@0
    39
	 * and a specified large prime and generator.
sl@0
    40
	 *
sl@0
    41
	 * The returned pointer is put onto the cleanup stack.
sl@0
    42
	 *
sl@0
    43
	 * @param aN	The DH parameter, n (a large prime)
sl@0
    44
	 * @param aG	The DH parameter, g (the generator)
sl@0
    45
	 * @return A pointer to a CDHKeyPairShim instance
sl@0
    46
	 * 
sl@0
    47
	 * @leave KErrArgument	If aG is out of bounds 
sl@0
    48
	 */
sl@0
    49
	static CDHKeyPairShim* NewLC(RInteger& aN, RInteger& aG);
sl@0
    50
sl@0
    51
	/**
sl@0
    52
	 * Creates a new DH key pair from a specified 
sl@0
    53
	 * large prime, generator, and random large integer.
sl@0
    54
	 *
sl@0
    55
	 * The returned pointer is put onto the cleanup stack.
sl@0
    56
	 *
sl@0
    57
	 * @param aN	The DH parameter, n (a large prime)
sl@0
    58
	 * @param aG	The DH parameter, g (the generator)
sl@0
    59
	 * @param ax	The DH value, x (a random large integer)
sl@0
    60
	 * @return A pointer to a CDHKeyPairShim instance
sl@0
    61
	 * 
sl@0
    62
	 * @leave KErrArgument	If either aG or ax are out of bounds 
sl@0
    63
	 */
sl@0
    64
	static CDHKeyPairShim* NewLC(RInteger& aN, RInteger& aG, RInteger& ax);
sl@0
    65
sl@0
    66
	/** The destructor frees all resources owned by the object, prior to its destruction. */
sl@0
    67
	~CDHKeyPairShim(void);
sl@0
    68
protected:
sl@0
    69
	/** Default constructor */
sl@0
    70
	CDHKeyPairShim(void);
sl@0
    71
sl@0
    72
	/** 
sl@0
    73
	 * Constructor
sl@0
    74
	 *
sl@0
    75
	 * @param aN	The DH parameter, n (a large prime)
sl@0
    76
	 * @param aG	The DH parameter, g (the generator)
sl@0
    77
	 */
sl@0
    78
	void ConstructL(RInteger& aN, RInteger& aG);
sl@0
    79
sl@0
    80
	/** 
sl@0
    81
	 * Constructor
sl@0
    82
	 *
sl@0
    83
	 * @param aN	The DH parameter, n (a large prime)
sl@0
    84
	 * @param aG	The DH parameter, g (the generator)
sl@0
    85
	 * @param ax	The DH value, x (a random large integer)
sl@0
    86
	 */
sl@0
    87
	void ConstructL(RInteger& aN, RInteger& aG, RInteger& ax);
sl@0
    88
	
sl@0
    89
	/**
sl@0
    90
	Creates the DH keypair from the given parameters
sl@0
    91
	@param aN	The DH parameter, n (a large prime)
sl@0
    92
	@param aG	The DH parameter, g (the generator)
sl@0
    93
	@param ax	The DH value, x (a random large integer)
sl@0
    94
	@param xIncluded if the x is included or not.
sl@0
    95
	*/
sl@0
    96
	void KeyConstructorL(RInteger& aN, RInteger& aG, RInteger& ax, TBool xIncluded);
sl@0
    97
	
sl@0
    98
private:
sl@0
    99
	CDHKeyPairShim(const CDHKeyPairShim&);
sl@0
   100
	CDHKeyPairShim& operator=(const CDHKeyPairShim&);
sl@0
   101
	};
sl@0
   102
sl@0
   103
#endif	//	__DHKEYPAIRSHIM_H__