os/security/crypto/weakcryptospi/inc/spi/randomplugin.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 * Random generator interface
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @publishedPartner
    23  @released
    24 */
    25 
    26 #ifndef __CRYPTOAPI_RANDOMPLUGIN_H__
    27 #define __CRYPTOAPI_RANDOMPLUGIN_H__
    28 
    29 #include <cryptospi/cryptoplugin.h>
    30 
    31 namespace CryptoSpi
    32 	{
    33 	/**
    34 	A pseudo-random number generator (PRNG).
    35 	Generates random numbers derived from entropy obtained from another
    36 	source, usually a hardware random number generator or if unavailable,
    37 	from a combination variety of unpredictable system variables, added
    38 	to an entropy pool which is used for seeding. This might include
    39 	keypresses generated by a user, hardware interrupts, etc.
    40 	*/
    41 	class MRandom : public MPlugin
    42 	    {
    43 	    public:
    44 	        /**
    45 	         * Implementations of this method should fill the passed
    46 	         * buffer with the generated pseudo-random data up to the
    47 	         * current length, discarding any current contents. The 
    48 	         * implementations should leave with KErrNotSecure when 
    49 	         * the generated random data is not secure enough. 
    50 	         *
    51 	         * @param aDest The buffer to fill with random data
    52 	         * @leave KErrNotSecure Random data generated is not 
    53 	         *        secure enough for crytographic operations
    54 	         *        otherwise, leaves with any other system wide error code.
    55 	         *
    56 	         */
    57 	        virtual void GenerateRandomBytesL(TDes8& aDest) = 0;
    58 	    };
    59 
    60 
    61 	class MAsyncRandom : public MPlugin
    62 	    {
    63 	    public:
    64 	        /**
    65 	         * Implementations of this method should fill the passed
    66 	         * buffer with the generated pseudo-random data up to the
    67 	         * current length, discarding any current contents. The 
    68 	         * implementations should leave with KErrNotSecure when 
    69 	         * the generated random data is not secure enough. 
    70 	         *
    71 	         * @param aDest The buffer to fill with random data
    72 	         * @param aStatus The argument to carry the asynchonous request completion
    73 	         *        status to notify the client when buffer is filled with random data.  
    74 	         * @leave KErrNotSecure Random data generated is not 
    75 	         *        secure enough for crytographic operations
    76 	         *        otherwise, leaves with any other system wide error code.
    77 	         *
    78 	         */
    79 	        virtual void GenerateRandomBytesL(TDes8& aDest, TRequestStatus& aStatus) = 0;
    80 
    81 	        /**
    82 	        Cancel an outstanding request
    83 	        */
    84 	        virtual void Cancel() = 0;
    85 	    };
    86 	
    87 	}
    88 
    89 #endif  // __CRYPTOAPI_RANDOMPLUGIN_H__