First public contribution.
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Generic Key implementation
16 * Generic Key implementation
25 #include <cryptospi/keys.h>
26 #include <cryptospi/cryptoparams.h>
27 #include <cryptospi/cryptospidef.h>
28 #include <cryptopanic.h>
30 using namespace CryptoSpi;
32 EXPORT_C CKey* CKey::NewL(const CKey& aKey)
34 CKey* self=NewLC(aKey);
39 EXPORT_C CKey* CKey::NewLC(const CKey& aKey)
41 CKey* self=new(ELeave) CKey(aKey.iKeyProperty);
42 CleanupStack::PushL(self);
43 self->ConstructL(*aKey.iKeyParameters);
47 EXPORT_C CKey* CKey::NewL(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters)
49 CKey* self=NewLC(aKeyProperty, aKeyParameters);
54 EXPORT_C CKey* CKey::NewLC(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters)
56 CKey* self=new(ELeave) CKey(aKeyProperty);
57 CleanupStack::PushL(self);
58 self->ConstructL(aKeyParameters);
62 EXPORT_C const TKeyProperty& CKey::KeyProperty() const
67 CKey::CKey(const TKeyProperty& aKeyProperty) : iKeyProperty(aKeyProperty)
71 EXPORT_C CKey::~CKey()
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;
78 EXPORT_C const TInteger& CKey::GetBigIntL(TUid aUid) const
80 return iKeyParameters->GetBigIntL(aUid);
83 EXPORT_C TInt CKey::GetTIntL(TUid aUid) const
85 return iKeyParameters->GetTIntL(aUid);
88 EXPORT_C const TDesC8& CKey::GetTDesC8L(TUid aUid) const
90 return iKeyParameters->GetTDesC8L(aUid);
93 EXPORT_C TBool CKey::IsPresent(TUid aUid) const
95 return iKeyParameters->IsPresent(aUid);
98 void CKey::ConstructL(const CCryptoParams& aKeyParameters)
100 iKeyParameters = CCryptoParams::NewL();
101 iKeyParameters->CopyL(aKeyParameters);
104 EXPORT_C const CCryptoParams& CKey::KeyParameters() const
106 return *iKeyParameters;