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 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef _Keytool_utils_h_
|
sl@0
|
20 |
#define _Keytool_utils_h_
|
sl@0
|
21 |
#include <e32std.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
#include <mctkeystore.h>
|
sl@0
|
24 |
#include <signed.h>
|
sl@0
|
25 |
#include <cctcertinfo.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
_LIT(KSWInstall, "SWInstall");
|
sl@0
|
29 |
_LIT(KSWInstallOCSP, "SWInstallOCSP");
|
sl@0
|
30 |
_LIT(KMidletInstall, "MidletInstall");
|
sl@0
|
31 |
_LIT(KTls, "SSL/TLS");
|
sl@0
|
32 |
_LIT(KTOcsp, "OCSP Test");
|
sl@0
|
33 |
_LIT(KUnknown, "Unknown Applicability!");
|
sl@0
|
34 |
|
sl@0
|
35 |
const TInt swinstalluid = 0x100042AB;
|
sl@0
|
36 |
const TInt swinstallocspuid = 0x1000A8B6;
|
sl@0
|
37 |
const TInt midletinstalluid = 0x101F9B28;
|
sl@0
|
38 |
const TInt tlsuid = 0x1000183D;
|
sl@0
|
39 |
const TInt tocspuid = 0x1000A405;
|
sl@0
|
40 |
|
sl@0
|
41 |
const TInt KUidSecurityKeytool= 0x10281c32;
|
sl@0
|
42 |
|
sl@0
|
43 |
/**
|
sl@0
|
44 |
* A bunch of assorted useful functions for the keytool.
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
class KeyToolUtils
|
sl@0
|
47 |
{
|
sl@0
|
48 |
public:
|
sl@0
|
49 |
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
* Given a <code>CCTKeyInfo</code> object is prints its
|
sl@0
|
52 |
* contents in a human readable format.
|
sl@0
|
53 |
*
|
sl@0
|
54 |
* @param aKey The <code>CCTKeyInfo</code> hgolding the information
|
sl@0
|
55 |
* we are interested in.
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
static void PrintKeyInfoL(const CCTKeyInfo& aKey, TBool aIsDetailed = EFalse, TBool aPageWise = EFalse);
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
* Prints a human readable translation of the given key usage code.
|
sl@0
|
61 |
*
|
sl@0
|
62 |
* @param aUsage The key usage we want to print.
|
sl@0
|
63 |
* @param aConsole The console where the output goes.
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
static void PrintUsageL(TUint aUsage);
|
sl@0
|
66 |
|
sl@0
|
67 |
/**
|
sl@0
|
68 |
* Given a key access encoded as an integer (we are talking
|
sl@0
|
69 |
* <code>CKeyInfoBase::EKeyAccess</code> anyway) it returns
|
sl@0
|
70 |
* an equivalent human understandable descriptor.
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
static HBufC* KeyAccessDesLC(TInt aAccess);
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
* Given an algorithm identifier returns an equivalent human
|
sl@0
|
76 |
* readable descriptor.
|
sl@0
|
77 |
*/
|
sl@0
|
78 |
static HBufC* AlgorithmDesLC(CCTKeyInfo::EKeyAlgorithm aAlgorithm);
|
sl@0
|
79 |
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
* Given a list of keys as returned from keystore->list() method
|
sl@0
|
82 |
* and a label of a key we are interested in, it returns the corresponding
|
sl@0
|
83 |
* key info.
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
static CCTKeyInfo* findKey(RMPointerArray<CCTKeyInfo>& aKeyList, TDesC& aLabel);
|
sl@0
|
86 |
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
* Pretty prints an octet string.
|
sl@0
|
89 |
*
|
sl@0
|
90 |
* @param aString The octet string to be printed.
|
sl@0
|
91 |
* @param aConsole The console where the output goes.
|
sl@0
|
92 |
*/
|
sl@0
|
93 |
static void WriteOctetStringL(const TDesC8& aString);
|
sl@0
|
94 |
|
sl@0
|
95 |
/**
|
sl@0
|
96 |
* Pretty prints the human readable description of a given error code.
|
sl@0
|
97 |
*
|
sl@0
|
98 |
* @param aError The error code we want to print.
|
sl@0
|
99 |
* @param aConsole The console where the output goes.
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
static void WriteErrorL(TInt aError);
|
sl@0
|
102 |
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
* Parses the human understandable description of a key usage
|
sl@0
|
105 |
* and returns the corresponding numeric code.
|
sl@0
|
106 |
*
|
sl@0
|
107 |
* @param aUsage The string containing the key usage.
|
sl@0
|
108 |
* @return The corresponding code for the usage.
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
static TKeyUsagePKCS15 ParseKeyUsage(TPtrC aUsage);
|
sl@0
|
111 |
|
sl@0
|
112 |
static CCTKeyInfo::EKeyAccess ParseKeyAccess(TPtrC aAccess);
|
sl@0
|
113 |
|
sl@0
|
114 |
static void PrintCertInfoL(CCTCertInfo& aCertInfo, CCertificate& aCertificate, RArray<TUid> aApps, TBool aTrusted, TBool aIsDetailed = EFalse,TBool aPageWise = EFalse);
|
sl@0
|
115 |
|
sl@0
|
116 |
static const TDesC& Uid2Des(TUid aUid);
|
sl@0
|
117 |
|
sl@0
|
118 |
static RArray<CCTKeyInfo*> MatchKey(RMPointerArray<CCTKeyInfo>& aKeyList, TDesC& aLabel);
|
sl@0
|
119 |
|
sl@0
|
120 |
static void FilterCertsL(RMPointerArray<CCTCertInfo>& aCertList, TDesC& aLabel);
|
sl@0
|
121 |
|
sl@0
|
122 |
static void FilterCertsL(RMPointerArray<CCTCertInfo>& aCertList, TCertificateOwnerType& aOwnerType);
|
sl@0
|
123 |
|
sl@0
|
124 |
static void PrintInfoL(const TDesC& aValue,TBool aPageWise = EFalse);
|
sl@0
|
125 |
|
sl@0
|
126 |
static void SetConsole(CConsoleBase* aConsole);
|
sl@0
|
127 |
|
sl@0
|
128 |
static void SetFile(RFile* aFile);
|
sl@0
|
129 |
|
sl@0
|
130 |
static TBool DoesFileExistsL(const RFs& aFs, const TDesC& aFileName);
|
sl@0
|
131 |
|
sl@0
|
132 |
static CConsoleBase *iConsole;
|
sl@0
|
133 |
|
sl@0
|
134 |
static RFile* iFile;
|
sl@0
|
135 |
};
|
sl@0
|
136 |
#endif
|