Update contrib.
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.
19 #include "securitydefs.h"
21 ////////////////////////////////////////////////////////////////////////////////
22 // TKeyUsagePKCS15 & TKeyUsageX509
23 ////////////////////////////////////////////////////////////////////////////////
25 // x509 PKCS15 Public PKCS15 Private
27 // DataEncipherment Encrypt Decrypt
28 // DigitalSignature, keyCertSign, cRLSign Verify Sign
29 // DigitalSignature, keyCertSign, cRLSign VerifyRecover SignRecover
30 // KeyAgreement Derive Derive
31 // KeyEncipherment Wrap Unwrap
32 // NonRepudiation NonRepudiation NonRepudiation
34 EXPORT_C TKeyUsagePKCS15 KeyUsageX509ToPKCS15Private(TKeyUsageX509 aUsage)
36 TKeyUsagePKCS15 result = EPKCS15UsageNone;
38 if (EX509UsageAll == aUsage)
40 result = EPKCS15UsageAll;
44 if (aUsage & EX509UsageDataEncipherment)
46 result |= EPKCS15UsageDecrypt;
48 if (aUsage & (EX509UsageDigitalSignature | EX509UsageKeyCertSign | EX509UsageCRLSign))
50 result |= EPKCS15UsageSign | EPKCS15UsageSignRecover;
52 if (aUsage & EX509UsageKeyAgreement)
54 result |= EPKCS15UsageDerive;
56 if (aUsage & EX509UsageKeyEncipherment)
58 result |= EPKCS15UsageUnwrap;
60 if (aUsage & EX509UsageNonRepudiation)
61 {// This shouldn't really happen, ENonRepudiation should be sole usage
62 result |= EPKCS15UsageNonRepudiation;
69 EXPORT_C TKeyUsagePKCS15 KeyUsageX509ToPKCS15Public(TKeyUsageX509 aUsage)
71 TKeyUsagePKCS15 result = EPKCS15UsageNone;
73 if (EX509UsageAll == aUsage)
75 result = EPKCS15UsageAll;
79 if (aUsage & EX509UsageDataEncipherment)
81 result |= EPKCS15UsageEncrypt;
83 if (aUsage & (EX509UsageDigitalSignature | EX509UsageKeyCertSign | EX509UsageCRLSign))
85 result |= EPKCS15UsageVerify | EPKCS15UsageVerifyRecover;
87 if (aUsage & EX509UsageKeyAgreement)
89 result |= EPKCS15UsageDerive;
91 if (aUsage & EX509UsageKeyEncipherment)
93 result |= EPKCS15UsageWrap;
95 if (aUsage & EX509UsageNonRepudiation)
96 {// This shouldn't really happen, ENonRepudiation should be sole usage
97 result |= EPKCS15UsageNonRepudiation;
104 EXPORT_C TKeyUsageX509 KeyUsagePKCS15ToX509(TKeyUsagePKCS15 aUsage)
106 TKeyUsageX509 result = EX509UsageNone;
108 if (EPKCS15UsageAll == aUsage)
110 result = EX509UsageAll;
114 if (aUsage & (EPKCS15UsageEncrypt | EPKCS15UsageDecrypt))
116 result |= EX509UsageDataEncipherment;
118 if (aUsage & (EPKCS15UsageVerify | EPKCS15UsageSign | EPKCS15UsageVerifyRecover | EPKCS15UsageSignRecover))
120 result |= EX509UsageDigitalSignature | EX509UsageKeyCertSign | EX509UsageCRLSign;
122 if (aUsage & EPKCS15UsageDerive)
124 result |= EX509UsageKeyAgreement;
126 if (aUsage & (EPKCS15UsageWrap | EPKCS15UsageUnwrap))
128 result |= EX509UsageKeyEncipherment;
130 if (aUsage & EPKCS15UsageNonRepudiation)
132 result |= EX509UsageNonRepudiation;