1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/inc/pkcs10attr.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,233 @@
1.4 +/*
1.5 +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* PKCS#10 Certificate Request Attributes class.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @publishedPartner
1.26 + @released
1.27 +*/
1.28 +
1.29 +#if !defined (__PKCS10ATTR_H__)
1.30 +#define __PKCS10ATTR_H__
1.31 +
1.32 +class CASN1EncBase;
1.33 +class CASN1EncSequence;
1.34 +class CASN1EncSet;
1.35 +
1.36 +//
1.37 +// Class capturing common functionality of a PKCS attribute.
1.38 +//
1.39 +class CPKCSAttributeBase : public CBase
1.40 + {
1.41 +public:
1.42 +
1.43 + /** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
1.44 + leaving it on the cleanup stack. This is called by CPKCS10Attribtues
1.45 + when AddAttribute() is called.
1.46 + @panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
1.47 + @return ASN.1 encoding object
1.48 + */
1.49 + virtual CASN1EncBase* GetEncodingLC() = 0;
1.50 +
1.51 + virtual ~CPKCSAttributeBase();
1.52 +
1.53 +protected:
1.54 + /** @internalComponent */
1.55 + CPKCSAttributeBase();
1.56 + CASN1EncSequence* iRoot;
1.57 + CASN1EncSet* iValueSet;
1.58 + };
1.59 +
1.60 +/** Class representing a generic certificate attribute. Attributes have an
1.61 + object identifier and one or more values.
1.62 +*/
1.63 +class CPKCS10Attribute : public CPKCSAttributeBase
1.64 + {
1.65 +public:
1.66 +
1.67 + /** Create an attribute with a specified OID and no values, leaving it on
1.68 + the cleanup stack.
1.69 + NOTE: This method is deprecated. Use the other forms of NewLC instead.
1.70 + @param aAttrOID The specified OID in the form a.b.c. etc.
1.71 + @return New PKCS10 attribute object on the cleanup stack
1.72 + @deprecated
1.73 + */
1.74 + IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID);
1.75 +
1.76 + /** Create an attribute with a specified OID and one value, leaving it on
1.77 + the cleanup stack. The value forms part of a set. Additional values can
1.78 + be added by calling the AddValueL method.
1.79 + @param aAttrOID The specified OID in the form a.b.c. etc.
1.80 + @param aASN1 ASN1 encoding object for attribute value
1.81 + -- this method takes ownership.
1.82 + @return New PKCS10 attribute object on the cleanup stack
1.83 + */
1.84 + IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID, CASN1EncBase* aASN1);
1.85 +
1.86 + /** Create an attribute with a specified OID and one value. The value forms
1.87 + part of a set. Additional values can be added by calling the AddValueL method.
1.88 + @param aAttrOID The specified OID in the form a.b.c. etc.
1.89 + @param aASN1 ASN1 encoding object for attribute value
1.90 + -- this method takes ownership.
1.91 + @return New PKCS10 attribute object
1.92 + */
1.93 + IMPORT_C static CPKCS10Attribute* NewL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
1.94 +
1.95 + /** Add a value to the attribute.
1.96 + @param aASN1 ASN1 encoding object for attribute value
1.97 + -- this method takes ownership.
1.98 + */
1.99 + IMPORT_C void AddValueL(CASN1EncBase* aASN1);
1.100 +
1.101 + /** ResetL method to allow for re-use of the generic attribute object.
1.102 + Additional values can be added by calling the AddValueL method.
1.103 + @param aAttrOID The specified OID in the form a.b.c. etc.
1.104 + @param aASN1 ASN1 encoding object for attribute value
1.105 + -- this method takes ownership.
1.106 + */
1.107 + IMPORT_C void ResetL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
1.108 +
1.109 + virtual ~CPKCS10Attribute();
1.110 +
1.111 + /**
1.112 + * @internalComponent
1.113 + *
1.114 + * Get the ASN1 encoding of the attribute and relinquish ownership of it,
1.115 + leaving it on the cleanup stack. This is called by CPKCS10Attribtues
1.116 + when AddAttribute() is called. This method may leave with E32USER-CBase:66
1.117 + if a stack frame for the next PushL() cannot be allocated.
1.118 + NOTE: This method is deprecated. Use GetEncodingLC() instead.
1.119 + @deprecated
1.120 + */
1.121 + CASN1EncBase* TakeEncodingC();
1.122 +
1.123 + /**
1.124 + * @internalComponent
1.125 + *
1.126 + * Get the ASN1 encoding of the attribute and relinquish ownership of it,
1.127 + leaving it on the cleanup stack. This is called by CPKCS10Attribtues
1.128 + when AddAttribute() is called. This method may leave with E32USER-CBase:66
1.129 + if a stack frame for the next PushL() cannot be allocated.
1.130 + NOTE: This method is deprecated. Use GetEncodingLC() instead.
1.131 + @deprecated
1.132 + */
1.133 + CASN1EncBase* TakeEncodingLC();
1.134 +
1.135 + /** Calls the base class implementation for getting the ASN1 encoding of the attribute.
1.136 + Note that this method cannot be reused unless ResetL() has been called.
1.137 + @panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
1.138 + @return ASN.1 encoding object
1.139 + */
1.140 + virtual CASN1EncBase* GetEncodingLC();
1.141 +
1.142 +private:
1.143 + // Default constructor.
1.144 + CPKCS10Attribute();
1.145 +
1.146 + // Second phase construction function.
1.147 + void ConstructL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
1.148 + };
1.149 +
1.150 +/** Class for encoding a collection of certificate attributes and passing them
1.151 + to the CPKCS10Request class. Some possible attributes are described in
1.152 + PKCS#9.
1.153 +
1.154 + @publishedPartner
1.155 + @released
1.156 +*/
1.157 +class CPKCS10Attributes : public CBase
1.158 + {
1.159 +public:
1.160 + /** Creates an instance of the class.
1.161 + @return New attributes object on the cleanup stack.
1.162 + */
1.163 + IMPORT_C static CPKCS10Attributes* NewLC();
1.164 +
1.165 + /** Creates an instance of the class.
1.166 + @return New attributes object.
1.167 + */
1.168 + IMPORT_C static CPKCS10Attributes* NewL();
1.169 +
1.170 + /** Adds a new attribute for the certificate request.
1.171 + @param aAttr The attribute to add - this method takes ownership.
1.172 + @deprecated
1.173 + */
1.174 + IMPORT_C void AddAttributeL(CPKCS10Attribute* aAttr);
1.175 +
1.176 + /** Adds a new attribute for the certificate request.
1.177 + @param aAttr The attribute to add - this method takes ownership.
1.178 + */
1.179 + IMPORT_C void AddPKCSAttributeL(CPKCSAttributeBase* aAttr);
1.180 +
1.181 + IMPORT_C ~CPKCS10Attributes(); // virtual from base
1.182 +
1.183 + /**
1.184 + * @internalComponent
1.185 + *
1.186 + * Get the ASN1 encoding of the attributes and relinquish ownership of it,
1.187 + leaving it on the cleanup stack. This is called by CPKCS10Request when
1.188 + SetAttributes() is called. This method may leave with E32USER-CBase:66
1.189 + if a stack frame for the next PushL() cannot be allocated.
1.190 + @deprecated
1.191 + */
1.192 + CASN1EncBase* TakeEncodingC();
1.193 +
1.194 + /**
1.195 + * @internalComponent
1.196 + *
1.197 + * Get the ASN.1 encoding of the attribute and relinquish ownership of it,
1.198 + leaving it on the cleanup stack. This is called by CPKCS10Request when
1.199 + SetAttributes() is called.
1.200 + @panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
1.201 + @return ASN.1 encoding object
1.202 + */
1.203 + CASN1EncBase* TakeEncodingLC();
1.204 +
1.205 +private:
1.206 + /** Default constructor.
1.207 + */
1.208 + CPKCS10Attributes();
1.209 +
1.210 + /** Second phase construction function.
1.211 + @note The structure of the attribute node is as follows:
1.212 + @code
1.213 + SET
1.214 + SEQUENCE
1.215 + OID of attribute
1.216 + SET values
1.217 + ...
1.218 + @endcode
1.219 + */
1.220 + void ConstructL();
1.221 +
1.222 +private:
1.223 + /** Pointer to sequence of user-supplied certificate attributes.
1.224 + #AddAttributeL method is used to create and fill this member.
1.225 + If it is initialized by the time #CalculateEncodingL method
1.226 + is called, the latter uses attributes from this member variable
1.227 + for the request, otherwise no attributes are inserted into
1.228 + the request.
1.229 +
1.230 + See #AddAttributeL for the explanation of ASN.1 encoding of
1.231 + attributes.
1.232 + */
1.233 + CASN1EncSequence* iRoot;
1.234 + };
1.235 +
1.236 +#endif // __PKCS10ATTR_H__