os/security/crypto/weakcrypto/inc/randsvrimpl.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) 2003-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
* Random Server Codes
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file 
sl@0
    22
 @internalTechnology
sl@0
    23
*/
sl@0
    24
 
sl@0
    25
#ifndef RANDSVRIMPL_H
sl@0
    26
#define RANDSVRIMPL_H
sl@0
    27
sl@0
    28
sl@0
    29
const TInt KRandomBlockSize=1024;
sl@0
    30
const TInt KRandomPoolSize=2048;
sl@0
    31
sl@0
    32
class CRandomScheduler:public CActiveScheduler
sl@0
    33
	{
sl@0
    34
public:
sl@0
    35
	static TBool New(void);
sl@0
    36
	void Error(TInt aError) const;
sl@0
    37
	};
sl@0
    38
sl@0
    39
class CRandomSession;
sl@0
    40
sl@0
    41
class CRandomServer : public CServer2
sl@0
    42
	{
sl@0
    43
public:
sl@0
    44
	static TInt New(void);
sl@0
    45
	~CRandomServer(void);
sl@0
    46
	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
sl@0
    47
	friend class CRandomSession;
sl@0
    48
private:
sl@0
    49
	CRandomServer(void);
sl@0
    50
	void ConstructL(void);
sl@0
    51
	void Stir(void);
sl@0
    52
	TPtrC8 GetRandom(void); 
sl@0
    53
	CMessageDigest* Hash(void) const;
sl@0
    54
	static TInt Tick(TAny* aPointer);
sl@0
    55
	TUint8* iPool;
sl@0
    56
	TInt iPoolIn;
sl@0
    57
	TInt iPoolOut;
sl@0
    58
	TInt iQuality;
sl@0
    59
	TBool iFast;
sl@0
    60
	CMessageDigest* iHash;
sl@0
    61
	CPeriodic* iTicker;
sl@0
    62
	};
sl@0
    63
sl@0
    64
class CRandomSession : public CSession2 
sl@0
    65
	{
sl@0
    66
public:
sl@0
    67
	enum { KRandomRequest };
sl@0
    68
	static CRandomSession* NewL(CRandomServer* aServer);
sl@0
    69
	~CRandomSession(void);
sl@0
    70
	void ServiceL(const RMessage2& aMessage);
sl@0
    71
private:
sl@0
    72
	TInt FillBuffer(const RMessage2& aMessage);
sl@0
    73
	CRandomServer* iServer;
sl@0
    74
	CRandomSession(CRandomServer* aServer);
sl@0
    75
	};
sl@0
    76
sl@0
    77
#endif // RANDSVRIMPL_H