os/security/crypto/weakcryptospi/source/spi/keys.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* Generic Key implementation
sl@0
    16
* Generic Key implementation
sl@0
    17
*
sl@0
    18
*/
sl@0
    19
sl@0
    20
sl@0
    21
/**
sl@0
    22
 @file
sl@0
    23
*/
sl@0
    24
sl@0
    25
#include <cryptospi/keys.h>
sl@0
    26
#include <cryptospi/cryptoparams.h>
sl@0
    27
#include <cryptospi/cryptospidef.h>
sl@0
    28
#include <cryptopanic.h>
sl@0
    29
sl@0
    30
using namespace CryptoSpi;
sl@0
    31
sl@0
    32
EXPORT_C CKey* CKey::NewL(const CKey& aKey)
sl@0
    33
	{
sl@0
    34
	CKey* self=NewLC(aKey);
sl@0
    35
	CleanupStack::Pop();
sl@0
    36
	return self;
sl@0
    37
	}
sl@0
    38
sl@0
    39
EXPORT_C CKey* CKey::NewLC(const CKey& aKey)
sl@0
    40
	{
sl@0
    41
	CKey* self=new(ELeave) CKey(aKey.iKeyProperty);
sl@0
    42
	CleanupStack::PushL(self);
sl@0
    43
	self->ConstructL(*aKey.iKeyParameters);
sl@0
    44
	return self;
sl@0
    45
	}
sl@0
    46
sl@0
    47
EXPORT_C CKey* CKey::NewL(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters)
sl@0
    48
	{
sl@0
    49
	CKey* self=NewLC(aKeyProperty, aKeyParameters);
sl@0
    50
	CleanupStack::Pop();
sl@0
    51
	return self;
sl@0
    52
	}
sl@0
    53
sl@0
    54
EXPORT_C CKey* CKey::NewLC(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters)
sl@0
    55
	{
sl@0
    56
	CKey* self=new(ELeave) CKey(aKeyProperty);
sl@0
    57
	CleanupStack::PushL(self);
sl@0
    58
	self->ConstructL(aKeyParameters);
sl@0
    59
	return self;
sl@0
    60
	}
sl@0
    61
	
sl@0
    62
EXPORT_C const TKeyProperty& CKey::KeyProperty() const
sl@0
    63
	{
sl@0
    64
	return iKeyProperty;
sl@0
    65
	}
sl@0
    66
	
sl@0
    67
CKey::CKey(const TKeyProperty& aKeyProperty) : iKeyProperty(aKeyProperty)
sl@0
    68
	{
sl@0
    69
	}
sl@0
    70
sl@0
    71
EXPORT_C CKey::~CKey()
sl@0
    72
	{
sl@0
    73
	// The destructors for each CCryptoParam in this array should securely
sl@0
    74
	// delete their contents, e.g. RSA/DSA BigInt exponent and modulus.
sl@0
    75
	delete iKeyParameters;
sl@0
    76
	}
sl@0
    77
sl@0
    78
EXPORT_C const TInteger& CKey::GetBigIntL(TUid aUid) const
sl@0
    79
	{
sl@0
    80
	return iKeyParameters->GetBigIntL(aUid);
sl@0
    81
	}
sl@0
    82
sl@0
    83
EXPORT_C TInt CKey::GetTIntL(TUid aUid) const
sl@0
    84
	{
sl@0
    85
	return iKeyParameters->GetTIntL(aUid);
sl@0
    86
	}
sl@0
    87
sl@0
    88
EXPORT_C const TDesC8& CKey::GetTDesC8L(TUid aUid) const
sl@0
    89
	{
sl@0
    90
	return iKeyParameters->GetTDesC8L(aUid);
sl@0
    91
	}
sl@0
    92
sl@0
    93
EXPORT_C TBool CKey::IsPresent(TUid aUid) const
sl@0
    94
	{
sl@0
    95
	return iKeyParameters->IsPresent(aUid);
sl@0
    96
	}
sl@0
    97
sl@0
    98
void CKey::ConstructL(const CCryptoParams& aKeyParameters)
sl@0
    99
	{
sl@0
   100
	iKeyParameters = CCryptoParams::NewL();
sl@0
   101
	iKeyParameters->CopyL(aKeyParameters);
sl@0
   102
	}
sl@0
   103
sl@0
   104
EXPORT_C const CCryptoParams& CKey::KeyParameters() const
sl@0
   105
	{
sl@0
   106
	return *iKeyParameters;
sl@0
   107
	}
sl@0
   108
sl@0
   109