|
1 /* |
|
2 * Copyright (c) 2010 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 "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: VPN Agile provision Crypto library |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __AGILE_CRYPTO_H |
|
19 #define __AGILE_CRYPTO_H |
|
20 |
|
21 #include "pkiserviceapi.h" |
|
22 |
|
23 |
|
24 const TInt KAgileCryptoMaxSignatureLth = 512; //publicKey->Size() / 8; |
|
25 |
|
26 typedef TPKIKeyIdentifier TPrivKeyRef; |
|
27 typedef HBufC8* TRetBufCertReq; |
|
28 typedef HBufC8* TRetBufCertRef; |
|
29 typedef TInt TErrCode; |
|
30 |
|
31 // --- agile crypto error codes |
|
32 const TInt KAgileErrCryptoCertFileNotFound = -102101; |
|
33 const TInt KAgileErrCryptoReadCertRequestFailed = -102103; |
|
34 |
|
35 |
|
36 class CAgileCryptoCert : public CBase |
|
37 /** |
|
38 * Certificate operations |
|
39 * @internalComponent |
|
40 */ |
|
41 { |
|
42 public: |
|
43 |
|
44 |
|
45 IMPORT_C static CAgileCryptoCert* NewL(const TDesC8& aCert, TBool aBase64Encoded); |
|
46 IMPORT_C ~CAgileCryptoCert(); //agile_crypto_cert_free |
|
47 |
|
48 IMPORT_C void SaveCACertL(void); |
|
49 IMPORT_C void SaveClientCertL(const TPrivKeyRef& aKeyId, TUint aKeySize); |
|
50 |
|
51 private: |
|
52 CAgileCryptoCert(); |
|
53 |
|
54 void ConstructL(const TDesC8& aCert, TBool aBase64Encoded); |
|
55 |
|
56 |
|
57 private: |
|
58 HBufC8 *iCertDER; |
|
59 |
|
60 }; |
|
61 |
|
62 class CAgileCryptoGenerateKeypair; |
|
63 class CAgileCryptoPrivKey : public CBase |
|
64 /** |
|
65 * Private key operations |
|
66 * @internalComponent |
|
67 */ |
|
68 { |
|
69 public: |
|
70 //friend class CAgileCryptoGenerateKeypair; |
|
71 |
|
72 IMPORT_C static CAgileCryptoPrivKey* NewL(void); |
|
73 IMPORT_C ~CAgileCryptoPrivKey(); |
|
74 |
|
75 |
|
76 IMPORT_C void GenerateCertReqL(const TDesC8& aDistinguishedName, |
|
77 const TDesC8& aSubjectAltNameRfc822, |
|
78 const TDesC8& aChallengePassword, |
|
79 const TDesC8& aDnsName, |
|
80 const TPrivKeyRef& aKeyId, |
|
81 TDes& aCertReqRef, |
|
82 TInt& aCertReqSize); //agile_crypto_generate_cert_req_pem |
|
83 IMPORT_C TRetBufCertReq ReadCertReqL(const TDesC& aCertReqRef, TInt aCertReqSize); |
|
84 |
|
85 RPKIServiceAPI GetPkiService(); |
|
86 |
|
87 private: |
|
88 CAgileCryptoPrivKey(); |
|
89 void ConstructL(void); |
|
90 |
|
91 |
|
92 private: |
|
93 RPKIServiceAPI iPkiServiceApi; |
|
94 }; |
|
95 |
|
96 |
|
97 class CAgileCryptoGenerateKeypair : public CBase |
|
98 /** |
|
99 * Generate key pair |
|
100 * @internalComponent |
|
101 */ |
|
102 { |
|
103 public: |
|
104 IMPORT_C static CAgileCryptoGenerateKeypair* NewL(CAgileCryptoPrivKey* aAgileCryptoPrivKey); |
|
105 IMPORT_C TErrCode GenerateKeypairL(const TInt& aPublicKeyLen, |
|
106 TPrivKeyRef& aKeyId, |
|
107 TRequestStatus& aStatus); |
|
108 IMPORT_C void GenerateKeypairCancel(void); |
|
109 |
|
110 |
|
111 private: |
|
112 CAgileCryptoGenerateKeypair(CAgileCryptoPrivKey* aAgileCryptoPrivKey); |
|
113 void ConstructL(void); |
|
114 |
|
115 private: |
|
116 CAgileCryptoPrivKey* iAgileCryptoPrivKey; |
|
117 |
|
118 }; |
|
119 |
|
120 #endif |