sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-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 |
* Implements CKeyCreator
|
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 __CCREATEKEYASYNC_H__
|
sl@0
|
26 |
#define __CCREATEKEYASYNC_H__
|
sl@0
|
27 |
|
sl@0
|
28 |
#include "fsdatatypes.h"
|
sl@0
|
29 |
#include <e32std.h>
|
sl@0
|
30 |
#include <mctkeystore.h>
|
sl@0
|
31 |
#include <asymmetrickeys.h>
|
sl@0
|
32 |
#include <bigint.h>
|
sl@0
|
33 |
|
sl@0
|
34 |
class CSimpleDHKey;
|
sl@0
|
35 |
class CKeyCreatorData;
|
sl@0
|
36 |
|
sl@0
|
37 |
//! Server side
|
sl@0
|
38 |
//! Class to make key creation "asynchronous" by spinning off a thread
|
sl@0
|
39 |
//! to make the synchronous call to the appropriate key creation function
|
sl@0
|
40 |
//! The thread entry point is a static member of this class, which holds the
|
sl@0
|
41 |
//! thread and thread parameter data too. When the key has been created, the
|
sl@0
|
42 |
//! thread terminates using Rendezvous to notify the main thread. The created key
|
sl@0
|
43 |
//! is returned through the CAsymmetricCipher member of CKeyCreatorData
|
sl@0
|
44 |
class CKeyCreator : public CActive
|
sl@0
|
45 |
{
|
sl@0
|
46 |
public:
|
sl@0
|
47 |
CKeyCreator();
|
sl@0
|
48 |
~CKeyCreator();
|
sl@0
|
49 |
public: // Spin a thread to create an appropriate key, if successful, left on CleanupStack
|
sl@0
|
50 |
void DoCreateKeyAsync(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize, TRequestStatus& aStatus);
|
sl@0
|
51 |
public:
|
sl@0
|
52 |
// JCS this needs improvement when new crypto api is reviewed
|
sl@0
|
53 |
CRSAKeyPair* GetCreatedRSAKey();
|
sl@0
|
54 |
CDSAKeyPair* GetCreatedDSAKey();
|
sl@0
|
55 |
void GetCreatedDHKey(RInteger& aDHKey);
|
sl@0
|
56 |
protected:
|
sl@0
|
57 |
void DoCancel();
|
sl@0
|
58 |
void RunL();
|
sl@0
|
59 |
TInt RunError(TInt anError);
|
sl@0
|
60 |
private:
|
sl@0
|
61 |
static TInt CreatorThreadEntryPoint(TAny*);
|
sl@0
|
62 |
private:
|
sl@0
|
63 |
enum TAction {EIdle, EReadyToCreateKey, ECreatedKey};
|
sl@0
|
64 |
TAction iAction;
|
sl@0
|
65 |
private:
|
sl@0
|
66 |
TRequestStatus* iClientStatus;
|
sl@0
|
67 |
RThread iCreatorThread;
|
sl@0
|
68 |
private:
|
sl@0
|
69 |
class CKeyCreatorData : public CBase
|
sl@0
|
70 |
{
|
sl@0
|
71 |
public:
|
sl@0
|
72 |
CKeyCreatorData(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize);
|
sl@0
|
73 |
~CKeyCreatorData();
|
sl@0
|
74 |
public: // Don't bother hiding the data from myself
|
sl@0
|
75 |
TInt iSize;
|
sl@0
|
76 |
CKeyInfo::EKeyAlgorithm iKeyAlgorithm;
|
sl@0
|
77 |
// Algorithm identified by iKeyAlgorithm
|
sl@0
|
78 |
|
sl@0
|
79 |
union CreatedKey
|
sl@0
|
80 |
{
|
sl@0
|
81 |
CRSAKeyPair* iRSAKey;
|
sl@0
|
82 |
CDSAKeyPair* iDSAKey;
|
sl@0
|
83 |
CSimpleDHKey* iDHKey;
|
sl@0
|
84 |
} iKey;
|
sl@0
|
85 |
};
|
sl@0
|
86 |
|
sl@0
|
87 |
CKeyCreatorData* iCreateData;
|
sl@0
|
88 |
};
|
sl@0
|
89 |
|
sl@0
|
90 |
#endif // __CCREATEKEYASYNC_H__
|