1 /* |
|
2 * Copyright (c) 1999 - 2001 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 /* Created by araman on 05/31/00 for Crypto Library. */ |
|
19 |
|
20 |
|
21 #ifndef SCR_CRYPTO_H |
|
22 #define SCR_CRYPTO_H |
|
23 |
|
24 #include "scr_core.h" |
|
25 |
|
26 typedef enum { |
|
27 SignatureAlgorithmRsaSha1 = 0x01 |
|
28 }SignatureAlgorithm_t; |
|
29 |
|
30 typedef enum { |
|
31 SignatureIdKeyHash = 1 |
|
32 }SIgnatureIdType_t; |
|
33 /* This is defined by the spec */ |
|
34 typedef enum { |
|
35 SignatureCertificateTypeWtls = 2, |
|
36 SignatureCertificateTypeX509 = 3, |
|
37 SignatureCertificateTypeX968 = 4, |
|
38 SignatureCertificateTypeURL = 5 |
|
39 }SignatureCertificateType_t; |
|
40 |
|
41 typedef enum { |
|
42 SignatureContentTypeText = 1, |
|
43 SignatureContentTypeData = 2 |
|
44 }SignatureContentType_t; |
|
45 |
|
46 typedef enum { |
|
47 SignatureAuthenticatedAttributeGmtUtcTime = 1, |
|
48 SignatureAuthenticatedAttributeSignerNonce = 2 |
|
49 } SignatureAuthenticatedAttribute_t; |
|
50 |
|
51 typedef enum { |
|
52 SignatureIncludeContent = 1, |
|
53 SignatureIncludeKeyHash = 2, |
|
54 SignatureIncludeCertificate = 4 |
|
55 } SignatureInclude_t; |
|
56 |
|
57 typedef enum { |
|
58 SignatureKeyIdentifierNone = 0, |
|
59 SignatureKeyIdentifierUserKeyHash = 1, |
|
60 SignatureKeyIdentifierTrustedKeyHash = 2 |
|
61 } SignatureKeyIdentifier_t; |
|
62 |
|
63 typedef enum { |
|
64 SignStateInit=0, |
|
65 SignStateGetSelectedCert, |
|
66 SignStateGetPIN, |
|
67 SignStateGetSignature, |
|
68 SignStateBuildSignature, |
|
69 SignStateAddCertificateContent, |
|
70 SignStateFinish, |
|
71 SignStateError |
|
72 } SignState_t; |
|
73 |
|
74 typedef struct { |
|
75 NW_Byte algorithm; |
|
76 NW_Uint16 signLen; |
|
77 NW_Byte *sign; |
|
78 } Signature; |
|
79 |
|
80 typedef struct { |
|
81 NW_Uint8 signerInfoType; |
|
82 NW_Uint16 signerInfoLen; |
|
83 NW_Byte* signerInfo; |
|
84 } SignerInfo; |
|
85 |
|
86 typedef struct { |
|
87 NW_Uint8 contentType; |
|
88 NW_Uint16 contentEncoding; |
|
89 NW_Bool contentPresent; |
|
90 NW_Uint16 contentLen; |
|
91 NW_Byte* content; |
|
92 } ContentInfo; |
|
93 |
|
94 typedef struct { |
|
95 NW_Uint8 attributeType; |
|
96 NW_Uint8 gmtUtcTime[12]; |
|
97 } AuthenticatedAttribute; |
|
98 |
|
99 typedef struct { |
|
100 NW_Uint8 version; |
|
101 NW_Uint8 signerInfoCount; |
|
102 Signature *signature; |
|
103 SignerInfo **signerInfos; |
|
104 ContentInfo *contentInfo; |
|
105 AuthenticatedAttribute *authenticatedAttribute; |
|
106 } SignedContent; |
|
107 |
|
108 |
|
109 typedef struct { |
|
110 SignState_t state; |
|
111 NW_Ucs2 *stringToSign; |
|
112 NW_Int32 option; |
|
113 NW_Int32 keyIdType; |
|
114 NW_Byte *keyIdByte; |
|
115 NW_Int32 keyIdLen; |
|
116 NW_Uint8 certNum; |
|
117 void **certificatesList; |
|
118 void *selectedCertRef; |
|
119 void *selectedKeyRef; |
|
120 SignedContent *signedContent; |
|
121 }SignTextParams_t; |
|
122 |
|
123 void populate_crypto_lib(lib_function_table_t *table); |
|
124 NW_Byte size_crypto_lib(void); |
|
125 |
|
126 /* Init the SignTextParams_t struct */ |
|
127 SignTextParams_t* |
|
128 NW_ScrCrypto_SignTextParamsNew(SignState_t state, NW_Ucs2 *stringToSign, NW_Int32 option, |
|
129 NW_Int32 keyIdType, NW_Byte *keyIdByte, NW_Int32 keyIdLen, NW_Uint8 certNum, |
|
130 void **certificatesList, void *selectedCertRef, void *selectedKeyRef); |
|
131 /* Free the SignTextParams_t struct */ |
|
132 void NW_ScrCrypto_SignTextParamsFree(SignTextParams_t *params); |
|
133 |
|
134 #endif /*SCR_CRYPTO_H*/ |
|