|
1 /* |
|
2 * Copyright (c) 2006-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 * Generic Key implementation |
|
16 * Generic Key implementation |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 |
|
25 #include "keys.h" |
|
26 #include <cryptospi/cryptoparams.h> |
|
27 #include <cryptospi/cryptospidef.h> |
|
28 #include <cryptopanic.h> |
|
29 |
|
30 using namespace CryptoSpi; |
|
31 |
|
32 EXPORT_C CKey* CKey::NewL(const CKey& aKey) |
|
33 { |
|
34 CKey* self=NewLC(aKey); |
|
35 CleanupStack::Pop(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 EXPORT_C CKey* CKey::NewLC(const CKey& aKey) |
|
40 { |
|
41 CKey* self=new(ELeave) CKey(aKey.iKeyProperty); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(*aKey.iKeyParameters); |
|
44 return self; |
|
45 } |
|
46 |
|
47 EXPORT_C CKey* CKey::NewL(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters) |
|
48 { |
|
49 CKey* self=NewLC(aKeyProperty, aKeyParameters); |
|
50 CleanupStack::Pop(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 EXPORT_C CKey* CKey::NewLC(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters) |
|
55 { |
|
56 CKey* self=new(ELeave) CKey(aKeyProperty); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(aKeyParameters); |
|
59 return self; |
|
60 } |
|
61 |
|
62 EXPORT_C const TKeyProperty& CKey::KeyProperty() const |
|
63 { |
|
64 return iKeyProperty; |
|
65 } |
|
66 |
|
67 CKey::CKey(const TKeyProperty& aKeyProperty) : iKeyProperty(aKeyProperty) |
|
68 { |
|
69 } |
|
70 |
|
71 EXPORT_C CKey::~CKey() |
|
72 { |
|
73 // The destructors for each CCryptoParam in this array should securely |
|
74 // delete their contents, e.g. RSA/DSA BigInt exponent and modulus. |
|
75 delete iKeyParameters; |
|
76 } |
|
77 |
|
78 EXPORT_C const TInteger& CKey::GetBigIntL(TUid aUid) const |
|
79 { |
|
80 return iKeyParameters->GetBigIntL(aUid); |
|
81 } |
|
82 |
|
83 EXPORT_C TInt CKey::GetTIntL(TUid aUid) const |
|
84 { |
|
85 return iKeyParameters->GetTIntL(aUid); |
|
86 } |
|
87 |
|
88 EXPORT_C const TDesC8& CKey::GetTDesC8L(TUid aUid) const |
|
89 { |
|
90 return iKeyParameters->GetTDesC8L(aUid); |
|
91 } |
|
92 |
|
93 EXPORT_C TBool CKey::IsPresent(TUid aUid) const |
|
94 { |
|
95 return iKeyParameters->IsPresent(aUid); |
|
96 } |
|
97 |
|
98 void CKey::ConstructL(const CCryptoParams& aKeyParameters) |
|
99 { |
|
100 iKeyParameters = CCryptoParams::NewL(); |
|
101 iKeyParameters->CopyL(aKeyParameters); |
|
102 } |
|
103 |
|
104 EXPORT_C const CCryptoParams& CKey::KeyParameters() const |
|
105 { |
|
106 return *iKeyParameters; |
|
107 } |
|
108 |
|
109 |