sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * PKCS#9 attributes for use in PKCS#10 Certificate Request creation sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: #if !defined (__PKCS9ATTR_H__) sl@0: #define __PKCS9ATTR_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // OID of PKCS#9 Challenge Password attribute sl@0: _LIT(KPkcs9ChallengePasswordAttrOID, "1.2.840.113549.1.9.7"); sl@0: sl@0: // OID of PKCS#9 Extension Request attribute sl@0: _LIT(KPkcs9ExtensionRequestAttrOID, "1.2.840.113549.1.9.14"); sl@0: sl@0: // Lower bound of password length for PKCS#9 Challenge Password attribute sl@0: const TInt KPkcs9StringLB = 1; sl@0: sl@0: // Upper bound of password length for PKCS#9 Challenge Password attribute sl@0: const TInt KPkcs9StringUB = 255; sl@0: sl@0: /** sl@0: Class representing a PKCS#9 Challenge Password attribute. sl@0: */ sl@0: class CPKCS9ChallengePasswordAttr : public CPKCSAttributeBase sl@0: { sl@0: public: sl@0: sl@0: /** Create a PKCS#9 Challenge Password attribute with the given password, leaving it on sl@0: the cleanup stack. sl@0: @param aPassword The password - should be a Printable String with an upper bound sl@0: length of 255 characters and lower bound of 1 character. sl@0: @return New Challenge Password attribute object sl@0: */ sl@0: IMPORT_C static CPKCS9ChallengePasswordAttr* NewLC(const TDesC8& aPassword); sl@0: sl@0: /** Create a PKCS#9 Challenge Password attribute with the given password. sl@0: @param aPassword The password - should be a Printable String with an upper bound sl@0: length of 255 characters and lower bound of 1 character. sl@0: @return New Challenge Password attribute object sl@0: */ sl@0: IMPORT_C static CPKCS9ChallengePasswordAttr* NewL(const TDesC8& aPassword); sl@0: sl@0: /** Reset method to allow for re-use of the attribute object. sl@0: @param aPassword The password - should be a Printable String with an upper bound sl@0: length of 255 characters and lower bound of 1 character. sl@0: */ sl@0: IMPORT_C void ResetL(const TDesC8& aPassword); sl@0: sl@0: /** Get the ASN.1 encoding of the attribute and relinquish ownership of it, sl@0: leaving it on the cleanup stack. This is called by CPKCS10Attribtues sl@0: when AddAttribute() is called. Note that this method cannot be reused unless sl@0: Reset() has been called. sl@0: @panic E32USER-CBase:66 if a stack frame for the next PushL() cannot be allocated. sl@0: @return ASN.1 encoding object sl@0: */ sl@0: CASN1EncBase* GetEncodingLC(); sl@0: sl@0: virtual ~CPKCS9ChallengePasswordAttr(); sl@0: sl@0: private: sl@0: CPKCS9ChallengePasswordAttr(); sl@0: void ConstructL(const TDesC8& aPassword); sl@0: }; sl@0: sl@0: /** sl@0: Class representing a collection of one or more X.509 Certificate Extension attributes. sl@0: */ sl@0: class CPKCS9ExtensionRequestAttr : public CPKCSAttributeBase sl@0: { sl@0: public: sl@0: sl@0: /** Create a PKCS#9 Extensions attribute with the a single extension, leaving it on sl@0: the cleanup stack. sl@0: @param aExtension An X.509 Certificate Extension object. sl@0: @return New PKCS#9 Extensions attribute object sl@0: */ sl@0: IMPORT_C static CPKCS9ExtensionRequestAttr* NewLC(const CX509CertExtension& aExtension); sl@0: sl@0: /** Create a PKCS#9 Extensions attribute with the a single extension. sl@0: @param aExtension An X.509 Certificate Extension object. sl@0: @return New PKCS#9 Extensions attribute object sl@0: */ sl@0: IMPORT_C static CPKCS9ExtensionRequestAttr* NewL(const CX509CertExtension& aExtension); sl@0: sl@0: /** Adds an extension to the extensions attribute. sl@0: @param aExtension An X.509 Certificate Extension object. sl@0: */ sl@0: IMPORT_C void AddExtensionL(const CX509CertExtension& aExtension); sl@0: sl@0: /** Reset method to allow for re-use of the attribute object. Already existing sl@0: extensions are removed. sl@0: @param aExtension An X.509 Certificate Extension object. sl@0: */ sl@0: IMPORT_C void ResetL(const CX509CertExtension& aExtension); sl@0: sl@0: virtual ~CPKCS9ExtensionRequestAttr(); sl@0: sl@0: /** Get the ASN.1 encoding of the attribute and relinquish ownership of it, sl@0: leaving it on the cleanup stack. This is called by CPKCS10Attribtues sl@0: when AddAttribute() is called. Note that this method cannot be reused unless sl@0: Reset() has been called. sl@0: @panic E32USER-CBase:66 if a stack frame for the next PushL() cannot be allocated. sl@0: @return ASN.1 encoding object sl@0: */ sl@0: CASN1EncBase* GetEncodingLC(); sl@0: sl@0: private: sl@0: CPKCS9ExtensionRequestAttr(); sl@0: void ConstructL(const CX509CertExtension& aExtension); sl@0: sl@0: private: sl@0: CASN1EncSequence* iExtSeq; sl@0: }; sl@0: sl@0: #endif // __PKCS9ATTR_H__