|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-A56D550A-BF08-5D9C-A64C-67E8654F449B" xml:lang="en"><title>Creating |
|
13 Keys</title><shortdesc>This section explains how to create a key using the keystore. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
14 <context><p>Before you create a key, you must know which keystore the new |
|
15 key must be stored in. See <xref href="GUID-1733B4E1-3264-58DF-957B-F5C0AE1E0644.dita">Retrieving |
|
16 Keystores</xref> for more information. </p><p>The following steps explain |
|
17 the process of creating a key:</p> </context> |
|
18 <steps id="GUID-5947641D-B308-5E35-B6E1-1E9561A8495B"> |
|
19 <step id="GUID-75536534-0982-54E0-BF52-0BC3DE8A2200"><cmd/> |
|
20 <info>Create a file system session using an <xref href="GUID-E263C747-946F-35AA-9F1D-41833BD350FC.dita"><apiname>RFs</apiname></xref> object. </info> |
|
21 </step> |
|
22 <step id="GUID-7648129E-7206-5C6A-BDDC-F3AA0A930B87"><cmd/> |
|
23 <info>Create an object of type CUnifiedKeyStore using <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-C7A96153-4179-3B3F-878D-1EAA64A98D39"><apiname>CUnifiedKeyStore::NewL()</apiname></xref> or <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-217FBB3B-CEF5-36F2-A612-EDDA0982053C"><apiname>CUnifiedKeyStore::NewLC()</apiname></xref>. </info> |
|
24 </step> |
|
25 <step id="GUID-6DEAD07A-5AAE-5876-B1EF-3728C8C4EB07"><cmd/> |
|
26 <info>Initialise the member functions and keystore using the asynchronous |
|
27 function <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-6C5D732C-1FD1-3EF0-AC90-87690F891B8D"><apiname>CUnifiedKeyStore::Initialize()</apiname></xref>. </info> |
|
28 </step> |
|
29 <step id="GUID-EE225F78-78B5-54B8-82A7-CCC8A5DBAF01"><cmd/> |
|
30 <info>Create a key using <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-F4546E33-BCE9-330A-913A-88A0253EF498"><apiname>CUnifiedKeyStore::CreateKey()</apiname></xref>. </info> |
|
31 </step> |
|
32 </steps> |
|
33 <result><p>A new key is created and stored in the selected keystore. </p> </result> |
|
34 <example><title>Example</title> <p>The following code snippet shows how to |
|
35 set a file system session object, initialise keystore and member functions, |
|
36 and create a key. </p> <codeblock id="GUID-6A28C0E5-2708-5875-976B-F319DDC2148F" xml:space="preserve">//Create a file system session object |
|
37 RFs iFs; |
|
38 CleanupClosePushL(&iFs); |
|
39 |
|
40 |
|
41 //Initialise the keystore and member functions |
|
42 CUnifiedKeyStore* keyStore = CUnifiedKeyStore::NewL(iFs); |
|
43 keyStore->Initialize(iStatus); //iStatus is a TRequestStatus object |
|
44 |
|
45 |
|
46 //Initialise the arguments to be passed into the CreateKey() function |
|
47 TKeyUsagePKCS15 usage = EPKCS15UsageSign | EPKCS15UsageSignRecover; |
|
48 TUint keysize = 512; |
|
49 _LIT(KLabel,”keylabel”); |
|
50 CCTKeyInfo::EKeyAlgorithm algorithm = CCTKeyInfo::EDSA; |
|
51 TInt accessType = CCTKeyInfo::EExtractable; |
|
52 TTime startDate, endDate; |
|
53 startDate.HomeTime(); |
|
54 endDate.HomeTime(); |
|
55 |
|
56 |
|
57 // Create a pointer for data returned by CreateKey() |
|
58 CCTKeyInfo* keyInfo; |
|
59 |
|
60 //Create the key |
|
61 keyStore->CreateKey(0, usage, keysize, KLabel, algorithm, |
|
62 accessType, startDate, endDate, keyInfo, iStatus); |
|
63 |
|
64 |
|
65 //Clean up |
|
66 CleanupStack::PopAndDestroy(); // iFs</codeblock> </example> |
|
67 </taskbody><related-links> |
|
68 <link href="GUID-C4389D60-2A8D-532D-9D92-E57B0CCD14CF.dita"><linktext>Unified Keystore</linktext> |
|
69 </link> |
|
70 </related-links></task> |