crypto/weakcrypto/inc/randsvr.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2003-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 Server Codes
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file 
       
    24  @internalTechnology
       
    25 */
       
    26  
       
    27 #ifndef __RANDSVR_H__
       
    28 #define __RANDSVR_H__
       
    29 
       
    30 #include <e32base.h>
       
    31 #include <hash.h>
       
    32 
       
    33 
       
    34 /** 
       
    35 @publishedPartner
       
    36 @released
       
    37 */
       
    38 IMPORT_C TInt RunRandomServer(TAny* /*someParameters*/);
       
    39 
       
    40 const TInt KRandomBlockSize=1024;
       
    41 const TInt KRandomPoolSize=2048;
       
    42 
       
    43 /**
       
    44  *
       
    45  * @internalTechnology
       
    46  */
       
    47 class CRandomScheduler:public CActiveScheduler
       
    48 	{
       
    49 public:
       
    50 	static TBool New(void);
       
    51 	void Error(TInt aError) const;
       
    52 	};
       
    53 
       
    54 class CRandomSession;
       
    55 
       
    56 /**
       
    57  *
       
    58  * @internalTechnology
       
    59  */
       
    60 class CRandomServer : public CServer2
       
    61 	{
       
    62 public:
       
    63 	static TInt New(void);
       
    64 	~CRandomServer(void);
       
    65 	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
    66 	friend class CRandomSession;
       
    67 private:
       
    68 	CRandomServer(void);
       
    69 	void ConstructL(void);
       
    70 	void Stir(void);
       
    71 	TPtrC8 GetRandom(void); 
       
    72 	CMessageDigest* Hash(void) const;
       
    73 	static TInt Tick(TAny* aPointer);
       
    74 	TUint8* iPool;
       
    75 	TInt iPoolIn;
       
    76 	TInt iPoolOut;
       
    77 	TInt iQuality;
       
    78 	TBool iFast;
       
    79 	CMessageDigest* iHash;
       
    80 	CPeriodic* iTicker;
       
    81 	};
       
    82 
       
    83 /**
       
    84  *
       
    85  * @internalTechnology
       
    86  */
       
    87 class CRandomSession : public CSession2 
       
    88 	{
       
    89 public:
       
    90 	enum { KRandomRequest };
       
    91 	static CRandomSession* NewL(CRandomServer* aServer);
       
    92 	~CRandomSession(void);
       
    93 	void ServiceL(const RMessage2& aMessage);
       
    94 private:
       
    95 	TInt FillBuffer(const RMessage2& aMessage);
       
    96 	CRandomServer* iServer;
       
    97 	CRandomSession(CRandomServer* aServer);
       
    98 	};
       
    99 
       
   100 #endif