epoc32/include/pkcs10attr.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
* PKCS#10 Certificate Request Attributes class.
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
/**
williamr@2
    23
 @file
williamr@2
    24
 @publishedPartner
williamr@2
    25
 @released 
williamr@2
    26
*/
williamr@2
    27
williamr@2
    28
#if !defined (__PKCS10ATTR_H__)
williamr@2
    29
#define __PKCS10ATTR_H__
williamr@2
    30
williamr@2
    31
class CASN1EncBase;
williamr@2
    32
class CASN1EncSequence;
williamr@2
    33
williamr@2
    34
//
williamr@2
    35
// Class capturing common functionality of a PKCS attribute.
williamr@2
    36
//
williamr@2
    37
class CPKCSAttributeBase : public CBase
williamr@2
    38
	{
williamr@2
    39
public:
williamr@2
    40
williamr@2
    41
	/** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
williamr@2
    42
		leaving it on the cleanup stack.  This is called by CPKCS10Attribtues
williamr@2
    43
		when AddAttribute() is called. 
williamr@2
    44
		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
williamr@2
    45
		@return ASN.1 encoding object
williamr@2
    46
	*/
williamr@2
    47
	virtual CASN1EncBase* GetEncodingLC() = 0;
williamr@2
    48
williamr@2
    49
	virtual ~CPKCSAttributeBase();
williamr@2
    50
williamr@2
    51
protected:
williamr@2
    52
	/** @internalComponent */
williamr@2
    53
	CPKCSAttributeBase();
williamr@2
    54
	CASN1EncSequence* iRoot;
williamr@2
    55
	CASN1EncSet* iValueSet;
williamr@2
    56
	};
williamr@2
    57
williamr@2
    58
/** Class representing a generic certificate attribute.  Attributes have an
williamr@2
    59
	object identifier and one or more values.
williamr@2
    60
*/
williamr@2
    61
class CPKCS10Attribute : public CPKCSAttributeBase
williamr@2
    62
	{
williamr@2
    63
public:
williamr@2
    64
williamr@2
    65
	/** Create an attribute with a specified OID and no values, leaving it on
williamr@2
    66
		the cleanup stack.
williamr@2
    67
		NOTE: This method is deprecated. Use the other forms of NewLC instead.
williamr@2
    68
		@param aAttrOID	The specified OID in the form a.b.c. etc.
williamr@2
    69
		@return New PKCS10 attribute object on the cleanup stack
williamr@2
    70
		@deprecated
williamr@2
    71
	*/
williamr@2
    72
	IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID);
williamr@2
    73
williamr@2
    74
	/** Create an attribute with a specified OID and one value, leaving it on
williamr@2
    75
		the cleanup stack. The value forms part of a set. Additional values can
williamr@2
    76
		be added by calling the AddValueL method.
williamr@2
    77
		@param aAttrOID	The specified OID in the form a.b.c. etc.
williamr@2
    78
		@param aASN1	ASN1 encoding object for attribute value
williamr@2
    79
		 				-- this method takes ownership.
williamr@2
    80
		@return New PKCS10 attribute object on the cleanup stack
williamr@2
    81
	*/
williamr@2
    82
	IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID, CASN1EncBase* aASN1);
williamr@2
    83
williamr@2
    84
	/** Create an attribute with a specified OID and one value. The value forms 
williamr@2
    85
		part of a set. Additional values can be added by calling the AddValueL method.
williamr@2
    86
		@param aAttrOID	The specified OID in the form a.b.c. etc.
williamr@2
    87
		@param aASN1	ASN1 encoding object for attribute value
williamr@2
    88
		 				-- this method takes ownership.
williamr@2
    89
		@return New PKCS10 attribute object
williamr@2
    90
	*/
williamr@2
    91
	IMPORT_C static CPKCS10Attribute* NewL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
williamr@2
    92
williamr@2
    93
	/** Add a value to the attribute.
williamr@2
    94
		@param aASN1	ASN1 encoding object for attribute value
williamr@2
    95
		 				-- this method takes ownership.
williamr@2
    96
	*/
williamr@2
    97
	IMPORT_C void AddValueL(CASN1EncBase* aASN1);
williamr@2
    98
williamr@2
    99
	/** ResetL method to allow for re-use of the generic attribute object. 
williamr@2
   100
		Additional values can be added by calling the AddValueL method.
williamr@2
   101
		@param aAttrOID	The specified OID in the form a.b.c. etc.
williamr@2
   102
		@param aASN1	ASN1 encoding object for attribute value
williamr@2
   103
		 				-- this method takes ownership.
williamr@2
   104
	*/
williamr@2
   105
	IMPORT_C void ResetL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
williamr@2
   106
williamr@2
   107
	virtual ~CPKCS10Attribute();
williamr@2
   108
williamr@2
   109
	/** 
williamr@2
   110
	 * @internalComponent
williamr@2
   111
	 *
williamr@2
   112
	 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
williamr@2
   113
		leaving it on the cleanup stack. This is called by CPKCS10Attribtues
williamr@2
   114
		when AddAttribute() is called. This method may leave with E32USER-CBase:66 
williamr@2
   115
		if a stack frame for the next PushL() cannot be allocated.
williamr@2
   116
		NOTE: This method is deprecated. Use GetEncodingLC() instead.
williamr@2
   117
		@deprecated
williamr@2
   118
	*/
williamr@2
   119
	CASN1EncBase* TakeEncodingC();
williamr@2
   120
williamr@2
   121
	/** 
williamr@2
   122
	 * @internalComponent
williamr@2
   123
	 *
williamr@2
   124
	 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
williamr@2
   125
		leaving it on the cleanup stack.  This is called by CPKCS10Attribtues
williamr@2
   126
		when AddAttribute() is called. This method may leave with E32USER-CBase:66 
williamr@2
   127
		if a stack frame for the next PushL() cannot be allocated.
williamr@2
   128
		NOTE: This method is deprecated. Use GetEncodingLC() instead.
williamr@2
   129
		@deprecated
williamr@2
   130
	*/
williamr@2
   131
	CASN1EncBase* TakeEncodingLC();
williamr@2
   132
williamr@2
   133
	/** Calls the base class implementation for getting the ASN1 encoding of the attribute.
williamr@2
   134
		Note that this method cannot be reused unless ResetL() has been called. 
williamr@2
   135
		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
williamr@2
   136
		@return ASN.1 encoding object
williamr@2
   137
	*/
williamr@2
   138
	virtual CASN1EncBase* GetEncodingLC();
williamr@2
   139
williamr@2
   140
private:
williamr@2
   141
	// Default constructor.
williamr@2
   142
	CPKCS10Attribute();
williamr@2
   143
williamr@2
   144
	// Second phase construction function.
williamr@2
   145
	void ConstructL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
williamr@2
   146
	};
williamr@2
   147
williamr@2
   148
/** Class for encoding a collection of certificate attributes and passing them
williamr@2
   149
	to the CPKCS10Request class. Some possible attributes are described in
williamr@2
   150
	PKCS#9.
williamr@2
   151
  
williamr@2
   152
	@publishedPartner
williamr@2
   153
	@released
williamr@2
   154
*/
williamr@2
   155
class CPKCS10Attributes : public CBase
williamr@2
   156
	{
williamr@2
   157
public:
williamr@2
   158
	/** Creates an instance of the class.
williamr@2
   159
		@return New attributes object on the cleanup stack.
williamr@2
   160
	*/
williamr@2
   161
	IMPORT_C static CPKCS10Attributes* NewLC();
williamr@2
   162
williamr@2
   163
	/** Creates an instance of the class.
williamr@2
   164
		@return New attributes object.
williamr@2
   165
	*/
williamr@2
   166
	IMPORT_C static CPKCS10Attributes* NewL();
williamr@2
   167
williamr@2
   168
	/** Adds a new attribute for the certificate request.
williamr@2
   169
		@param aAttr The attribute to add - this method takes ownership.
williamr@2
   170
		@deprecated
williamr@2
   171
	*/
williamr@2
   172
	IMPORT_C void AddAttributeL(CPKCS10Attribute* aAttr);
williamr@2
   173
williamr@2
   174
	/** Adds a new attribute for the certificate request.
williamr@2
   175
		@param aAttr The attribute to add - this method takes ownership.
williamr@2
   176
	*/
williamr@2
   177
	IMPORT_C void AddPKCSAttributeL(CPKCSAttributeBase* aAttr);
williamr@2
   178
williamr@2
   179
	IMPORT_C ~CPKCS10Attributes(); // virtual from base
williamr@2
   180
williamr@2
   181
	/** 
williamr@2
   182
	 * @internalComponent
williamr@2
   183
	 *
williamr@2
   184
	 * Get the ASN1 encoding of the attributes and relinquish ownership of it,
williamr@2
   185
		leaving it on the cleanup stack. This is called by CPKCS10Request when
williamr@2
   186
		SetAttributes() is called. This method may leave with E32USER-CBase:66 
williamr@2
   187
		if a stack frame for the next PushL() cannot be allocated.
williamr@2
   188
		@deprecated
williamr@2
   189
	*/
williamr@2
   190
	CASN1EncBase* TakeEncodingC();
williamr@2
   191
williamr@2
   192
	/** 
williamr@2
   193
	 * @internalComponent
williamr@2
   194
	 *
williamr@2
   195
	 * Get the ASN.1 encoding of the attribute and relinquish ownership of it,
williamr@2
   196
		leaving it on the cleanup stack. This is called by CPKCS10Request when
williamr@2
   197
		SetAttributes() is called. 
williamr@2
   198
		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
williamr@2
   199
		@return ASN.1 encoding object
williamr@2
   200
	*/
williamr@2
   201
	CASN1EncBase* TakeEncodingLC();
williamr@2
   202
williamr@2
   203
private:
williamr@2
   204
	/** Default constructor.
williamr@2
   205
	*/
williamr@2
   206
	CPKCS10Attributes();
williamr@2
   207
williamr@2
   208
	/** Second phase construction function. 
williamr@2
   209
		@note The structure of the attribute node is as follows:
williamr@2
   210
		@code
williamr@2
   211
		  SET
williamr@2
   212
		    SEQUENCE
williamr@2
   213
			  OID of attribute
williamr@2
   214
			  SET values
williamr@2
   215
			...
williamr@2
   216
		@endcode
williamr@2
   217
	*/
williamr@2
   218
	void ConstructL();
williamr@2
   219
	
williamr@2
   220
private:
williamr@2
   221
	/** Pointer to sequence of user-supplied certificate attributes. 
williamr@2
   222
		#AddAttributeL method is used to create and fill this member. 
williamr@2
   223
		If it is initialized by the time #CalculateEncodingL method 
williamr@2
   224
		is called, the latter uses attributes from this member variable 
williamr@2
   225
		for the request, otherwise no attributes are inserted into 
williamr@2
   226
		the request. 
williamr@2
   227
		
williamr@2
   228
		See #AddAttributeL for the explanation of ASN.1 encoding of
williamr@2
   229
		attributes.
williamr@2
   230
	*/
williamr@2
   231
	CASN1EncSequence* iRoot;
williamr@2
   232
	};
williamr@2
   233
williamr@2
   234
#endif // __PKCS10ATTR_H__