sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 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 |
* This class implements the reference Crypto Token Hardware Abstraction
|
sl@0
|
16 |
* Interface (HAI). It is just intended to show how operations using
|
sl@0
|
17 |
* device keys can be performed using crypto token framework. In the
|
sl@0
|
18 |
* real world scenario, this HAI should be replaced by device drivers
|
sl@0
|
19 |
* by the licensees. In such a case, all the operations performed by
|
sl@0
|
20 |
* the replacing class would be performed in Kernel Space.
|
sl@0
|
21 |
*
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
/**
|
sl@0
|
26 |
* @file
|
sl@0
|
27 |
* @internalComponent
|
sl@0
|
28 |
* @released
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
#ifndef CCRYPTOTOKENHAI_H
|
sl@0
|
31 |
#define CCRYPTOTOKENHAI_H
|
sl@0
|
32 |
|
sl@0
|
33 |
#include <e32base.h>
|
sl@0
|
34 |
#include <f32file.h>
|
sl@0
|
35 |
#include <S32FILE.H>
|
sl@0
|
36 |
#include <mctkeystore.h>
|
sl@0
|
37 |
|
sl@0
|
38 |
class CKeyDetails;
|
sl@0
|
39 |
class MCTToken;
|
sl@0
|
40 |
|
sl@0
|
41 |
namespace CryptoSpi
|
sl@0
|
42 |
{
|
sl@0
|
43 |
class CSigner;
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
NONSHARABLE_CLASS(CCryptoTokenHai) : public CBase
|
sl@0
|
47 |
{
|
sl@0
|
48 |
public:
|
sl@0
|
49 |
IMPORT_C static CCryptoTokenHai* NewLC(MCTToken* aToken);
|
sl@0
|
50 |
IMPORT_C static CCryptoTokenHai* NewL(MCTToken* aToken);
|
sl@0
|
51 |
IMPORT_C ~CCryptoTokenHai();
|
sl@0
|
52 |
|
sl@0
|
53 |
public:
|
sl@0
|
54 |
IMPORT_C void DecryptL(TInt aHandle,
|
sl@0
|
55 |
const TDesC8& aCiphertext,
|
sl@0
|
56 |
HBufC8*& aPlaintext );
|
sl@0
|
57 |
|
sl@0
|
58 |
IMPORT_C void SignL( TInt aHandle,
|
sl@0
|
59 |
const TDesC8& aPlaintext,
|
sl@0
|
60 |
HBufC8*& aSignature );
|
sl@0
|
61 |
|
sl@0
|
62 |
IMPORT_C TInt KeyPresent( TInt aHandle );
|
sl@0
|
63 |
IMPORT_C void ExportPrivateKeyL( TInt aHandle, HBufC8*& aKey );
|
sl@0
|
64 |
IMPORT_C void ExportPublicKeyL( TInt aHandle, HBufC8*& aKey );
|
sl@0
|
65 |
IMPORT_C void ImportKeyL( const TDesC& aLabel, const TDesC8& aPrivateKey, const TDesC8& aPublicKey );
|
sl@0
|
66 |
IMPORT_C void ListL(const TCTKeyAttributeFilter& aFilter, RPointerArray<CCTKeyInfo>& aKeys) const;
|
sl@0
|
67 |
|
sl@0
|
68 |
private:
|
sl@0
|
69 |
void ConstructL();
|
sl@0
|
70 |
CCryptoTokenHai(MCTToken& aToken);
|
sl@0
|
71 |
void OpenStoreL();
|
sl@0
|
72 |
void OpenStoreInFileL(const TDesC& aFile);
|
sl@0
|
73 |
void CreateStoreInFileL(const TDesC& aFile);
|
sl@0
|
74 |
void MakePrivateFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut);
|
sl@0
|
75 |
void EnsurePathL(RFs& aFs, const TDesC& aFile);
|
sl@0
|
76 |
void MakePrivateROMFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut);
|
sl@0
|
77 |
void CopyL(RFs& aFs, const TDesC& aSouce, const TDesC& aDest);
|
sl@0
|
78 |
void CompactStore();
|
sl@0
|
79 |
static void RevertStore(TAny* aStore);
|
sl@0
|
80 |
void ReadKeysFromStoreL();
|
sl@0
|
81 |
TBool KeyMatchesFilterL(const CKeyDetails& aInfo, const TCTKeyAttributeFilter& aFilter) const;
|
sl@0
|
82 |
void CopyStoreFromROML(const TDesC& fullPath, TInt result);
|
sl@0
|
83 |
void WriteKeysToStoreL(RStoreWriteStream& aRootStream);
|
sl@0
|
84 |
|
sl@0
|
85 |
private:
|
sl@0
|
86 |
RPointerArray<CKeyDetails> iKeys;
|
sl@0
|
87 |
RFs iFs;
|
sl@0
|
88 |
CPermanentFileStore* iFileStore;
|
sl@0
|
89 |
TStreamId iRootStreamId;
|
sl@0
|
90 |
MCTToken& iToken;
|
sl@0
|
91 |
};
|
sl@0
|
92 |
|
sl@0
|
93 |
#endif // CCRYPTOTOKENHAI_H
|