cryptoservices/certificateandkeymgmt/inc/pkcs9attr.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2007-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 * PKCS#9 attributes for use in PKCS#10 Certificate Request creation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file
       
    24  @publishedPartner
       
    25  @released 
       
    26 */
       
    27 
       
    28 #if !defined (__PKCS9ATTR_H__)
       
    29 #define __PKCS9ATTR_H__
       
    30 
       
    31 #include <x509cert.h>
       
    32 #include <pkcs10attr.h>
       
    33 
       
    34 // OID of PKCS#9 Challenge Password attribute
       
    35 _LIT(KPkcs9ChallengePasswordAttrOID, "1.2.840.113549.1.9.7");
       
    36 
       
    37 // OID of PKCS#9 Extension Request attribute
       
    38 _LIT(KPkcs9ExtensionRequestAttrOID, "1.2.840.113549.1.9.14");
       
    39 
       
    40 // Lower bound of password length for PKCS#9 Challenge Password attribute
       
    41 const TInt KPkcs9StringLB = 1;
       
    42 
       
    43 // Upper bound of password length for PKCS#9 Challenge Password attribute
       
    44 const TInt KPkcs9StringUB = 255;
       
    45 
       
    46 /**
       
    47  Class representing a PKCS#9 Challenge Password attribute.
       
    48 */
       
    49 class CPKCS9ChallengePasswordAttr : public CPKCSAttributeBase
       
    50 	{
       
    51 public:
       
    52 
       
    53 	/** Create a PKCS#9 Challenge Password attribute with the given password, leaving it on
       
    54 		the cleanup stack.
       
    55 		@param aPassword The password - should be a Printable String with an upper bound 
       
    56 		length of 255 characters and lower bound of 1 character.
       
    57 		@return New Challenge Password attribute object
       
    58 	*/
       
    59 	IMPORT_C static CPKCS9ChallengePasswordAttr* NewLC(const TDesC8& aPassword);
       
    60 
       
    61 	/** Create a PKCS#9 Challenge Password attribute with the given password.
       
    62 		@param aPassword The password - should be a Printable String with an upper bound 
       
    63 		length of 255 characters and lower bound of 1 character.
       
    64 		@return New Challenge Password attribute object
       
    65 	*/
       
    66 	IMPORT_C static CPKCS9ChallengePasswordAttr* NewL(const TDesC8& aPassword);
       
    67 
       
    68 	/** Reset method to allow for re-use of the attribute object.
       
    69 		@param aPassword The password - should be a Printable String with an upper bound 
       
    70 		length of 255 characters and lower bound of 1 character.
       
    71 	*/
       
    72 	IMPORT_C void ResetL(const TDesC8& aPassword);
       
    73 
       
    74 	/** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
       
    75 		leaving it on the cleanup stack. This is called by CPKCS10Attribtues
       
    76 		when AddAttribute() is called. Note that this method cannot be reused unless
       
    77 		Reset() has been called. 
       
    78 		@panic E32USER-CBase:66 if a stack frame for the next PushL() cannot be allocated.
       
    79 		@return ASN.1 encoding object
       
    80 	*/
       
    81 	CASN1EncBase* GetEncodingLC();
       
    82 
       
    83 	virtual ~CPKCS9ChallengePasswordAttr();
       
    84 
       
    85 private:
       
    86 	CPKCS9ChallengePasswordAttr();
       
    87 	void ConstructL(const TDesC8& aPassword);
       
    88 	};
       
    89 
       
    90 /**
       
    91  Class representing a collection of one or more X.509 Certificate Extension attributes.
       
    92 */
       
    93 class CPKCS9ExtensionRequestAttr : public CPKCSAttributeBase
       
    94 	{
       
    95 public:
       
    96 
       
    97 	/** Create a PKCS#9 Extensions attribute with the a single extension, leaving it on
       
    98 		the cleanup stack.
       
    99 		@param aExtension An X.509 Certificate Extension object.
       
   100 		@return New PKCS#9 Extensions attribute object
       
   101 	*/
       
   102 	IMPORT_C static CPKCS9ExtensionRequestAttr* NewLC(const CX509CertExtension& aExtension);
       
   103 
       
   104 	/** Create a PKCS#9 Extensions attribute with the a single extension.
       
   105 		@param aExtension An X.509 Certificate Extension object.
       
   106 		@return New PKCS#9 Extensions attribute object
       
   107 	*/
       
   108 	IMPORT_C static CPKCS9ExtensionRequestAttr* NewL(const CX509CertExtension& aExtension);
       
   109 
       
   110 	/** Adds an extension to the extensions attribute.
       
   111 		@param aExtension An X.509 Certificate Extension object.
       
   112 	*/
       
   113 	IMPORT_C void AddExtensionL(const CX509CertExtension& aExtension);
       
   114 
       
   115 	/** Reset method to allow for re-use of the attribute object. Already existing 
       
   116 		extensions are removed.
       
   117 		@param aExtension An X.509 Certificate Extension object.
       
   118 	*/
       
   119 	IMPORT_C void ResetL(const CX509CertExtension& aExtension);
       
   120 
       
   121 	virtual ~CPKCS9ExtensionRequestAttr();
       
   122 
       
   123 	/** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
       
   124 		leaving it on the cleanup stack. This is called by CPKCS10Attribtues
       
   125 		when AddAttribute() is called. Note that this method cannot be reused unless
       
   126 		Reset() has been called. 
       
   127 		@panic E32USER-CBase:66 if a stack frame for the next PushL() cannot be allocated.
       
   128 		@return ASN.1 encoding object
       
   129 	*/
       
   130 	CASN1EncBase* GetEncodingLC();
       
   131 
       
   132 private:
       
   133 	CPKCS9ExtensionRequestAttr();
       
   134 	void ConstructL(const CX509CertExtension& aExtension);
       
   135 
       
   136 private:
       
   137 	CASN1EncSequence* iExtSeq;
       
   138 	};
       
   139 
       
   140 #endif // __PKCS9ATTR_H__