os/security/cryptomgmtlibs/cryptotokenfw/inc_interfaces/CCTCertInfo_v2.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* CCTCertInfo.H
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file 
sl@0
    22
 @publishedAll
sl@0
    23
 @released
sl@0
    24
*/
sl@0
    25
 
sl@0
    26
#ifndef __CCTCERTINFO_H__
sl@0
    27
#define __CCTCERTINFO_H__
sl@0
    28
sl@0
    29
#include <e32base.h>
sl@0
    30
#include <s32strm.h>
sl@0
    31
sl@0
    32
#include <securitydefs.h>
sl@0
    33
#include <ct/mcttokentype.h>
sl@0
    34
#include <ct/mcttoken.h>
sl@0
    35
#include <ct/mcttokenobject.h>
sl@0
    36
sl@0
    37
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    38
sl@0
    39
/** Mask constants used for serializing iDeletable and iFormat attributes 
sl@0
    40
*/
sl@0
    41
const TUint KReadOnlyFlagMask = 128;
sl@0
    42
const TUint KFormatMask = 127;
sl@0
    43
sl@0
    44
/** The UID of a CertInfo MCTTokenObject. */
sl@0
    45
const TInt KCTObjectCertInfo = 0x101F50E6;
sl@0
    46
sl@0
    47
#endif
sl@0
    48
sl@0
    49
/** The maximum length of a certificate label. */
sl@0
    50
const TUint32 KMaxCertLabelLength = 64;
sl@0
    51
sl@0
    52
/** Defines a modifiable buffer descriptor to contain a human-readable certificate label. 
sl@0
    53
*
sl@0
    54
*/
sl@0
    55
typedef TBuf<KMaxCertLabelLength> TCertLabel;
sl@0
    56
sl@0
    57
/**
sl@0
    58
 * Mix-in class representnig data about a stored certificate.  Provides
sl@0
    59
 * implementation of serialization.
sl@0
    60
 * 
sl@0
    61
 * Note that for backward compatibility reasons, the issuer hash is not serialised.
sl@0
    62
 *
sl@0
    63
 */
sl@0
    64
class MCertInfo
sl@0
    65
	{
sl@0
    66
 public:
sl@0
    67
	// Internalization/Externalization
sl@0
    68
	// Externalize. Writes the data out to a stream
sl@0
    69
	
sl@0
    70
  /** Externalises an object of this class to a write stream.
sl@0
    71
	* 
sl@0
    72
	* The presence of this function means that the standard templated operator<<() 
sl@0
    73
	* can be used to externalise objects of this class.
sl@0
    74
	* 
sl@0
    75
	* @param aStream	Stream to which the object should be externalised. */
sl@0
    76
	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
sl@0
    77
sl@0
    78
	// Internalize. Reads the data from a stream 
sl@0
    79
	/** Internalises an object of this class from a read stream.
sl@0
    80
	* 
sl@0
    81
	* The presence of this function means that the standard templated operator>>() 
sl@0
    82
	* can be used to internalise objects of this class.
sl@0
    83
	* 
sl@0
    84
	* Note that this function has assignment semantics: it replaces the old value 
sl@0
    85
	* of the object with a new value read from the read stream.	
sl@0
    86
	* 
sl@0
    87
	* @param aStream	Stream from which the object should be internalised. */
sl@0
    88
	IMPORT_C void InternalizeL(RReadStream& aStream);
sl@0
    89
	
sl@0
    90
 protected:
sl@0
    91
	IMPORT_C MCertInfo();
sl@0
    92
	IMPORT_C MCertInfo(const TDesC& aLabel,
sl@0
    93
					   TCertificateFormat aFormat,
sl@0
    94
					   TCertificateOwnerType aCertificateOwnerType, 
sl@0
    95
					   TInt aSize,
sl@0
    96
					   const TKeyIdentifier* aSubjectKeyId,
sl@0
    97
					   const TKeyIdentifier* aIssuerKeyId, 
sl@0
    98
					   TInt aCertificateId,
sl@0
    99
					   TBool aDeletable);
sl@0
   100
	IMPORT_C MCertInfo(const MCertInfo& aOther);
sl@0
   101
	IMPORT_C ~MCertInfo();
sl@0
   102
sl@0
   103
	IMPORT_C void ConstructL(const TDesC8* aIssuerHash);
sl@0
   104
sl@0
   105
	const TDesC8* IssuerHash() const;
sl@0
   106
sl@0
   107
 private:
sl@0
   108
	TBool Valid() const;
sl@0
   109
	const MCertInfo& operator=(const MCertInfo& aOther);
sl@0
   110
sl@0
   111
 protected:
sl@0
   112
	TCertLabel iLabel;
sl@0
   113
	TInt iCertificateId;
sl@0
   114
	TCertificateFormat iFormat;
sl@0
   115
	TCertificateOwnerType iCertificateOwnerType;
sl@0
   116
	TInt iSize;
sl@0
   117
	TKeyIdentifier iSubjectKeyId;
sl@0
   118
	TKeyIdentifier iIssuerKeyId;
sl@0
   119
	TBool iDeletable;
sl@0
   120
sl@0
   121
 private:
sl@0
   122
	HBufC8* iIssuerHash;
sl@0
   123
	};
sl@0
   124
sl@0
   125
/** Encapsulates information about a stored certificate.
sl@0
   126
 * 
sl@0
   127
 * Objects of this type are usually returned by a certificate store, to allow 
sl@0
   128
 * a client to query the contents of the store.
sl@0
   129
 * 
sl@0
   130
 * Note that these objects are normally constructed by certificate stores, not 
sl@0
   131
 * by clients. 
sl@0
   132
 *
sl@0
   133
 */
sl@0
   134
class CCTCertInfo : protected CBase, public MCTTokenObject, public MCertInfo
sl@0
   135
	{
sl@0
   136
public:
sl@0
   137
	/** Construction -- Note that these objects are normally constructed by certificate stores, not by clients. */
sl@0
   138
sl@0
   139
	/** 
sl@0
   140
	*
sl@0
   141
	* Creates the certificate information object by copying from an existing object.
sl@0
   142
	* 
sl@0
   143
	* @param aCertInfo			The source certificate information.
sl@0
   144
	* @return					A pointer to the new certificate information object.
sl@0
   145
	* @leave KErrNoMemory	There is no memory to construct it. */
sl@0
   146
	IMPORT_C static CCTCertInfo* NewL(const CCTCertInfo& aCertInfo);
sl@0
   147
sl@0
   148
	/** 
sl@0
   149
	*
sl@0
   150
	* Creates the certificate information object by copying from an existing object, 
sl@0
   151
	* and puts a pointer to the new object onto the cleanup stack.
sl@0
   152
	* 
sl@0
   153
	* @param aCertInfo			The source certificate information.
sl@0
   154
	* @return					A pointer to the new certificate information object.
sl@0
   155
	* @leave KErrNoMemory	There is no memory to construct it. */
sl@0
   156
	IMPORT_C static CCTCertInfo* NewLC(const CCTCertInfo& aCertInfo);
sl@0
   157
sl@0
   158
	/** 
sl@0
   159
	*
sl@0
   160
	* Creates the certificate information object from its constituent parts.
sl@0
   161
	* 
sl@0
   162
	* @param aLabel					The certificate's label.
sl@0
   163
	* @param aFormat				The certificate's format.
sl@0
   164
	* @param aCertificateOwnerType	The owner type.
sl@0
   165
	* @param aSize					The size of the certificate.
sl@0
   166
	* @param aSubjectKeyId			The subject key ID.
sl@0
   167
	* @param aIssuerKeyId			The issuer key ID.
sl@0
   168
	* @param aToken					The token that the certificate is within.
sl@0
   169
	* @param aCertificateId			The ID within the object handle.
sl@0
   170
	* @param aDeletable				The certificate is deletable.
sl@0
   171
	* @param aIssuerHash			The hash of the DN of the issuer.
sl@0
   172
	* @return						A pointer to the new certificate information object. 
sl@0
   173
	* @leave KErrNoMemory		There is no memory to construct it.*/
sl@0
   174
	IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
sl@0
   175
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
sl@0
   176
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
sl@0
   177
		MCTToken& aToken, TInt aCertificateId, TBool aDeletable, 
sl@0
   178
									  const TDesC8* aIssuerHash = NULL);
sl@0
   179
sl@0
   180
	/** 
sl@0
   181
	*
sl@0
   182
	* Creates the certificate information object from its constituent parts.	
sl@0
   183
	* 
sl@0
   184
	* @param aLabel					The certificate's label.
sl@0
   185
	* @param aFormat 				The certificate's format.
sl@0
   186
	* @param aCertificateOwnerType	The owner type.
sl@0
   187
	* @param aSize					The size of the certificate.
sl@0
   188
	* @param aSubjectKeyId			The subject key ID.
sl@0
   189
	* @param aIssuerKeyId			The issuer key ID.
sl@0
   190
	* @param aToken					The token that the certificate is within.
sl@0
   191
	* @param aCertificateId			The ID within the object handle.
sl@0
   192
	* @return 						A pointer to the new certificate information object.
sl@0
   193
	* @leave KErrNoMemory		There is no memory to construct it.*/
sl@0
   194
	IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
sl@0
   195
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
sl@0
   196
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
sl@0
   197
		MCTToken& aToken, TInt aCertificateId);
sl@0
   198
sl@0
   199
	/** 
sl@0
   200
	* 
sl@0
   201
	* Creates the certificate information object from its constituent parts, 
sl@0
   202
	* and puts a pointer to the new object onto the cleanup stack.
sl@0
   203
	* 
sl@0
   204
	* @param aLabel					The certificate's label.
sl@0
   205
	* @param aFormat				The certificate's format.
sl@0
   206
	* @param aCertificateOwnerType	The owner type.
sl@0
   207
	* @param aSize					The size of the certificate.
sl@0
   208
	* @param aSubjectKeyId			The subject key ID.
sl@0
   209
	* @param aIssuerKeyId			The issuer key ID.
sl@0
   210
	* @param aToken					The token that the certificate is within.
sl@0
   211
	* @param aCertificateId			The ID within the object handle.
sl@0
   212
	* @param aDeletable				The certificate is deletable.
sl@0
   213
	* @param aIssuerHash			The hash of the issuer's DN.
sl@0
   214
	* @return						A pointer to the new certificate information object. 
sl@0
   215
	* @leave KErrNoMemory		There is no memory to construct it.*/
sl@0
   216
	IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
sl@0
   217
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
sl@0
   218
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
sl@0
   219
		MCTToken& aToken, TInt aCertificateId, TBool aDeletable, 
sl@0
   220
									   const TDesC8* aIssuerHash = NULL);
sl@0
   221
sl@0
   222
	/**
sl@0
   223
	*
sl@0
   224
	* Creates the certificate information object from its constituent parts, and puts 
sl@0
   225
	* a pointer to the new object onto the cleanup stack.
sl@0
   226
	* 
sl@0
   227
	* @param aLabel					The certificate's label.
sl@0
   228
	* @param aFormat				The certificate's format.
sl@0
   229
	* @param aCertificateOwnerType	The owner type.
sl@0
   230
	* @param aSize					The size of the certificate.
sl@0
   231
	* @param aSubjectKeyId			The subject key ID.
sl@0
   232
	* @param aIssuerKeyId			The issuer key ID.
sl@0
   233
	* @param aToken					The token that the certificate is within.
sl@0
   234
	* @param aCertificateId			The ID within the object handle.
sl@0
   235
	* @return						A pointer to the new certificate information object.
sl@0
   236
	* @leave KErrNoMemory		There is no memory to construct it.*/
sl@0
   237
	IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
sl@0
   238
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
sl@0
   239
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
sl@0
   240
		MCTToken& aToken, TInt aCertificateId);
sl@0
   241
sl@0
   242
	/** 
sl@0
   243
	* 
sl@0
   244
	* Creates the certificate information object by internalising a previously externalised 
sl@0
   245
	* one.
sl@0
   246
	* 
sl@0
   247
	* @param aStream			The stream from which the object is to be internalised.
sl@0
   248
	* @param aToken				The token that it is within.
sl@0
   249
	* @return					A pointer to the new certificate information object. 
sl@0
   250
	* @leave KErrNoMemory	There is no memory to construct it.
sl@0
   251
	* @see ExternalizeL
sl@0
   252
	* @see InternalizeL */
sl@0
   253
	IMPORT_C static CCTCertInfo* NewL(RReadStream& aStream, MCTToken& aToken);
sl@0
   254
sl@0
   255
	/** 
sl@0
   256
	* 
sl@0
   257
	* Creates the certificate information object, by internalising a previously externalised 
sl@0
   258
	* one, and puts a pointer to the new object onto the cleanup stack.	
sl@0
   259
	* 
sl@0
   260
	* @param aStream			The stream from which the object is to be internalised.
sl@0
   261
	* @param aToken				The token that it is within.
sl@0
   262
	* @return					A pointer to the new certificate information object. 
sl@0
   263
	* @leave KErrNoMemory	There is no memory to construct it.
sl@0
   264
	* @see ExternalizeL
sl@0
   265
	* @see InternalizeL */
sl@0
   266
	IMPORT_C static CCTCertInfo* NewLC(RReadStream& aStream, MCTToken& aToken);
sl@0
   267
sl@0
   268
	/** Gets the subject key ID.	
sl@0
   269
	* 
sl@0
   270
	* @return A reference to a key identifier object. */
sl@0
   271
	IMPORT_C const TKeyIdentifier& SubjectKeyId() const;
sl@0
   272
sl@0
   273
	/** Gets the issuer key ID.
sl@0
   274
	* 
sl@0
   275
	* @return A reference to a key identifier object. */
sl@0
   276
	IMPORT_C const TKeyIdentifier& IssuerKeyId() const;
sl@0
   277
sl@0
   278
	/** Gets the certificate format.
sl@0
   279
	* 
sl@0
   280
	* @return The certificate format. */
sl@0
   281
	IMPORT_C TCertificateFormat CertificateFormat() const;
sl@0
   282
sl@0
   283
	/** Gets the owner type.
sl@0
   284
	* 
sl@0
   285
	* @return The owner type. */
sl@0
   286
	IMPORT_C TCertificateOwnerType CertificateOwnerType() const;
sl@0
   287
sl@0
   288
	/** Gets the size of the certificate.
sl@0
   289
	* 
sl@0
   290
	* Note that this function must be called so that the correct size of descriptor 
sl@0
   291
	* can be allocated when retrieving the certificate (with MCertStore::Retrieve()).
sl@0
   292
	* 
sl@0
   293
	* @return The size of the certificate. */
sl@0
   294
	IMPORT_C TInt Size() const;
sl@0
   295
sl@0
   296
	/** Gets a handle for the object.
sl@0
   297
	* 
sl@0
   298
	* The primary purpose of the handle is to allow token objects to be 'passed' 
sl@0
   299
	* between processes.
sl@0
   300
	* 
sl@0
   301
	* @return	A handle for the object. 
sl@0
   302
	* @see TCTTokenObjectHandle */
sl@0
   303
	IMPORT_C TCTTokenObjectHandle Handle() const;
sl@0
   304
sl@0
   305
	/** Whether the certificate is deletable.
sl@0
   306
	* 
sl@0
   307
	* @return	ETrue if it is possible to delete the certificate; EFalse, otherwise. */
sl@0
   308
	IMPORT_C TBool IsDeletable() const;
sl@0
   309
sl@0
   310
	/** Gets the hash of the issuer's DN.
sl@0
   311
	* 
sl@0
   312
	* @return	The hash of the issuer's DN, or NULL if not known. */
sl@0
   313
	IMPORT_C const TDesC8* IssuerHash() const;
sl@0
   314
sl@0
   315
 public:	
sl@0
   316
  // from MCTTokenObject
sl@0
   317
	/** Gets the object's human-readable label.
sl@0
   318
	* 
sl@0
   319
	* @return	The object's human-readable label.
sl@0
   320
	* @see MCTTokenObject::Label()*/
sl@0
   321
	virtual const TDesC& Label() const;
sl@0
   322
sl@0
   323
	/** Gets a reference to the associated token.
sl@0
   324
	* 
sl@0
   325
	* @return	A reference to the associated token.
sl@0
   326
	* @see MCTTokenObject::Token()*/
sl@0
   327
	virtual MCTToken& Token() const;
sl@0
   328
sl@0
   329
	/** Gets a UID representing the type of the token object.
sl@0
   330
	* 
sl@0
   331
	* The function overrides MCTTokenObject::Type().
sl@0
   332
	* 
sl@0
   333
	* The meanings of possible UIDs should be documented in the documentation for 
sl@0
   334
	* the interface that returns them.
sl@0
   335
	* 
sl@0
   336
	* @return	A UID representing the type of the token object; this implementation 
sl@0
   337
	* 			returns KCTObjectCertInfo.
sl@0
   338
	* @see MCTTokenObject::Type() */
sl@0
   339
	virtual TUid Type() const;
sl@0
   340
	
sl@0
   341
	// Compares 2 cert infos
sl@0
   342
	/** Compares this certificate information object with a specified Certificate 
sl@0
   343
	* Information object for equality.
sl@0
   344
	* 
sl@0
   345
	* @param aCertInfo	The certificate information object to be compared.
sl@0
   346
	* @return			ETrue, if they are the same; EFalse, otherwise. */
sl@0
   347
	IMPORT_C TBool operator ==(const CCTCertInfo& aCertInfo) const;
sl@0
   348
sl@0
   349
	/** Sets the certificate Id.
sl@0
   350
	* 
sl@0
   351
	* @param aCertId The certificate Id.*/
sl@0
   352
	IMPORT_C void SetCertificateId(TInt aCertId);
sl@0
   353
sl@0
   354
 protected:
sl@0
   355
	IMPORT_C virtual ~CCTCertInfo();
sl@0
   356
	
sl@0
   357
 private:
sl@0
   358
	CCTCertInfo(MCTToken& aToken);
sl@0
   359
	CCTCertInfo(const TDesC& aLabel, TCertificateFormat aFormat,
sl@0
   360
				TCertificateOwnerType aCertificateOwnerType, 
sl@0
   361
				TInt aSize,
sl@0
   362
				const TKeyIdentifier* aSubjectKeyId,
sl@0
   363
				const TKeyIdentifier* aIssuerKeyId,
sl@0
   364
				MCTToken& aToken, TInt aCertificateId,
sl@0
   365
				TBool aDeletable);
sl@0
   366
	CCTCertInfo(const CCTCertInfo& aCertInfo);
sl@0
   367
	void ConstructL(RReadStream& aStream);
sl@0
   368
	void ConstructL(const TDesC8* aIssuerHash);
sl@0
   369
	
sl@0
   370
 private:
sl@0
   371
	const CCTCertInfo& operator=(const CCTCertInfo& aOther);
sl@0
   372
	
sl@0
   373
 private:	
sl@0
   374
	MCTToken& iToken;
sl@0
   375
	};
sl@0
   376
sl@0
   377
#endif