authenticationservices/authenticationserver/source/server/transientkey.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 24 Nov 2009 09:06:03 +0200
changeset 29 ece3df019add
permissions -rw-r--r--
Revision: 200948 Kit: 200948

/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
* CTransientKey declaration
*
*/


/**
 @file 
 @released
 @internalComponent
*/

#ifndef TRANSIENTKEY_H
#define TRANSIENTKEY_H

#include <pbe.h>
#include "authserver_client.h"
#include "encryptedprotectionkey.h"

namespace AuthServer
{

/**
 * CTransientKey is a cryptographic key that is generated on the fly and never
 * stored on the device.  Transient keys are used to encrypt and decrypt
 * protection keys, they are generated by the AuthServer using data gathered
 * from CAuthPlugin derived classes.
 */
class CTransientKey : public CBase
	{
public:
	
	/**
	 * Creates a new transient key, passing in the plugin data from which to
	 * derive it.
	 *
	 * @param aEncryptor encryption element to use as the key. Ownership
	 * passes to this object.
	 **/
	static CTransientKey* NewL(CPBEncryptElement* aEncryptor);

	/**
	 * Creates a new transient key, passing in the plugin data from which to
	 * derive it.
	 *
	 * @param aEncryptor encryption element to use as the key. Ownership
	 * passes to this object.
	 **/
	static CTransientKey* NewLC(CPBEncryptElement* aEncryptor);

	~CTransientKey();

	/**
	 * Create an version of the provided protection key encrypted by this
	 * key. Ownership of the returned object is passed to the caller.
	 *
	 * @param aKey the protection key to encrypt.
	 *
	 * @return an protection key encrypted by this key.
	 **/
	CEncryptedProtectionKey* EncryptL(const CProtectionKey& aKey) const;

	/**
	 * Decrypts an CEncryptedProtectionKey created by this transient
	 * key. Ownership of the returned object is passed to the caller.
	 *
	 * @param aKey the encrypted protection key to decrypt.
	 *
	 * @return a protection key
	 **/
	CProtectionKey* DecryptL(const CEncryptedProtectionKey& aKey) const;

		
private:
	void ConstructL(CPBEncryptElement* aEncryptor);
	
	CPBEncryptElement* iPbeElement;
    };
}

#endif // TRANSIENTKEY_H