cryptoservices/certificateandkeymgmt/inc/pkcs12safebag.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @publishedPartner
       
    24  @released
       
    25 */
       
    26 
       
    27 #ifndef __PKCS12_SAFE_BAG_H__
       
    28 #define __PKCS12_SAFE_BAG_H__
       
    29 
       
    30 #include <asn1dec.h>
       
    31 #include <pkcs12attribute.h>
       
    32 
       
    33 namespace PKCS12
       
    34 {
       
    35 class CDecPkcs12Attribute;
       
    36 
       
    37 /**
       
    38  This class is the base class for all the bags and decodes the SafeBag.
       
    39  SafeBag has BagId, BagValue, and BagAttributes.
       
    40  
       
    41  BagId's are in the form of an Object Identifiers
       
    42  OID ----  1.2.840.113549.1.12.10.1.1 keybag
       
    43  OID ----  1.2.840.113549.1.12.10.1.2 shroudedKeyBag
       
    44  OID ----  1.2.840.113549.1.12.10.1.3 certBag
       
    45  OID ----  1.2.840.113549.1.12.10.1.4 crlBag
       
    46  OID ----  1.2.840.113549.1.12.10.1.5 SecretBag
       
    47  OID ----  1.2.840.113549.1.12.10.1.6 SafeContentsBag
       
    48  **/	
       
    49 class CDecPkcs12SafeBag	: public CBase
       
    50 	{
       
    51 public:
       
    52 	enum TBagId
       
    53 	/**
       
    54 	 Identifies the type of Bag present in the PKCS#12 safeBag structure.
       
    55 	 */
       
    56 		{
       
    57 		/** The numeric value of last element in the PKCS#12 KeyBag OID */
       
    58 		EKeyBag = 1,
       
    59 		
       
    60 		/** The numeric value of last element in the PKCS#12 ShroudedKeyBag OID */
       
    61 		EShroudedKeyBag,
       
    62 		
       
    63 		/** The numeric value of last element in the PKCS#12 CertBag OID */
       
    64 		ECertBag,
       
    65 		
       
    66 		/** The numeric value of last element in the PKCS#12 CRLBag OID */
       
    67 		ECrlBag,
       
    68 		
       
    69 		/** The numeric value of last element in the PKCS#12 SecretBag OID */
       
    70 		ESecretBag,
       
    71 		
       
    72 		/** The numeric value of last element in the PKCS#12 SafeContentsBag OID */
       
    73 		ESafeContentsBag
       
    74 		};
       
    75 	/**
       
    76 	 Creates a new PKCS#12SafeBag object.
       
    77 	  
       
    78 	 @param aSafeBagData contains a PKCS#12 SafeBag Structure
       
    79 	 @return A pointer to the newly allocated object.
       
    80 	 @leave  KErrArgument if the data is not Pkcs12 safeBag structure.
       
    81 	 */
       
    82     IMPORT_C static CDecPkcs12SafeBag* NewL(const TDesC8& aSafeBagData);
       
    83     
       
    84 	/**
       
    85 	 The BagId present in the SafeBag.
       
    86 	 BagID is an ObjectIdentifier which identifies the Type of bag present
       
    87 	 inside the SafeBag.
       
    88 	 @return BagID present within the SafeBag
       
    89 	 */
       
    90      IMPORT_C TBagId BagID() const ; 
       
    91     
       
    92 	/**
       
    93 	 This method returns the BagValue present in the Safe Bag.
       
    94 	 @return BagValue present within the SafeBag
       
    95 	 */
       
    96      IMPORT_C const TDesC8& BagValue() const ;
       
    97     
       
    98 	/**
       
    99 	 This method returns an array of BagAttributes.
       
   100 	 BagAttributes is an Optional field. It allows users to assign nicknames
       
   101 	 and identifiers to keys, etc., and permits visual tools to display 
       
   102 	 meaningful strings of some sort to the user.
       
   103 	 @return an array of BagAttributes present within the SafeBag.
       
   104 	 @see CDecPkcs12Attribute
       
   105 	 */
       
   106      IMPORT_C const RPointerArray<CDecPkcs12Attribute>& BagAttributes() const ;
       
   107         
       
   108     /**
       
   109 	 Destructor.
       
   110 	 */
       
   111 	IMPORT_C ~CDecPkcs12SafeBag();
       
   112     
       
   113 protected:
       
   114 	/**
       
   115 	 * @internalComponent
       
   116 	 *
       
   117 	 * This decodes the entire safeBag structure.
       
   118 	 * @param aRawData contains a PKCS#12 safeBag Structure.
       
   119 	 * @leave  KErrArgument if the data is not Pkcs12 safeBag structure.
       
   120 	 * @see CDecPkcs12Attribute
       
   121 	 **/
       
   122 	void ConstructL(const TDesC8& aRawData);	
       
   123 	
       
   124 	/**
       
   125 	 * @internalComponent
       
   126 	 *
       
   127 	 * Constructor.
       
   128 	 **/
       
   129 	CDecPkcs12SafeBag();
       
   130 	
       
   131 	/**
       
   132 	 * @internalComponent
       
   133 	 *
       
   134 	 * Copy Constructor.
       
   135 	 * @param aDecPkcs12safeBag A CDecPkcs12SafeBag object.
       
   136 	 **/
       
   137 	CDecPkcs12SafeBag(const CDecPkcs12SafeBag& aDecPkcs12safeBag);
       
   138 	
       
   139 	/**
       
   140 	 * @internalComponent
       
   141 	 *
       
   142 	 * Assignment operator.
       
   143 	 * @param aDecPkcs12safeBag A CDecPkcs12SafeBag object.
       
   144 	 * @return A reference to CDecPkcs12SafeBag class.
       
   145 	 **/
       
   146 	CDecPkcs12SafeBag& operator=(const CDecPkcs12SafeBag& aDecPkcs12safeBag);
       
   147 	
       
   148 protected:
       
   149  	/** Contains the BagId. That is ObjectIdentifier for SafeContents Bag */
       
   150 	TBagId iBagId;
       
   151 	
       
   152 	/** Contains the BagValue */
       
   153 	TPtrC8 iBagValue;
       
   154 	
       
   155 	/* contains the BagAttributes */
       
   156 	RPointerArray <CDecPkcs12Attribute> iBagAttributes;
       
   157 	};
       
   158 } // namespace PKCS12
       
   159 #endif // __PKCS12_SAFE_BAG_H__