Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 2001-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.
27 #ifndef __CCTCERTINFO_H__
28 #define __CCTCERTINFO_H__
33 #include <securitydefs.h>
34 #include <ct/mcttokentype.h>
35 #include <ct/mcttoken.h>
36 #include <ct/mcttokenobject.h>
38 /** Mask constants used for serializing iDeletable and iFormat attributes
40 const TUint KReadOnlyFlagMask = 128;
41 const TUint KFormatMask = 127;
43 /** The UID of a CertInfo MCTTokenObject. */
44 const TInt KCTObjectCertInfo = 0x101F50E6;
46 /** The maximum length of a certificate label. */
47 const TUint32 KMaxCertLabelLength = 64;
49 /** Defines a modifiable buffer descriptor to contain a human-readable certificate label.
53 typedef TBuf<KMaxCertLabelLength> TCertLabel;
56 * Mix-in class representnig data about a stored certificate. Provides
57 * implementation of serialization.
59 * Note that for backward compatibility reasons, the issuer hash is not serialised.
66 // Internalization/Externalization
67 // Externalize. Writes the data out to a stream
69 /** Externalises an object of this class to a write stream.
71 * The presence of this function means that the standard templated operator<<()
72 * can be used to externalise objects of this class.
74 * @param aStream Stream to which the object should be externalised. */
75 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
77 // Internalize. Reads the data from a stream
78 /** Internalises an object of this class from a read stream.
80 * The presence of this function means that the standard templated operator>>()
81 * can be used to internalise objects of this class.
83 * Note that this function has assignment semantics: it replaces the old value
84 * of the object with a new value read from the read stream.
86 * @param aStream Stream from which the object should be internalised. */
87 IMPORT_C void InternalizeL(RReadStream& aStream);
91 IMPORT_C MCertInfo(const TDesC& aLabel,
92 TCertificateFormat aFormat,
93 TCertificateOwnerType aCertificateOwnerType,
95 const TKeyIdentifier* aSubjectKeyId,
96 const TKeyIdentifier* aIssuerKeyId,
99 IMPORT_C MCertInfo(const MCertInfo& aOther);
100 IMPORT_C ~MCertInfo();
102 IMPORT_C void ConstructL(const TDesC8* aIssuerHash);
104 const TDesC8* IssuerHash() const;
108 const MCertInfo& operator=(const MCertInfo& aOther);
113 TCertificateFormat iFormat;
114 TCertificateOwnerType iCertificateOwnerType;
116 TKeyIdentifier iSubjectKeyId;
117 TKeyIdentifier iIssuerKeyId;
124 /** Encapsulates information about a stored certificate.
126 * Objects of this type are usually returned by a certificate store, to allow
127 * a client to query the contents of the store.
129 * Note that these objects are normally constructed by certificate stores, not
135 class CCTCertInfo : protected CBase, public MCTTokenObject, public MCertInfo
138 /** Construction -- Note that these objects are normally constructed by certificate stores, not by clients. */
144 * Creates the certificate information object by copying from an existing object.
146 * @param aCertInfo The source certificate information.
147 * @return A pointer to the new certificate information object.
148 * @leave KErrNoMemory There is no memory to construct it. */
149 IMPORT_C static CCTCertInfo* NewL(const CCTCertInfo& aCertInfo);
155 * Creates the certificate information object by copying from an existing object,
156 * and puts a pointer to the new object onto the cleanup stack.
158 * @param aCertInfo The source certificate information.
159 * @return A pointer to the new certificate information object.
160 * @leave KErrNoMemory There is no memory to construct it. */
161 IMPORT_C static CCTCertInfo* NewLC(const CCTCertInfo& aCertInfo);
167 * Creates the certificate information object from its constituent parts.
169 * @param aLabel The certificate's label.
170 * @param aFormat The certificate's format.
171 * @param aCertificateOwnerType The owner type.
172 * @param aSize The size of the certificate.
173 * @param aSubjectKeyId The subject key ID.
174 * @param aIssuerKeyId The issuer key ID.
175 * @param aToken The token that the certificate is within.
176 * @param aCertificateId The ID within the object handle.
177 * @param aDeletable The certificate is deletable.
178 * @param aIssuerHash The hash of the DN of the issuer.
179 * @return A pointer to the new certificate information object.
180 * @leave KErrNoMemory There is no memory to construct it.*/
181 IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
182 TCertificateOwnerType aCertificateOwnerType, TInt aSize,
183 const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
184 MCTToken& aToken, TInt aCertificateId, TBool aDeletable,
185 const TDesC8* aIssuerHash = NULL);
191 * Creates the certificate information object from its constituent parts.
193 * @param aLabel The certificate's label.
194 * @param aFormat The certificate's format.
195 * @param aCertificateOwnerType The owner type.
196 * @param aSize The size of the certificate.
197 * @param aSubjectKeyId The subject key ID.
198 * @param aIssuerKeyId The issuer key ID.
199 * @param aToken The token that the certificate is within.
200 * @param aCertificateId The ID within the object handle.
201 * @return A pointer to the new certificate information object.
202 * @leave KErrNoMemory There is no memory to construct it.*/
203 IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
204 TCertificateOwnerType aCertificateOwnerType, TInt aSize,
205 const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
206 MCTToken& aToken, TInt aCertificateId);
212 * Creates the certificate information object from its constituent parts,
213 * and puts a pointer to the new object onto the cleanup stack.
215 * @param aLabel The certificate's label.
216 * @param aFormat The certificate's format.
217 * @param aCertificateOwnerType The owner type.
218 * @param aSize The size of the certificate.
219 * @param aSubjectKeyId The subject key ID.
220 * @param aIssuerKeyId The issuer key ID.
221 * @param aToken The token that the certificate is within.
222 * @param aCertificateId The ID within the object handle.
223 * @param aDeletable The certificate is deletable.
224 * @param aIssuerHash The hash of the issuer's DN.
225 * @return A pointer to the new certificate information object.
226 * @leave KErrNoMemory There is no memory to construct it.*/
227 IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
228 TCertificateOwnerType aCertificateOwnerType, TInt aSize,
229 const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
230 MCTToken& aToken, TInt aCertificateId, TBool aDeletable,
231 const TDesC8* aIssuerHash = NULL);
237 * Creates the certificate information object from its constituent parts, and puts
238 * a pointer to the new object onto the cleanup stack.
240 * @param aLabel The certificate's label.
241 * @param aFormat The certificate's format.
242 * @param aCertificateOwnerType The owner type.
243 * @param aSize The size of the certificate.
244 * @param aSubjectKeyId The subject key ID.
245 * @param aIssuerKeyId The issuer key ID.
246 * @param aToken The token that the certificate is within.
247 * @param aCertificateId The ID within the object handle.
248 * @return A pointer to the new certificate information object.
249 * @leave KErrNoMemory There is no memory to construct it.*/
250 IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
251 TCertificateOwnerType aCertificateOwnerType, TInt aSize,
252 const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
253 MCTToken& aToken, TInt aCertificateId);
259 * Creates the certificate information object by internalising a previously externalised
262 * @param aStream The stream from which the object is to be internalised.
263 * @param aToken The token that it is within.
264 * @return A pointer to the new certificate information object.
265 * @leave KErrNoMemory There is no memory to construct it.
267 * @see InternalizeL */
268 IMPORT_C static CCTCertInfo* NewL(RReadStream& aStream, MCTToken& aToken);
274 * Creates the certificate information object, by internalising a previously externalised
275 * one, and puts a pointer to the new object onto the cleanup stack.
277 * @param aStream The stream from which the object is to be internalised.
278 * @param aToken The token that it is within.
279 * @return A pointer to the new certificate information object.
280 * @leave KErrNoMemory There is no memory to construct it.
282 * @see InternalizeL */
283 IMPORT_C static CCTCertInfo* NewLC(RReadStream& aStream, MCTToken& aToken);
285 /** Gets the subject key ID.
287 * @return A reference to a key identifier object. */
288 IMPORT_C const TKeyIdentifier& SubjectKeyId() const;
290 /** Gets the issuer key ID.
292 * @return A reference to a key identifier object. */
293 IMPORT_C const TKeyIdentifier& IssuerKeyId() const;
295 /** Gets the certificate format.
297 * @return The certificate format. */
298 IMPORT_C TCertificateFormat CertificateFormat() const;
300 /** Gets the owner type.
302 * @return The owner type. */
303 IMPORT_C TCertificateOwnerType CertificateOwnerType() const;
305 /** Gets the size of the certificate.
307 * Note that this function must be called so that the correct size of descriptor
308 * can be allocated when retrieving the certificate (with MCertStore::Retrieve()).
310 * @return The size of the certificate. */
311 IMPORT_C TInt Size() const;
313 /** Gets a handle for the object.
315 * The primary purpose of the handle is to allow token objects to be 'passed'
318 * @return A handle for the object.
319 * @see TCTTokenObjectHandle */
320 IMPORT_C TCTTokenObjectHandle Handle() const;
322 /** Whether the certificate is deletable.
324 * @return ETrue if it is possible to delete the certificate; EFalse, otherwise. */
325 IMPORT_C TBool IsDeletable() const;
327 /** Gets the hash of the issuer's DN.
329 * @return The hash of the issuer's DN, or NULL if not known. */
330 IMPORT_C const TDesC8* IssuerHash() const;
333 // from MCTTokenObject
334 /** Gets the object's human-readable label.
336 * @return The object's human-readable label.
337 * @see MCTTokenObject::Label()*/
338 virtual const TDesC& Label() const;
340 /** Gets a reference to the associated token.
342 * @return A reference to the associated token.
343 * @see MCTTokenObject::Token()*/
344 virtual MCTToken& Token() const;
346 /** Gets a UID representing the type of the token object.
348 * The function overrides MCTTokenObject::Type().
350 * The meanings of possible UIDs should be documented in the documentation for
351 * the interface that returns them.
353 * @return A UID representing the type of the token object; this implementation
354 * returns KCTObjectCertInfo.
355 * @see MCTTokenObject::Type() */
356 virtual TUid Type() const;
358 // Compares 2 cert infos
359 /** Compares this certificate information object with a specified Certificate
360 * Information object for equality.
362 * @param aCertInfo The certificate information object to be compared.
363 * @return ETrue, if they are the same; EFalse, otherwise. */
364 IMPORT_C TBool operator ==(const CCTCertInfo& aCertInfo) const;
366 /** Sets the certificate Id.
368 * @param aCertId The certificate Id.*/
369 IMPORT_C void SetCertificateId(TInt aCertId);
372 IMPORT_C virtual ~CCTCertInfo();
375 CCTCertInfo(MCTToken& aToken);
376 CCTCertInfo(const TDesC& aLabel, TCertificateFormat aFormat,
377 TCertificateOwnerType aCertificateOwnerType,
379 const TKeyIdentifier* aSubjectKeyId,
380 const TKeyIdentifier* aIssuerKeyId,
381 MCTToken& aToken, TInt aCertificateId,
383 CCTCertInfo(const CCTCertInfo& aCertInfo);
384 void ConstructL(RReadStream& aStream);
385 void ConstructL(const TDesC8* aIssuerHash);
388 const CCTCertInfo& operator=(const CCTCertInfo& aOther);