crypto/weakcryptospi/inc/spi/randomplugin.h
author MattD <mattd@symbian.org>
Thu, 12 Nov 2009 16:07:39 +0000
changeset 21 7e3f204e6c81
parent 8 35751d3474b7
child 43 9b5a3a9fddf8
permissions -rw-r--r--
Added tag PDK_3.0.c for changeset 5ed53bb58874

/*
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
* Random generator interface
*
*/


/**
 @file
 @publishedPartner
 @released
*/

#ifndef __CRYPTOAPI_RANDOMPLUGIN_H__
#define __CRYPTOAPI_RANDOMPLUGIN_H__

#include <cryptospi/cryptoplugin.h>

namespace CryptoSpi
	{
	/**
	A cryptographically secure pseudo-random number generator (CSPRNG)
	Generates random numbers derived from entropy obtained from another
	source, usually a hardware random number generator or if unavailable,
	from a combination variety of unpredictable system variables, added
	to an entropy pool which is used for seeding. This might include
	keypresses generated by a user, hardware interrupts, etc.
	*/
	class MRandom : public MPlugin
	    {
	    public:
	        /**
	        Generate enough random bytes to fill the supplied descriptor
	        If there is not enough entropy available, or another error
	        occurs (e.g. out of memory) then this method may leave.
	        @param aDest The returned generated random bytes
	        */
	        virtual void GenerateRandomBytesL(TDes8& aDest) = 0;
	    };


	class MAsyncRandom : public MPlugin
	    {
	    public:
	        /**
	        Generate enough random bytes to fill the supplied descriptor
	        If there is not enough entropy available, or another error
	        occurs (e.g. out of memory) then this method may leave.
	        @param aDest The returned generated random bytes
	        */
	        virtual void GenerateRandomBytesL(TDes8& aDest, TRequestStatus& aStatus) = 0;

	        /**
	        Cancel an outstanding request
	        */
	        virtual void Cancel() = 0;
	    };
	
	}

#endif  // __CRYPTOAPI_RANDOMPLUGIN_H__