Update contrib.
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
17 * Common specific extensions:
18 * 1) basic constraints
22 * 5) policy constraints
27 * 10) extended key usage
28 * 11) authority information access
30 * 12) inhibit-any policy
41 #if !defined (__X509CERTEXT_H__)
42 #define __X509CERTEXT_H__
48 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
49 #include <x509bitstring.h>
55 /** A list of values that defines what an X.509 key can be used for.
56 * These values can be ANDed together if a key has several usages.
61 /** A digital signature. */
62 EX509DigitalSignature,
63 /** Non repudiation. */
65 /** Key encipherment. */
67 /** Data encipherment. */
68 EX509DataEncipherment,
71 /** Key certificate sign. */
81 /** X509 Extension OIDs
85 //OIDS for the extensions we define here...
86 _LIT(KBasicConstraints,"2.5.29.19");
87 _LIT(KSubjectAltName,"2.5.29.17");
88 _LIT(KIssuerAltName,"2.5.29.18");
89 _LIT(KKeyUsage,"2.5.29.15");
90 _LIT(KNameConstraints,"2.5.29.30");
91 _LIT(KPolicyConstraints,"2.5.29.36");
92 _LIT(KCertPolicies,"2.5.29.32");
93 _LIT(KPolicyMapping,"2.5.29.33");
94 _LIT(KAuthorityKeyId,"2.5.29.35");
95 _LIT(KSubjectKeyId,"2.5.29.14");
96 _LIT(KExtendedKeyUsage,"2.5.29.37");
97 _LIT(KAuthorityInfoAccess, "1.3.6.1.5.5.7.1.1");
98 _LIT(KInhibitAnyPolicy, "2.5.29.54");
100 // OIDs for access methods
101 _LIT(KAccessMethodOCSP, "1.3.6.1.5.5.7.48.1");
103 //deprecated OIDs we might still encounter
104 _LIT(KOldBasicConstraints,"2.5.29.10");
105 _LIT(KOldBasicConstraints2,"2.5.29.13");
106 _LIT(KOldSubjectAltName,"2.5.29.7");
107 _LIT(KOldIssuerAltName,"2.5.29.8");
108 _LIT(KOldNameConstraints,"2.5.29.11");
109 _LIT(KOldPolicyConstraints,"2.5.29.2");
110 _LIT(KOldPolicyConstraints2,"2.5.29.34");
111 _LIT(KOldCertPolicies,"2.5.29.3");
112 _LIT(KOldPolicyMapping,"2.5.29.5");
113 _LIT(KOldAuthorityKeyId,"2.5.29.1");
115 // Define OIDs for Symbian certificate constraints.
116 _LIT(KDeviceIdListConstraint,"1.2.826.0.1.1796587.1.1.1.1");
117 _LIT(KSidListConstraint,"1.2.826.0.1.1796587.1.1.1.4");
118 _LIT(KVidListConstraint,"1.2.826.0.1.1796587.1.1.1.5");
119 _LIT(KCapabilitiesConstraint,"1.2.826.0.1.1796587.1.1.1.6");
121 //1) basic constraints...
123 class CX509ExtensionBase : public CBase
124 /** A certificate extension base class.
129 /** Second-phase constructor.
131 * @param aBinaryData The encoded binary representation.
132 * @param aPos The position from which to start decoding. */
133 virtual void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
135 /** Implementation for second-phase construction.
137 * This is called by ConstructL().
139 * @param aBinaryData The encoded binary representation. This is the same as
140 * passed to ConstructL().
141 * @param aPos The position from which to start decoding. Note that the value
142 * passed points, in effect, to the content, by passing the header data. */
143 virtual void DoConstructL(const TDesC8& aBinaryData, TInt& aPos) = 0;
146 class CX509BasicConstraintsExt : public CX509ExtensionBase
147 /** An X.509 certificate extension that defines basic constraints.
149 * It indicates whether the certificate belongs to a Certificate Authority or
155 /** Creates a new CX509BasicConstraintsExt object from the specified
156 * buffer containing the binary coded representation.
158 * @param aBinaryData The encoded binary representation.
159 * @return The new CX509BasicConstraintsExt object. */
160 IMPORT_C static CX509BasicConstraintsExt* NewL(const TDesC8& aBinaryData);
162 /** Creates a new CX509BasicConstraintsExt object from the specified
163 * buffer containing the binary coded representation, and puts a pointer to it
164 * onto the cleanup stack.
166 * @param aBinaryData The encoded binary representation.
167 * @return The new CX509BasicConstraintsExt object. */
168 IMPORT_C static CX509BasicConstraintsExt* NewLC(const TDesC8& aBinaryData);
170 /** Creates a new CX509BasicConstraintsExt object from the specified
171 * buffer containing the binary coded representation, starting at the specified
174 * @param aBinaryData The encoded binary representation.
175 * @param aPos The offset position from which to start decoding.
176 * @return The new CX509BasicConstraintsExt object. */
177 IMPORT_C static CX509BasicConstraintsExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
179 /** Creates a new CX509BasicConstraintsExt object from the specified
180 * buffer containing the binary coded representation, starting at the specified
181 * offset, and puts a pointer to it onto the cleanup stack.
183 * @param aBinaryData The encoded binary representation.
184 * @param aPos The offset position from which to start decoding.
185 * @return The new CX509BasicConstraintsExt object. */
186 IMPORT_C static CX509BasicConstraintsExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
190 * Frees all resources owned by the object, prior to its destruction. */
191 virtual ~CX509BasicConstraintsExt();
193 /** Tests whether the certificate belongs to a Certificate Authority.
195 * @return ETrue, if the certificate belongs to a Certificate Authority;
196 * EFalse, otherwise. */
197 IMPORT_C TBool IsCA() const;
199 /** Gets the maximum number of certificates that can follow this one in the chain.
201 * @return The number of certificates. */
202 IMPORT_C TInt MaxChainLength() const;//0 if not set
204 CX509BasicConstraintsExt();
205 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
212 class CX509AltNameExt : public CX509ExtensionBase
213 /** An X.509 certificate extension that defines an alternate name.
215 * It appears as an Issuer Alt Name extension or a Subject Alt Name extension
216 * and is used to contain extra identifying information that will not fit into
217 * a Distinguished Name.
219 * It consists of an array of X.509 General Names.
224 /** Creates a new CX509AltNameExt object from the specified
225 * buffer containing the binary coded representation.
227 * @param aBinaryData The encoded binary representation.
228 * @return The new CX509AltNameExt object. */
229 IMPORT_C static CX509AltNameExt* NewL(const TDesC8& aBinaryData);
231 /** Creates a new CX509AltNameExt object from the specified
232 * buffer containing the binary coded representation, and puts a pointer to it
233 * onto the cleanup stack.
235 * @param aBinaryData The encoded binary representation.
236 * @return The new CX509AltNameExt object. */
237 IMPORT_C static CX509AltNameExt* NewLC(const TDesC8& aBinaryData);
239 /** Creates a new CX509AltNameExt object from the specified
240 * buffer containing the binary coded representation, starting at the specified
243 * @param aBinaryData The encoded binary representation.
244 * @param aPos The offset position from which to start decoding.
245 * @return The new CX509AltNameExt object. */
246 IMPORT_C static CX509AltNameExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
248 /** Creates a new CX509AltNameExt object from the specified
249 * buffer containing the binary coded representation, starting at the specified
250 * offset, and puts a pointer to it onto the cleanup stack.
252 * @param aBinaryData The encoded binary representation.
253 * @param aPos The offset position from which to start decoding.
254 * @return The new CX509AltNameExt object. */
255 IMPORT_C static CX509AltNameExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
259 * Frees all resources owned by the object, prior to its destruction. */
260 virtual ~CX509AltNameExt();
262 /** Gets a reference to the array of general names that forms the alternate name
265 * @return The array of general names. */
266 IMPORT_C const CArrayPtrFlat<CX509GeneralName>& AltName() const;
268 /** Checks whether the corressponding elements of two equally sized arrays of X.509 general names
271 * @param aExt An X.509 certificate extension object that defines an alternate name.
272 * @return TRUE if all the elements in the arrays match.
274 IMPORT_C TBool Match(const CX509AltNameExt& aExt) const;
277 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
278 CArrayPtrFlat<CX509GeneralName>* iAuthorityName;
281 class CX509KeyUsageExt : public CX509ExtensionBase
282 /** An X.509 certificate extension that defines the uses to which a key may be put.
287 /** Creates a new CX509KeyUsageExt object from the specified buffer
288 * containing the binary coded representation.
290 * @param aBinaryData The encoded binary representation.
291 * @return The new CX509KeyUsageExt object. */
292 IMPORT_C static CX509KeyUsageExt* NewL(const TDesC8& aBinaryData);
294 /** Creates a new CX509KeyUsageExt object from the specified buffer
295 * containing the binary coded representation, and puts a pointer to it onto
298 * @param aBinaryData The encoded binary representation.
299 * @return The new CX509KeyUsageExt object. */
300 IMPORT_C static CX509KeyUsageExt* NewLC(const TDesC8& aBinaryData);
302 /** Creates a new CX509KeyUsageExt object from the specified buffer
303 * containing the binary coded representation, starting at the specified offset.
305 * @param aBinaryData The encoded binary representation.
306 * @param aPos The offset position from which to start decoding.
307 * @return The new CX509KeyUsageExt object. */
308 IMPORT_C static CX509KeyUsageExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
310 /** Creates a new CX509KeyUsageExt object from the specified buffer
311 * containing the binary coded representation, starting at the specified offset,
312 * and puts a pointer to it onto the cleanup stack.
314 * @param aBinaryData The encoded binary representation.
315 * @param aPos The offset position from which to start decoding.
316 * @return The new CX509KeyUsageExt object. */
317 IMPORT_C static CX509KeyUsageExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
321 * Frees all resources owned by the object, prior to its destruction. */
322 virtual ~CX509KeyUsageExt();
324 /** Tests whether a particular usage is set in the extension.
327 * @param aUsage The usage.
328 * @return ETrue, if the specific usage is set in the extension; EFalse, otherwise. */
329 IMPORT_C TBool IsSet(TX509KeyUsage aUsage) const;
332 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
333 CX509BitString* iData;
336 //4) name constraints
338 class CX509GeneralSubtree : public CBase
339 /** Provides access to the general name and the min/max lengths of the subtree.
347 * Creates a new CX509GeneralSubtree object from the specified buffer containing
348 * the encoded binary representation.
350 * @param aBinaryData The encoded binary representation.
351 * @return The new CX509GeneralSubtree object.
353 static CX509GeneralSubtree* NewL(const TDesC8& aBinaryData);
358 * Creates a new CX509GeneralSubtree object from the specified buffer containing
359 * the encoded binary representation, and puts a pointer to it onto the cleanup stack.
361 * @param aBinaryData The encoded binary representation.
362 * @return The new CX509GeneralSubtree object.
364 static CX509GeneralSubtree* NewLC(const TDesC8& aBinaryData);
369 * Creates a new CX509GeneralSubtree object from the specified buffer containing
370 * the encoded binary representation.
372 * @param aBinaryData The encoded binary representation.
373 * @param aPos The position from which to start decoding.
374 * @return The new CX509GeneralSubtree object.
376 static CX509GeneralSubtree* NewL(const TDesC8& aBinaryData, TInt& aPos);
381 * Creates a new CX509GeneralSubtree object from the specified buffer containing
382 * the encoded binary representation, and puts a pointer to it onto the cleanup stack.
384 * @param aBinaryData The encoded binary representation.
385 * @param aPos The position from which to start decoding.
386 * @return The new CX509GeneralSubtree object.
388 static CX509GeneralSubtree* NewLC(const TDesC8& aBinaryData, TInt& aPos);
392 * Frees all resources owned by the object. */
393 virtual ~CX509GeneralSubtree();
395 /** Gets the general name.
397 * @return The general name. */
398 IMPORT_C const CX509GeneralName& Name() const;
400 /** Gets the minimum distance of the CX509GeneralSubtree object.
402 * @return The minimum distance of the CX509GeneralSubtree object. */
403 IMPORT_C TInt MinDistance() const;
405 /** Gets the maximum distance of the CX509GeneralSubtree object.
407 * @return The maximum distance of the CX509GeneralSubtree object. */
408 IMPORT_C TInt MaxDistance() const;
410 CX509GeneralSubtree();
411 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
412 CX509GeneralName* iName;
417 class CX509NameConstraintsExt : public CX509ExtensionBase
418 /** An X.509 certificate extension that defines constraints on an entity's name.
420 * This extension allows Certification Authorities to restrict or prevent the issuing
421 * of certificates to entities whose names lie within a defined name space.
426 /** Creates a new CX509NameConstraintsExt object from the specified
427 * buffer containing the binary coded representation.
429 * @param aBinaryData The encoded binary representation.
430 * @return The new CX509NameConstraintsExt object. */
431 IMPORT_C static CX509NameConstraintsExt* NewL(const TDesC8& aBinaryData);
433 /** Creates a new CX509NameConstraintsExt object from the specified
434 * buffer containing the binary coded representation, and puts a pointer to it
435 * onto the cleanup stack.
437 * @param aBinaryData The encoded binary representation.
438 * @return The new CX509NameConstraintsExt object. */
439 IMPORT_C static CX509NameConstraintsExt* NewLC(const TDesC8& aBinaryData);
441 /** Creates a new CX509NameConstraintsExt object from the specified
442 * buffer containing the binary coded representation, starting at the specified offset.
444 * @param aBinaryData The encoded binary representation.
445 * @param aPos The offset position from which to start decoding.
446 * @return The new CX509NameConstraintsExt object. */
447 IMPORT_C static CX509NameConstraintsExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
449 /** Creates a new CX509NameConstraintsExt object from the specified
450 * buffer containing the binary coded representation, starting at the specified
451 * offset, and puts a pointer to it onto the cleanup stack.
453 * @param aBinaryData The encoded binary representation.
454 * @param aPos The offset position from which to start decoding.
455 * @return The new CX509NameConstraintsExt object. */
456 IMPORT_C static CX509NameConstraintsExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
460 * Frees all resources owned by the object, prior to its destruction. */
461 IMPORT_C ~CX509NameConstraintsExt();
463 /** Gets a reference to the array of exclusion subtree names.
465 * No certificates after this one may contain names within the subtrees specified.
467 * @return The excluded subtrees. */
468 IMPORT_C const CArrayPtrFlat<CX509GeneralSubtree>& ExcludedSubtrees() const;
470 /** Gets a reference to the array of permitted subtree names.
472 * All certificates after this one must contain names within the subtrees specified.
474 * @return The permitted subtrees. */
475 IMPORT_C const CArrayPtrFlat<CX509GeneralSubtree>& PermittedSubtrees() const;
477 CX509NameConstraintsExt();
478 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
479 void AddSubtreesL(CArrayPtrFlat<CX509GeneralSubtree>& aSubtrees, const TDesC8& aBinaryData);
480 CArrayPtrFlat<CX509GeneralSubtree>* iExcludedSubtrees;
481 CArrayPtrFlat<CX509GeneralSubtree>* iPermittedSubtrees;
484 //5) policy constraints
486 class TX509PolicyConstraint
487 /** Defines whether a policy constraint applies.
489 * Objects of this type are used by the X.509 certificate extension that constrains
490 * the use of policies.
492 * An object of this type encapsulates two pieces of information:
493 * @li whether a specific policy applies to subsequent certificates
494 * @li if a specific policy applies, the number of certificates that can follow the
495 * current one before the policy constraint applies.
497 * Enables a CA to constrain the use of policies in two ways: they can enforce
498 * the appearance of explicit certificate policies in subsequent certificates,
499 * and prevent policy mapping from being performed.
507 * Constructs a TX509PolicyConstraint definition object with the specified requirement
508 * and countdown values.
510 * @param aRequired The policy requirement. Set to ETrue, if the policy constraint
511 * applies; set to EFalse, otherwise.
512 * @param aCountdown The countdown value. This is the number of certificates that
513 * can follow the current one before the constraint applies.
514 * This only has meaning if the policy constraint applies.
516 TX509PolicyConstraint(TBool aRequired, TInt aCountdown);
521 * Default constructor.
523 * Sets policy requirement to EFalse and iRequired to EFalse and the iCountdown
526 TX509PolicyConstraint();
528 /** The policy requirement.
530 * This has the value ETrue, if the policy constraint applies; EFalse otherwise. */
533 /** The count down value.
535 * Defines the number of certificates that can follow the current one before
536 * the policy constraint applies. This has no meaning if the policy constraint
541 class CX509PolicyConstraintsExt : public CX509ExtensionBase
542 /** Enables a Certification Authority to constrain the use of policies in two ways:
543 * @li to enforce the appearance of explicit certificate policies in subsequent certificates
544 * @li to prevent policy mapping from being performed.
549 /** Creates a new CX509PolicyConstraintsExt object from the specified buffer
550 * containing the encoded binary representation.
552 * @param aBinaryData The encoded binary representation.
553 * @return The new CX509PolicyConstraintsExt object. */
554 IMPORT_C static CX509PolicyConstraintsExt* NewL(const TDesC8& aBinaryData);
556 /** Creates a new Policy constraints extension object from the specified buffer
557 * containing the encoded binary representation, and puts a pointer to it onto
560 * @param aBinaryData The encoded binary representation.
561 * @return The new CX509PolicyConstraintsExt object. */
562 IMPORT_C static CX509PolicyConstraintsExt* NewLC(const TDesC8& aBinaryData);
564 /** Creates a new CX509PolicyConstraintsExt object from the specified buffer
565 * containing the encoded binary representation, starting at the specified offset.
567 * @param aBinaryData The encoded binary representation.
568 * @param aPos The offset position from which to start decoding.
569 * @return The new CX509PolicyConstraintsExt object. */
570 IMPORT_C static CX509PolicyConstraintsExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
572 /** Creates a new CX509PolicyConstraintsExt object from the specified buffer
573 * containing the encoded binary representation, and puts a pointer to it onto
576 * @param aBinaryData The encoded binary representation.
577 * @param aPos The offset position from which to start decoding.
578 * @return The new CX509PolicyConstraintsExt object. */
579 IMPORT_C static CX509PolicyConstraintsExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
583 * Frees all resources owned by the object, prior to its destruction. */
584 IMPORT_C ~CX509PolicyConstraintsExt();
586 /** Gets the explicit policy constraint.
588 * @return The explicit policy constraint. */
589 IMPORT_C TX509PolicyConstraint ExplicitPolicyRequired() const;
591 /** Gets the inhibiting policy mapping.
593 * @return The inhibiting policy mapping. */
594 IMPORT_C TX509PolicyConstraint InhibitPolicyMapping() const;
596 CX509PolicyConstraintsExt();
597 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
598 TX509PolicyConstraint iRequirePolicy;
599 TX509PolicyConstraint iInhibitPolicyMapping;
604 class CX509PolicyQualifierInfo : public CBase
605 /** Gets X.509 policy qualifier information.
613 * Creates a new CX509PolicyQualifierInfo object from the specified
614 * buffer containing the encoded binary representation.
616 * @param aBinaryData The encoded binary representation.
617 * @return The new CX509PolicyQualifierInfo object.
619 static CX509PolicyQualifierInfo* NewL(const TDesC8& aBinaryData);
624 * Creates a new CX509PolicyQualifierInfo object from the specified
625 * buffer containing the encoded binary representation, and puts a pointer to
626 * it onto the cleanup stack.
628 * @param aBinaryData The encoded binary representation.
629 * @return The new CX509PolicyQualifierInfo object.
631 static CX509PolicyQualifierInfo* NewLC(const TDesC8& aBinaryData);
636 * Creates a new CX509PolicyQualifierInfo object from the specified
637 * buffer containing the encoded binary representation.
639 * @param aBinaryData The encoded binary representation.
640 * @param aPos The position from which to start decoding.
641 * @return The new CX509PolicyQualifierInfo object.
643 static CX509PolicyQualifierInfo* NewL(const TDesC8& aBinaryData, TInt& aPos);
648 * Creates a new CX509PolicyQualifierInfo object from the specified
649 * buffer containing the encoded binary representation, and puts a pointer to
650 * it onto the cleanup stack.
652 * @param aBinaryData The encoded binary representation.
653 * @param aPos The position from which to start decoding.
654 * @return The new CX509PolicyQualifierInfo object.
656 static CX509PolicyQualifierInfo* NewLC(const TDesC8& aBinaryData, TInt& aPos);
661 * Creates a new CX509PolicyQualifierInfo object from an existing X.509
662 * Policy Qualifier Information object.
664 * @param aQualifierInfo The CX509PolicyQualifierInfo object to be copied.
665 * @return The new CX509PolicyQualifierInfo object.
667 static CX509PolicyQualifierInfo* NewL(const CX509PolicyQualifierInfo& aQualifierInfo);
672 * Creates a new CX509PolicyQualifierInfo object from an existing X.509
673 * Policy Qualifier Information object, and puts a pointer to it onto the cleanup stack.
675 * @param aQualifierInfo The CX509PolicyQualifierInfo object to be copied.
676 * @return The new CX509PolicyQualifierInfo object.
678 static CX509PolicyQualifierInfo* NewLC(const CX509PolicyQualifierInfo& aQualifierInfo);
683 * Creates a new CX509PolicyQualifierInfo object from a stream.
685 * @return The new CX509PolicyQualifierInfo object.
687 static CX509PolicyQualifierInfo* NewL(RReadStream& aStream);
692 * Creates a new CX509PolicyQualifierInfo object from a stream, and puts a pointer to it onto
695 * @return The new CX509PolicyQualifierInfo object.
697 static CX509PolicyQualifierInfo* NewLC(RReadStream& aStream);
701 * Frees all resources owned by the object. */
702 virtual ~CX509PolicyQualifierInfo();
704 /** Gets the policy qualifier Id.
706 * @return A non-modifiable pointer descriptor representing the policy qualifier Id. */
707 IMPORT_C TPtrC Id() const;
709 /** Gets the policy qualifier data.
711 * @return A non-modifiable pointer descriptor representing the policy qualifier data. */
712 IMPORT_C TPtrC8 Data() const;
714 // Internalization/Externalization
715 // Externalize. Writes the data out to a stream
719 * Externalises an object of this class to a write stream.
721 * The presence of this function means that the standard templated operator<<()
722 * can be used to externalise objects of this class.
724 * @param aStream Stream to which the object should be externalised.
726 void ExternalizeL(RWriteStream& aStream) const;
728 // Internalize. Reads the data from a stream
732 * Internalises an object of this class from a read stream.
734 * The presence of this function means that the standard templated operator>>()
735 * can be used to internalise objects of this class.
737 * Note that this function has assignment semantics: it replaces the old value
738 * of the object with a new value read from the read stream.
740 * @param aStream Stream from which the object should be internalised.
742 void InternalizeL(RReadStream& aStream);
745 CX509PolicyQualifierInfo();
746 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
747 void ConstructL(const CX509PolicyQualifierInfo& aQualifier);
748 void ConstructL(RReadStream& aStream);
749 HBufC* iPolicyQualifierId;
750 HBufC8* iData; //opaque (this is another any-defined-by, so could be anything)
753 class CX509CertPolicyInfo : public CBase
754 /** Defines a specific policy followed by a Certification Authority.
756 * The policy under which a certificate has been issued may contain a number
757 * of these specific policies.
759 * @see CX509CertPoliciesExt
766 * Creates a new CX509CertPolicyInfo object from the specified buffer containing the
767 * binary coded representation.
769 * @param aBinaryData The encoded binary representation.
770 * @return The new CX509CertPolicyInfo object.
772 static CX509CertPolicyInfo* NewL(const TDesC8& aBinaryData);
777 * Creates a new CX509CertPolicyInfo object from the specified buffer containing the
778 * binary coded representation, and puts a pointer to it onto the cleanup stack.
780 * @param aBinaryData The encoded binary representation.
781 * @return The new CX509CertPolicyInfo object.
783 static CX509CertPolicyInfo* NewLC(const TDesC8& aBinaryData);
787 * Creates a new CX509CertPolicyInfo object from the specified buffer containing the
788 * binary coded representation, starting at the specified offset.
790 * @param aBinaryData The encoded binary representation.
791 * @param aPos The offset position from which to start decoding.
792 * @return The new CX509CertPolicyInfo object.
794 static CX509CertPolicyInfo* NewL(const TDesC8& aBinaryData, TInt& aPos);
799 * Creates a new CX509CertPolicyInfo object from the specified buffer containing the
800 * binary coded representation, starting at the specified offset, and puts a
801 * pointer to it onto the cleanup stack.
803 * @param aBinaryData The encoded binary representation.
804 * @param aPos The offset position from which to start decoding.
805 * @return The new CX509CertPolicyInfo object.
807 static CX509CertPolicyInfo* NewLC(const TDesC8& aBinaryData, TInt& aPos);
809 /** Creates a new CX509CertPolicyInfo object from an existing object.
811 * This is equivalent to a copy constructor.
813 * @param aPolicy The CX509CertPolicyInfo object to be copied.
814 * @return The new CX509CertPolicyInfo object. */
815 IMPORT_C static CX509CertPolicyInfo* NewL(const CX509CertPolicyInfo& aPolicy);
817 /** Creates a new CX509CertPolicyInfo object from an existing object, and puts a pointer
818 * to it onto the cleanup stack.
820 * This is equivalent to a copy constructor.
822 * @param aPolicy The CX509CertPolicyInfo object to be copied.
823 * @return The new CX509CertPolicyInfo object. */
824 IMPORT_C static CX509CertPolicyInfo* NewLC(const CX509CertPolicyInfo& aPolicy);
826 /** Creates a new CX509CertPolicyInfo object from a stream.
828 * @return The new CX509CertPolicyInfo object. */
829 IMPORT_C static CX509CertPolicyInfo* NewL(RReadStream& aStream);
831 /** Creates a new CX509CertPolicyInfo object from a stream, and puts a pointer to it onto
834 * @return The new CX509CertPolicyInfo object. */
835 IMPORT_C static CX509CertPolicyInfo* NewLC(RReadStream& aStream);
839 * Frees all resources owned by the object, prior to its destruction. */
840 virtual ~CX509CertPolicyInfo();
842 /** Gets a reference to the array of policy qualifers.
844 * @return The array of policy qualifiers. */
845 IMPORT_C const CArrayPtrFlat<CX509PolicyQualifierInfo>& Qualifiers() const;
847 /** Gets the specific policy's Object Identifier (OID).
849 * @return A pointer descriptor representing the specific policy's OID. */
850 IMPORT_C TPtrC Id() const;
853 // Internalization/Externalization
854 // Externalize. Writes the data out to a stream
855 /** Externalises an object of this class to a write stream.
857 * The presence of this function means that the standard templated operator<<()
858 * can be used to externalise objects of this class.
860 * @param aStream Stream to which the object should be externalised. */
861 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
863 // Internalize. Reads the data from a stream
864 /** Internalises an object of this class from a read stream.
866 * The presence of this function means that the standard templated operator>>()
867 * can be used to internalise objects of this class.
869 * Note that this function has assignment semantics: it replaces the old value
870 * of the object with a new value read from the read stream.
872 * @param aStream Stream from which the object should be internalised. */
873 IMPORT_C void InternalizeL(RReadStream& aStream);
877 CX509CertPolicyInfo();
878 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
879 void ConstructL(const CX509CertPolicyInfo& aInfo);
880 void ConstructL(RReadStream& aStream);
881 HBufC* iCertPolicyId;//OID for this policy
882 CArrayPtrFlat<CX509PolicyQualifierInfo>* iQualifiers;
885 class CX509CertPoliciesExt : public CX509ExtensionBase
886 /** The policy under which this certificate has been issued.
888 * Contains further information on a client's signature.
893 /** Creates a new CX509CertPoliciesExt object from the specified buffer
894 * containing the encoded binary representation.
896 * @param aBinaryData The encoded binary representation.
897 * @return The CX509CertPoliciesExt object. */
898 IMPORT_C static CX509CertPoliciesExt* NewL(const TDesC8& aBinaryData);
900 /** Creates a new CX509CertPoliciesExt object from the specified buffer
901 * containing the encoded binary representation, and puts a pointer to it onto
904 * @param aBinaryData The encoded binary representation.
905 * @return The CX509CertPoliciesExt object. */
906 IMPORT_C static CX509CertPoliciesExt* NewLC(const TDesC8& aBinaryData);
908 /** Creates a new CX509CertPoliciesExt object from the specified buffer
909 * containing the encoded binary representation, starting at the specified offset.
911 * @param aBinaryData The encoded binary representation.
912 * @param aPos The offset position from which to start decoding.
913 * @return The CX509CertPoliciesExt object. */
914 IMPORT_C static CX509CertPoliciesExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
916 /** Creates a new CX509CertPoliciesExt object from the specified buffer
917 * containing the encoded binary representation, and puts a pointer to it onto
920 * @param aBinaryData The encoded binary representation.
921 * @param aPos The offset position from which to start decoding.
922 * @return The CX509CertPoliciesExt object. */
923 IMPORT_C static CX509CertPoliciesExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
927 * Frees all resources owned by the object. */
928 virtual ~CX509CertPoliciesExt();
930 /** Gets the certificate policy extension information.
932 * @return The certificate policy extension information. */
933 IMPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& Policies() const;
935 CX509CertPoliciesExt();
936 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
937 CArrayPtrFlat<CX509CertPolicyInfo>* iPolicies;
942 class CX509PolicyMapping : public CBase
943 /** A set of policy mappings.
951 * Creates a new CX509PolicyMapping object from the specified buffer containing
952 * the encoded binary representation, and puts a pointer to it onto the cleanup stack.
954 * @param aBinaryData The encoded binary representation.
956 static CX509PolicyMapping* NewL(const TDesC8& aBinaryData);
961 * Creates a new CX509PolicyMapping object from the specified buffer containing
962 * the encoded binary representation, and puts a pointer to it onto the cleanup stack.
964 * @param aBinaryData The encoded binary representation.
966 static CX509PolicyMapping* NewLC(const TDesC8& aBinaryData);
971 * Creates a new CX509PolicyMapping object from the specified buffer containing
972 * the encoded binary representation, starting at the specified offset, and puts
973 * a pointer to it onto the cleanup stack.
975 * @param aBinaryData The encoded binary representation.
976 * @param aPos The position from which to start decoding.
978 static CX509PolicyMapping* NewL(const TDesC8& aBinaryData, TInt& aPos);
983 * Creates a new CX509PolicyMapping object from the specified buffer containing
984 * the encoded binary representation, starting at the specified offset, and puts
985 * a pointer to it onto the cleanup stack.
987 * @param aBinaryData The encoded binary representation.
988 * @param aPos The position from which to start decoding.
990 static CX509PolicyMapping* NewLC(const TDesC8& aBinaryData, TInt& aPos);
992 /** Creates a new CX509PolicyMapping object copied from an existing one.
994 * @param aMapping The CX509PolicyMapping object to be copied. */
995 IMPORT_C static CX509PolicyMapping* NewL(const CX509PolicyMapping& aMapping);
997 /** Creates a new CX509PolicyMapping object copied from an existing one, and
998 * puts a pointer to the object onto the cleanup stack.
1000 * @param aMapping The CX509PolicyMapping object to be copied. */
1001 IMPORT_C static CX509PolicyMapping* NewLC(const CX509PolicyMapping& aMapping);
1005 * Frees all resources owned by the object. */
1006 virtual ~CX509PolicyMapping();
1008 /** Gets the issuer policy.
1010 * @return The issuer policy. */
1011 IMPORT_C TPtrC IssuerPolicy() const;
1013 /** Gets the subject policy.
1015 * @return The subject policy. */
1016 IMPORT_C TPtrC SubjectPolicy() const;
1018 CX509PolicyMapping();
1019 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
1020 void ConstructL(const CX509PolicyMapping& aMapping);
1021 HBufC* iIssuerPolicy;
1022 HBufC* iSubjectPolicy;
1025 class CX509PolicyMappingExt : public CX509ExtensionBase
1026 /** An X.509 certificate extension that contains a set of policy mappings.
1028 * A policy mapping allows a Certification Authority to declare that two certificate
1029 * policies are equivalent.
1034 /** Creates a new CX509PolicyMappingExt object from the specified buffer containing
1035 * the binary coded representation.
1037 * @param aBinaryData The encoded binary representation.
1038 * @return The new CX509PolicyMappingExt object. */
1039 IMPORT_C static CX509PolicyMappingExt* NewL(const TDesC8& aBinaryData);
1041 /** Creates a new CX509PolicyMappingExt object from the specified buffer containing
1042 * the binary coded representation, and puts a pointer to it onto the cleanup stack.
1044 * @param aBinaryData The encoded binary representation.
1045 * @return The new CX509PolicyMappingExt object. */
1046 IMPORT_C static CX509PolicyMappingExt* NewLC(const TDesC8& aBinaryData);
1048 /** Creates a new CX509PolicyMappingExt object from the specified buffer containing
1049 * the binary coded representation, starting at the specified offset.
1051 * @param aBinaryData The encoded binary representation.
1052 * @param aPos The offset position from which to start decoding.
1053 * @return The new CX509PolicyMappingExt object. */
1054 IMPORT_C static CX509PolicyMappingExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
1056 /** Creates a new CX509PolicyMappingExt object from the specified buffer containing
1057 * the binary coded representation, starting at the specified offset, and puts
1058 * a pointer to it onto the cleanup stack.
1060 * @param aBinaryData The encoded binary representation.
1061 * @param aPos The offset position from which to start decoding.
1062 * @return The new CX509PolicyMappingExt object. */
1063 IMPORT_C static CX509PolicyMappingExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
1067 * Frees all resources owned by the object, prior to its destruction. */
1068 virtual ~CX509PolicyMappingExt();
1070 /** Gets a reference to the array of policy mappings.
1072 * @return The array of policy mappings. */
1073 IMPORT_C const CArrayPtrFlat<CX509PolicyMapping>& Mappings() const;
1075 CX509PolicyMappingExt();
1076 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
1077 CArrayPtrFlat<CX509PolicyMapping>* iPolicies;
1080 //8) authority key ID
1082 class CX509AuthorityKeyIdExt : public CX509ExtensionBase
1083 /** An X.509 certificate extension that provides a way to find the public key corresponding
1084 * to the private key used to sign the certificate.
1086 * This is referred to as the authority key ID extension.
1088 * The key may be identified by the issuer's name and the issuing certificate's
1089 * serial number, or by a key identifier value either derived from the public
1090 * key or by some method of generating unique IDs.
1095 /** Creates a new CX509AuthorityKeyIdExt object from the specified buffer containing
1096 * the binary coded representation.
1098 * @param aBinaryData The encoded binary representation.
1099 * @return The new CX509AuthorityKeyIdExt object. */
1100 IMPORT_C static CX509AuthorityKeyIdExt* NewL(const TDesC8& aBinaryData);
1102 /** Creates a new CX509AuthorityKeyIdExt object from the specified buffer containing
1103 * the binary coded representation, and puts a pointer to it onto the cleanup stack.
1105 * @param aBinaryData The encoded binary representation.
1106 * @return The new CX509AuthorityKeyIdExt object. */
1107 IMPORT_C static CX509AuthorityKeyIdExt* NewLC(const TDesC8& aBinaryData);
1109 /** Creates a new CX509AuthorityKeyIdExt object from the specified buffer containing
1110 * the binary coded representation, starting at the specified offset.
1112 * @param aBinaryData The encoded binary representation.
1113 * @param aPos The offset position from which to start decoding.
1114 * @return The new CX509AuthorityKeyIdExt object. */
1115 IMPORT_C static CX509AuthorityKeyIdExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
1117 /** Creates a new CX509AuthorityKeyIdExt object from the specified buffer containing
1118 * the binary coded representation, starting at the specified offset, and puts
1119 * a pointer to it onto the cleanup stack.
1121 * @param aBinaryData The encoded binary representation.
1122 * @param aPos The offset position from which to start decoding.
1123 * @return The new CX509AuthorityKeyIdExt object. */
1124 IMPORT_C static CX509AuthorityKeyIdExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
1128 * Frees all resources owned by the object, prior to its destruction. */
1129 virtual ~CX509AuthorityKeyIdExt();
1131 /** Gets the authority name.
1133 * @return The authority name. */
1134 IMPORT_C const CArrayPtrFlat<CX509GeneralName>& AuthorityName() const;
1136 /** Gets the authority certificate serial number.
1138 * @return A pointer descriptor representing the authority certificate serial number. */
1139 IMPORT_C TPtrC8 AuthorityCertSerialNumber() const;
1141 /** Gets the key identifier value.
1143 * @return A pointer descriptor representing the key identifier value. */
1144 IMPORT_C TPtrC8 KeyId() const;
1146 CX509AuthorityKeyIdExt();
1147 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
1148 void DecodeNameL(const TDesC8& aBinaryData);
1149 void DecodeSerialNoL(const TDesC8& aBinaryData);
1150 void DecodeKeyIdL(const TDesC8& aBinaryData);
1151 CArrayPtrFlat<CX509GeneralName>* iAuthorityName;
1152 HBufC8* iAuthorityCertSerialNumber;
1153 HBufC8* iKeyIdentifier;
1158 class CX509SubjectKeyIdExt : public CX509ExtensionBase
1159 /** An X.509 certificate extension that provides a way of identifying certificates
1160 * that contain a specific public key.
1162 * This is referred to as the subject key ID extension.
1164 * It consists of a key identifier value either derived from the public key or
1165 * by some method of generating unique IDs.
1170 /** Creates a new CX509SubjectKeyIdExt object from the specified buffer containing
1171 * the binary coded representation.
1173 * @param aBinaryData The encoded binary representation.
1174 * @return The new CX509SubjectKeyIdExt object. */
1175 IMPORT_C static CX509SubjectKeyIdExt* NewL(const TDesC8& aBinaryData);
1177 /** Creates a new CX509SubjectKeyIdExt object from the specified buffer containing
1178 * the binary coded representation, and puts a pointer to it onto the cleanup stack.
1180 * @param aBinaryData The encoded binary representation.
1181 * @return The new CX509SubjectKeyIdExt object. */
1182 IMPORT_C static CX509SubjectKeyIdExt* NewLC(const TDesC8& aBinaryData);
1184 /** Creates a new CX509SubjectKeyIdExt object from the specified buffer containing
1185 * the binary coded representation, starting at the specified offset.
1187 * @param aBinaryData The encoded binary representation.
1188 * @param aPos The offset position from which to start decoding.
1189 * @return The new CX509SubjectKeyIdExt object. */
1190 IMPORT_C static CX509SubjectKeyIdExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
1192 /** Creates a new CX509SubjectKeyIdExt object from the specified buffer containing
1193 * the binary coded representation, starting at the specified offset, and puts
1194 * a pointer to it onto the cleanup stack.
1196 * @param aBinaryData The encoded binary representation.
1197 * @param aPos The offset position from which to start decoding.
1198 * @return The new CX509SubjectKeyIdExt object. */
1199 IMPORT_C static CX509SubjectKeyIdExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
1203 * Frees all resources owned by the object, prior to its destruction. */
1204 IMPORT_C ~CX509SubjectKeyIdExt();
1206 /** Gets the key ID.
1208 * @return A pointer descriptor representing the key ID. */
1209 IMPORT_C TPtrC8 KeyId() const;
1211 CX509SubjectKeyIdExt();
1212 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
1213 HBufC8* iKeyIdentifier;
1216 //10) extended key usage
1218 class CX509ExtendedKeyUsageExt : public CX509ExtensionBase
1219 /** An X.509 certificate extension that defines the extra uses to which a key may be put.
1221 * This is referred to as the extended key usage extension.
1226 /** Creates a new CX509ExtendedKeyUsageExt object from the specified buffer
1227 * containing the binary coded representation.
1229 * @param aBinaryData The encoded binary data.
1230 * @return The new CX509ExtendedKeyUsageExt object. */
1231 IMPORT_C static CX509ExtendedKeyUsageExt* NewL(const TDesC8& aBinaryData);
1233 /** Creates a new CX509ExtendedKeyUsageExt object from the specified buffer
1234 * containing the binary coded representation, and puts a pointer to it onto
1235 * the cleanup stack.
1237 * @param aBinaryData The encoded binary representation.
1238 * @return The new CX509ExtendedKeyUsageExt object. */
1239 IMPORT_C static CX509ExtendedKeyUsageExt* NewLC(const TDesC8& aBinaryData);
1241 /** Creates a new CX509ExtendedKeyUsageExt object from the specified buffer
1242 * containing the binary coded representation, starting at the specified offset.
1244 * @param aBinaryData The encoded binary representation.
1245 * @param aPos The offset position from which to start decoding.
1246 * @return The new CX509ExtendedKeyUsageExt object. */
1247 IMPORT_C static CX509ExtendedKeyUsageExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
1249 /** Creates a new CX509ExtendedKeyUsageExt object from the specified buffer
1250 * containing the binary coded representation, starting at the specified offset,
1251 * and puts a pointer to it onto the cleanup stack.
1253 * @param aBinaryData The encoded binary representation.
1254 * @param aPos The offset position from which to start decoding.
1255 * @return The new CX509ExtendedKeyUsageExt object. */
1256 IMPORT_C static CX509ExtendedKeyUsageExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
1260 * Frees all resources owned by the object, prior to its destruction. */
1261 IMPORT_C ~CX509ExtendedKeyUsageExt();
1263 /** Gets the sequence of Object Ids (OID) that identify the key usages.
1265 * The sequence is held in a set of heap descriptors.
1267 * @return A reference to the array of pointers to the heap descriptors that
1268 * contain the OIDs. */
1269 IMPORT_C const CArrayPtrFlat<HBufC>& KeyUsages() const;
1271 CX509ExtendedKeyUsageExt();
1272 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
1273 CArrayPtrFlat<HBufC>* iKeyUsages;
1276 //11) authority information access
1278 class CX509AccessDescription : public CBase
1279 /** This class provides the access method OID and access location as used by X.509 private internet extensions
1280 * (authority information access).
1287 * @internalComponent
1289 * Creates a new CX509AccessDescription object from the specified buffer
1290 * containing the binary coded representation.
1292 * @param aBinaryData The encoded binary data.
1293 * @return The new CX509AccessDescription object.
1295 static CX509AccessDescription* NewL(const TDesC8& aBinaryData);
1298 * @internalComponent
1300 * Creates a new CX509AccessDescription object from the specified buffer
1301 * containing the binary coded representation, and puts a pointer to it onto
1302 * the cleanup stack.
1304 * @param aBinaryData The encoded binary representation.
1305 * @return The new CX509AccessDescription object.
1307 static CX509AccessDescription* NewLC(const TDesC8& aBinaryData);
1310 * @internalComponent
1312 * Creates a new CX509AuthInfoAccessExt object from the specified buffer
1313 * containing the binary coded representation, starting at the specified offset.
1315 * @param aBinaryData The encoded binary representation.
1316 * @param aPos The offset position from which to start decoding.
1317 * @return The new CX509AuthInfoAccessExt object.
1319 static CX509AccessDescription* NewL(const TDesC8& aBinaryData, TInt& aPos);
1322 * @internalComponent
1324 * Creates a new CX509AccessDescription object from the specified buffer
1325 * containing the binary coded representation, starting at the specified offset,
1326 * and puts a pointer to it onto the cleanup stack.
1328 * @param aBinaryData The encoded binary representation.
1329 * @param aPos The offset position from which to start decoding.
1330 * @return The new CX509AccessDescription object.
1332 static CX509AccessDescription* NewLC(const TDesC8& aBinaryData, TInt& aPos);
1334 /** Destructor. Frees all resources owned by the object, prior to its destruction.
1336 virtual ~CX509AccessDescription();
1338 /** Gets the Access Method OID.
1340 * @return A non modifiable pointer descriptor to point to the access method OID.
1342 IMPORT_C TPtrC Method() const;
1344 /** Gets the Access Location field which specifies the location where the additional
1345 * information of the CA can be obtained.
1347 * @return A reference to access location .
1349 IMPORT_C const CX509GeneralName& Location() const;
1351 CX509AccessDescription();
1352 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
1354 CX509GeneralName* iLocation;
1357 class CX509AuthInfoAccessExt : public CX509ExtensionBase
1358 /** An X.509 certificate extension that defines the authority information access.
1366 /** Creates a new CX509AuthInfoAccessExt object from the specified buffer
1367 * containing the binary coded representation.
1369 * @param aBinaryData The encoded binary data.
1370 * @return The new CX509AuthInfoAccessExt object.
1372 IMPORT_C static CX509AuthInfoAccessExt* NewL(const TDesC8& aBinaryData);
1374 /** Creates a new CX509AuthInfoAccessExt object from the specified buffer
1375 * containing the binary coded representation, and puts a pointer to it onto
1376 * the cleanup stack.
1378 * @param aBinaryData The encoded binary representation.
1379 * @return The new CX509AuthInfoAccessExt object.
1381 IMPORT_C static CX509AuthInfoAccessExt* NewLC(const TDesC8& aBinaryData);
1383 /** Creates a new CX509AuthInfoAccessExt object from the specified buffer
1384 * containing the binary coded representation, starting at the specified offset.
1386 * @param aBinaryData The encoded binary representation.
1387 * @param aPos The offset position from which to start decoding.
1388 * @return The new CX509AuthInfoAccessExt object.
1390 IMPORT_C static CX509AuthInfoAccessExt* NewL(const TDesC8& aBinaryData, TInt& aPos);
1392 /** Creates a new CX509AuthInfoAccessExt object from the specified buffer
1393 * containing the binary coded representation, starting at the specified offset,
1394 * and puts a pointer to it onto the cleanup stack.
1396 * @param aBinaryData The encoded binary representation.
1397 * @param aPos The offset position from which to start decoding.
1398 * @return The new CX509AuthInfoAccessExt object.
1400 IMPORT_C static CX509AuthInfoAccessExt* NewLC(const TDesC8& aBinaryData, TInt& aPos);
1402 /** Destructor. Frees all resources owned by the object, prior to its destruction.
1404 IMPORT_C ~CX509AuthInfoAccessExt();
1406 /** Gets the authority access description containing the method and location of additional information of CA ,
1407 * who issued the certificate in which this extension appears.
1409 * @return A reference to the array of pointers to the authority access descriptions.
1411 IMPORT_C const CArrayPtrFlat<CX509AccessDescription>& AccessDescriptions() const;
1413 CX509AuthInfoAccessExt();
1414 void DoConstructL(const TDesC8& aBinaryData, TInt& aPos);
1415 CArrayPtrFlat<CX509AccessDescription>* iAccessDescs;