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