authenticationservices/authenticationserver/source/server/transientkeyinfo.h
changeset 29 ece3df019add
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
       
     1 /*
       
     2 * Copyright (c) 2005-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 * CTransientKeyInfo declaration
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @released
       
    23  @internalComponent
       
    24 */
       
    25 
       
    26 #ifndef TRANSIENTKEYINFO_H
       
    27 #define TRANSIENTKEYINFO_H
       
    28 
       
    29 #include "transientkey.h"
       
    30 
       
    31 namespace AuthServer
       
    32 {
       
    33 
       
    34 /**
       
    35  * CTransientKeyInfo holds persistent data related to transient keys which it
       
    36  * also generates. The class records the parameters required to (re)generate a
       
    37  * transient key from the plugin data, and is used to link encrypted protection
       
    38  * keys a generated transient key.
       
    39  */
       
    40 class CTransientKeyInfo : public CBase
       
    41 	{
       
    42 public:
       
    43 	/**
       
    44 	 * Sets member data from parameters and randomly initialises the transient
       
    45 	 * key generation parameters. Use this method to create a key
       
    46 	 * for encrypting a new key.
       
    47 	 **/
       
    48 	static CTransientKeyInfo* NewL(TPluginId  aPluginId);
       
    49 
       
    50 	/**
       
    51 	 * Sets member data from parameters and randomly initialises the transient
       
    52 	 * key generation parameters. Use this method to create a key
       
    53 	 * for encrypting a new key.
       
    54 	 **/
       
    55 	static CTransientKeyInfo* NewLC(TPluginId  aPluginId);
       
    56 
       
    57 	/**
       
    58 	 * Reads all data from the input stream. Use this method to recreate a key
       
    59 	 * used to encrypt a key.
       
    60 	 **/
       
    61 	static CTransientKeyInfo* NewL(RReadStream& aInputStream);
       
    62 	
       
    63 	/**
       
    64 	 * Reads all data from the input stream. Use this method to recreate a key
       
    65 	 * used to encrypt a key.
       
    66 	 **/
       
    67 	static CTransientKeyInfo* NewLC(RReadStream& aInputStream);
       
    68 
       
    69 	~CTransientKeyInfo();
       
    70 
       
    71 	/**
       
    72 	 * @return the id of the plugin that was used to generate the transient
       
    73 	 * key.
       
    74 	 **/
       
    75 	TPluginId PluginId() const;
       
    76 
       
    77 	/**
       
    78 	 * @return the encrypted protection key
       
    79 	 * key.
       
    80 	 **/
       
    81 	const CEncryptedProtectionKey& EncryptedKey() const;
       
    82 
       
    83     /**
       
    84 	 * Assign the encrypted protection key associated with the transient
       
    85 	 * key. Ownership of the key is taken by this object.
       
    86  	 *
       
    87 	 * @param aEncryptedKey the protection key encrypted with this transient key.
       
    88 	 **/
       
    89     void SetEncryptedProtectionKeyL(CEncryptedProtectionKey* aEncryptedKey);
       
    90 	  
       
    91 	/**
       
    92 	 * Create transient key using the plugin data. If this object was created
       
    93 	 * from a stream the method will leave with KErrBadPassword if the plugin
       
    94 	 * data does not match the original. Ownership of the CTransientKey object
       
    95 	 * is returned to the caller.
       
    96 	 **/ 
       
    97 	CTransientKey* CreateTransientKeyL(const TDesC8& aPluginData) const;
       
    98 
       
    99 	/**
       
   100 	 *
       
   101 	 **/
       
   102 	void ExternalizeL(RWriteStream& aOutStream) const;
       
   103 
       
   104 private:
       
   105 	
       
   106     void ConstructL(TPluginId aPluginId);
       
   107     void InternalizeL(RReadStream& aInStream);
       
   108 
       
   109 	/// the id of the plugin that encrypted the key
       
   110 	TPluginId iPluginId;
       
   111 		
       
   112 	/// the encrypted protection key
       
   113 	CEncryptedProtectionKey* iEncryptedKey;
       
   114 	
       
   115 	/// the encryption parameters
       
   116 	mutable CPBEncryptionData* iEncryptionData;
       
   117     };
       
   118 }
       
   119 
       
   120 #endif // TRANSIENTKEYINFO_H