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.
15 * General Security Definitions
26 #ifndef __SECURITYDEFS_H__
27 #define __SECURITYDEFS_H__
32 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
33 #include <securitydefsconst.h>
36 /** General Security Definitions */
38 // Old keystore interface, deprecated //////////////////////////////////////////
41 * What a key can be used for.
42 * The values this can take are defined in TKeyUsageVals.
46 typedef TInt TKeyUsage;
49 * What a key can be used for.
51 * These values can be ORed together if a key has several usages. EAllKeyUsages
52 * is used when searching for all keys, rather than ones with a particular
53 * usage. As these can be combined, TKeyUsage is used to store them.
59 EDigitalSignature = 0x80000000,
60 ENonRepudiation = 0x40000000,
61 EKeyEncipherment = 0x20000000,
62 EDataEncipherment = 0x10000000,
63 EKeyAgreement = 0x08000000,
64 EKeyCertSign = 0x04000000,
65 ECRLSign = 0x02000000,
66 EEncipherOnly = 0x01000000,
67 EDecipherOnly = 0x00800000,
71 // End of deprecated keystore API //////////////////////////////////////////////
74 * What a key can be used for - PKCS#15 scheme.
79 EPKCS15UsageEncrypt = 0x001,
80 EPKCS15UsageDecrypt = 0x002,
81 EPKCS15UsageSign = 0x004,
82 EPKCS15UsageSignRecover = 0x008,
83 EPKCS15UsageWrap = 0x010,
84 EPKCS15UsageUnwrap = 0x020,
85 EPKCS15UsageVerify = 0x040,
86 EPKCS15UsageVerifyRecover = 0x080,
87 EPKCS15UsageDerive = 0x100,
88 EPKCS15UsageNonRepudiation = 0x200,
89 // Common combinations
90 EPKCS15UsageEncryptWrap = 0x011,
91 EPKCS15UsageVerifyVerifyRecover = 0x0C0,
92 EPKCS15UsageDecryptUnwrap = 0x022,
93 EPKCS15UsageSignSignRecover = 0x00C,
94 EPKCS15UsageVerifyEncrypt = 0x0D1,
95 EPKCS15UsageSignDecrypt = 0x02E,
96 // For use in filters to return all keys
97 EPKCS15UsageAll = 0xffffffff,
98 EPKCS15UsageNone = 0x00000000
101 inline TKeyUsagePKCS15 operator|(TKeyUsagePKCS15 aLeft, TKeyUsagePKCS15 aRight);
102 inline TKeyUsagePKCS15 operator&(TKeyUsagePKCS15 aLeft, TKeyUsagePKCS15 aRight);
103 inline const TKeyUsagePKCS15& operator|=(TKeyUsagePKCS15& aLeft, TKeyUsagePKCS15 aRight);
104 inline const TKeyUsagePKCS15& operator&=(TKeyUsagePKCS15& aLeft, TKeyUsagePKCS15 aRight);
107 * What a key can be used for - X.509 scheme.
112 EX509UsageDigitalSignature = 0x80000000,
113 EX509UsageNonRepudiation = 0x40000000,
114 EX509UsageKeyEncipherment = 0x20000000,
115 EX509UsageDataEncipherment = 0x10000000,
116 EX509UsageKeyAgreement = 0x08000000,
117 EX509UsageKeyCertSign = 0x04000000,
118 EX509UsageCRLSign = 0x02000000,
119 EX509UsageEncipherOnly = 0x01000000,
120 EX509UsageDecipherOnly = 0x00800000,
121 // Values for commonly permitted combinations
122 EX509UsageAnySign = 0x86000000,
123 EX509UsageAllEncipher = 0x30000000,
124 EX509UsageAllSignEncipher = 0xB6000000,
125 /// For use in filters to return all keys
126 EX509UsageAll = 0xffffffff,
127 EX509UsageNone = 0x00000000
130 inline TKeyUsageX509 operator|(TKeyUsageX509 aLeft, TKeyUsageX509 aRight);
131 inline TKeyUsageX509 operator&(TKeyUsageX509 aLeft, TKeyUsageX509 aRight);
132 inline const TKeyUsageX509& operator|=(TKeyUsageX509& aLeft, TKeyUsageX509 aRight);
133 inline const TKeyUsageX509& operator&=(TKeyUsageX509& aLeft, TKeyUsageX509 aRight);
141 IMPORT_C TKeyUsageX509 KeyUsagePKCS15ToX509(TKeyUsagePKCS15 aUsage);
149 IMPORT_C TKeyUsagePKCS15 KeyUsageX509ToPKCS15Private(TKeyUsageX509 aUsage);
157 IMPORT_C TKeyUsagePKCS15 KeyUsageX509ToPKCS15Public(TKeyUsageX509 aUsage);
160 * Supported types of certificate format. Note these must be only 1 byte long as
161 * the file cert store only seralises them as 1 byte.
164 enum TCertificateFormat
166 EX509Certificate = 0x00,
167 EWTLSCertificate = 0x01,
168 EX968Certificate = 0x02,
169 EUnknownCertificate = 0x0f,
170 EX509CertificateUrl = 0x10,
171 EWTLSCertificateUrl = 0x11,
172 EX968CertificateUrl = 0x12
176 * The owner of a certificate.
179 enum TCertificateOwnerType
186 /** The length of a SHA-1 hash
189 const TInt KSHA1HashLengthBytes = 20;
195 typedef TBuf8<KSHA1HashLengthBytes> TSHA1Hash;
197 //const TInt KMD5HashLengthBytes = 16;
198 //typedef TMD5Hash TBufC8<KMD5HashLengthBytes>;
201 * A SHA-1 hash is also used as a key identifier.
204 typedef TSHA1Hash TKeyIdentifier;
207 * Errors that can occur when validating a certificate chain.
209 * Except EValidatedOK, all these are fatal errors unless specified.
212 enum TValidationError
216 /** Certificate chain has no root */
218 /** Invalid signature */
220 /** Date out of range */
222 /** Name is excluded */
224 /** Name is not permitted */
225 ENameNotPermitted, //subtle difference here!
226 /** Not a CA certificate */
228 /** Certificate revoked */
230 /** Unrecognized critical extension */
231 EUnrecognizedCriticalExtension,
232 /** No basic constraint in CA certificate */
233 ENoBasicConstraintInCACert,
234 /** No acceptable policy */
238 /** Negative path length specified */
239 ENegativePathLengthSpecified,
240 /** Names do not chain */
242 /** Required policy not found */
243 ERequiredPolicyNotFound,
247 * Root certificate not self-signed.
249 * We cannot tell if this is fatal or not, as we lack the context.
251 ERootCertNotSelfSigned,
253 * Critical extended key usage
255 * We cannot tell if this is fatal or not, as we lack the context.
257 ECriticalExtendedKeyUsage,
259 * Critical certificate policies with qualifiers
261 * We cannot tell if this is fatal or not, as we lack the context.
263 ECriticalCertPoliciesWithQualifiers,
265 * Critical policy mapping
267 * We cannot tell if this is fatal or not, as we lack the context.
269 ECriticalPolicyMapping,
273 * We cannot tell if this is fatal or not, as we lack the context.
279 * We cannot tell if this is fatal or not, as we lack the context.
285 * We cannot tell if this is fatal or not, as we lack the context.
289 * Critical Capabilities
291 * We cannot tell if this is fatal or not, as we lack the context.
293 ECriticalCapabilities
297 #include "securitydefs.inl"