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