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