os/security/crypto/weakcryptospi/inc/spi/keys.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 * crypto keys definition - including symmetric & asymmetric keys
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @publishedAll
    23  @released
    24 */
    25 
    26 #ifndef __CRYPTOAPI_KEYS_H__
    27 #define __CRYPTOAPI_KEYS_H__
    28 
    29 #include <e32base.h>
    30 #include <cryptospi/cryptoparams.h>
    31 
    32 namespace CryptoSpi
    33 	{
    34 	class CCryptoParam;
    35 	/**
    36 	The key property definition.
    37 	*/
    38 	class TKeyProperty
    39 		{
    40 	public:
    41 		/**
    42 		Algorithm UID of this Key
    43 		*/
    44 		TUid iAlgorithmUid;
    45 
    46 		/**
    47 		Implementation ID of the key generator
    48 		*/
    49 		TUid iImplementationUid;
    50 
    51 		/**
    52 		Key Type
    53 		*/
    54 		TUid iKeyType;
    55 
    56 		/**
    57 		Key Attribute
    58 		*/
    59 		TUid iKeyAttribute;
    60 		};
    61 
    62 
    63 	/**
    64 	The key definition 
    65 	*/
    66 	NONSHARABLE_CLASS(CKey) : public CBase
    67 		{
    68 	public:
    69 
    70 		/**
    71 		Creates a new key from a key property and key parameters.
    72 		@param aKeyProperty	The key property for the new key
    73 		@param aKeyParameters	The list of the key parameters
    74 		@return A pointer to a CKey instance
    75 		*/
    76 		IMPORT_C static CKey* NewL(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters);
    77 
    78 		/**
    79 		Creates a new key from a key property and key parameters.
    80 		Leave the Ckey pointer on the cleanup stack.
    81 		@param aKeyProperty	The key property for the new key
    82 		@param aKeyParameters	The list of the key parameters
    83 		@return A pointer to a CKey instance
    84 		*/
    85 		IMPORT_C static CKey* NewLC(const TKeyProperty& aKeyProperty, const CCryptoParams& aKeyParameters);
    86 
    87 		/**
    88 		Creates a new key from a CKey object.
    89 		@param aKey the source CKey object.
    90 		@return A pointer to a CKey instance
    91 		*/
    92 		IMPORT_C static CKey* NewL(const CKey& aKey);
    93 
    94 		/**
    95 		Creates a new key from a CKey object.
    96 		Leave the Ckey pointer on the cleanup stack.
    97 		@param aKey the source CKey object.
    98 		@return A pointer to a CKey instance
    99 		*/		
   100 		IMPORT_C static CKey* NewLC(const CKey& aKey);
   101 
   102 		/**
   103 		Destructor
   104 		*/
   105 		IMPORT_C ~CKey();
   106 
   107 		/**
   108 		Retrieve the key property
   109 		@return The reference of the key property
   110 		*/
   111 		IMPORT_C const TKeyProperty& KeyProperty() const;
   112 		
   113 		/**
   114 		Retrieve the Key Parameter according to the UID of the parameter
   115 		@param aUid	The UID of the key parameter
   116 		*/
   117 		IMPORT_C const TInteger& GetBigIntL(TUid aUid) const;
   118 		IMPORT_C TInt GetTIntL(TUid aUid) const;
   119 		IMPORT_C const TDesC8& GetTDesC8L(TUid aUid) const;
   120 
   121 		IMPORT_C TBool IsPresent(TUid aUid) const;
   122 
   123 		/**
   124 		Retrieve the key property and key parameter
   125 		@param aKeyProperty	The key property
   126 		@return The key parameters
   127 		*/		
   128 		IMPORT_C const CCryptoParams& KeyParameters() const;
   129 
   130 	private:
   131 		/**
   132 		constructor
   133 		*/
   134 		CKey(const TKeyProperty& aKeyProperty);
   135 
   136 		/**
   137 		2nd Phase Constructor
   138 		*/
   139 		void ConstructL(const CCryptoParams& aKeyParameters);
   140 						
   141 	private:
   142 		/**
   143 		The Key Parameters of this object
   144 		*/
   145 		CCryptoParams* iKeyParameters;
   146 		
   147 		/**
   148 		the key property
   149 		*/
   150 		TKeyProperty iKeyProperty;
   151 		};
   152 
   153 	} // namespace CryptoSpi
   154 
   155 #endif //__CRYPTOAPI_KEYS_H__
   156 
   157