Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: nss/lib/dev/ckhelper.h

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 /* 5 /*
6 * ckhelper.h 6 * ckhelper.h
7 * 7 *
8 * This file contains some helper utilities for interaction with cryptoki. 8 * This file contains some helper utilities for interaction with cryptoki.
9 */ 9 */
10 10
11 #ifndef CKHELPER_H 11 #ifndef CKHELPER_H
12 #define CKHELPER_H 12 #define CKHELPER_H
13 13
14 PR_BEGIN_EXTERN_C 14 PR_BEGIN_EXTERN_C
15 15
16 /* Some globals to keep from constantly redeclaring common cryptoki 16 /* Some globals to keep from constantly redeclaring common cryptoki
17 * attribute types on the stack. 17 * attribute types on the stack.
18 */ 18 */
19 19
20 /* Boolean values */ 20 /* Boolean values */
21 NSS_EXTERN_DATA const NSSItem g_ck_true; 21 NSS_EXTERN_DATA const NSSItem g_ck_true;
22 NSS_EXTERN_DATA const NSSItem g_ck_false; 22 NSS_EXTERN_DATA const NSSItem g_ck_false;
23 23
24 /* Object classes */ 24 /* Object classes */
25 NSS_EXTERN_DATA const NSSItem g_ck_class_cert; 25 NSS_EXTERN_DATA const NSSItem g_ck_class_cert;
26 NSS_EXTERN_DATA const NSSItem g_ck_class_pubkey; 26 NSS_EXTERN_DATA const NSSItem g_ck_class_pubkey;
27 NSS_EXTERN_DATA const NSSItem g_ck_class_privkey; 27 NSS_EXTERN_DATA const NSSItem g_ck_class_privkey;
28 28
29 #define NSS_CK_TEMPLATE_START(_template, attr, size) \ 29 #define NSS_CK_TEMPLATE_START(_template, attr, size) \
30 attr = _template; \ 30 attr = _template; \
31 size = 0; 31 size = 0;
32 32
33 #define NSS_CK_SET_ATTRIBUTE_ITEM(pattr, kind, item) \ 33 #define NSS_CK_SET_ATTRIBUTE_ITEM(pattr, kind, item) \
34 (pattr)->type = kind; \ 34 (pattr)->type = kind; \
35 (pattr)->pValue = (CK_VOID_PTR)(item)->data; \ 35 (pattr)->pValue = (CK_VOID_PTR)(item)->data; \
36 (pattr)->ulValueLen = (CK_ULONG)(item)->size; \ 36 (pattr)->ulValueLen = (CK_ULONG)(item)->size; \
37 (pattr)++; 37 (pattr)++;
38 38
39 #define NSS_CK_SET_ATTRIBUTE_UTF8(pattr, kind, utf8) \ 39 #define NSS_CK_SET_ATTRIBUTE_UTF8(pattr, kind, utf8) \
40 (pattr)->type = kind; \ 40 (pattr)->type = kind; \
41 (pattr)->pValue = (CK_VOID_PTR)utf8; \ 41 (pattr)->pValue = (CK_VOID_PTR)utf8; \
42 (pattr)->ulValueLen = (CK_ULONG)nssUTF8_Size(utf8, NULL); \ 42 (pattr)->ulValueLen = (CK_ULONG)nssUTF8_Size(utf8, NULL); \
43 if ((pattr)->ulValueLen) ((pattr)->ulValueLen)--; \ 43 if ((pattr)->ulValueLen) \
44 ((pattr)->ulValueLen)--; \
44 (pattr)++; 45 (pattr)++;
45 46
46 #define NSS_CK_SET_ATTRIBUTE_VAR(pattr, kind, var) \ 47 #define NSS_CK_SET_ATTRIBUTE_VAR(pattr, kind, var) \
47 (pattr)->type = kind; \ 48 (pattr)->type = kind; \
48 (pattr)->pValue = (CK_VOID_PTR)&var; \ 49 (pattr)->pValue = (CK_VOID_PTR)&var; \
49 (pattr)->ulValueLen = (CK_ULONG)sizeof(var); \ 50 (pattr)->ulValueLen = (CK_ULONG)sizeof(var); \
50 (pattr)++; 51 (pattr)++;
51 52
52 #define NSS_CK_SET_ATTRIBUTE_NULL(pattr, kind) \ 53 #define NSS_CK_SET_ATTRIBUTE_NULL(pattr, kind) \
53 (pattr)->type = kind; \ 54 (pattr)->type = kind; \
54 (pattr)->pValue = (CK_VOID_PTR)NULL; \ 55 (pattr)->pValue = (CK_VOID_PTR)NULL; \
55 (pattr)->ulValueLen = 0; \ 56 (pattr)->ulValueLen = 0; \
56 (pattr)++; 57 (pattr)++;
57 58
58 #define NSS_CK_TEMPLATE_FINISH(_template, attr, size) \ 59 #define NSS_CK_TEMPLATE_FINISH(_template, attr, size) \
59 size = (attr) - (_template); \ 60 size = (attr) - (_template); \
60 PR_ASSERT(size <= sizeof(_template)/sizeof(_template[0])); 61 PR_ASSERT(size <= sizeof(_template) / sizeof(_template[0]));
61 62
62 /* NSS_CK_ATTRIBUTE_TO_ITEM(attrib, item) 63 /* NSS_CK_ATTRIBUTE_TO_ITEM(attrib, item)
63 * 64 *
64 * Convert a CK_ATTRIBUTE to an NSSItem. 65 * Convert a CK_ATTRIBUTE to an NSSItem.
65 */ 66 */
66 #define NSS_CK_ATTRIBUTE_TO_ITEM(attrib, item) \ 67 #define NSS_CK_ATTRIBUTE_TO_ITEM(attrib, item) \
67 if ((CK_LONG)(attrib)->ulValueLen > 0) { \ 68 if ((CK_LONG)(attrib)->ulValueLen > 0) { \
68 » (item)->data = (void *)(attrib)->pValue; \ 69 (item)->data = (void *)(attrib)->pValue; \
69 » (item)->size = (PRUint32)(attrib)->ulValueLen; \ 70 (item)->size = (PRUint32)(attrib)->ulValueLen; \
70 } else { \ 71 } else { \
71 » (item)->data = 0; \ 72 (item)->data = 0; \
72 » (item)->size = 0; \ 73 (item)->size = 0; \
73 } 74 }
74 75
75 #define NSS_CK_ATTRIBUTE_TO_BOOL(attrib, boolvar) \ 76 #define NSS_CK_ATTRIBUTE_TO_BOOL(attrib, boolvar) \
76 if ((attrib)->ulValueLen > 0) { \ 77 if ((attrib)->ulValueLen > 0) { \
77 » if (*((CK_BBOOL*)(attrib)->pValue) == CK_TRUE) { \ 78 if (*((CK_BBOOL *)(attrib)->pValue) == CK_TRUE) { \
78 » boolvar = PR_TRUE; \ 79 boolvar = PR_TRUE; \
79 » } else { \ 80 } else { \
80 » boolvar = PR_FALSE; \ 81 boolvar = PR_FALSE; \
81 » } \ 82 } \
82 } 83 }
83 84
84 #define NSS_CK_ATTRIBUTE_TO_ULONG(attrib, ulongvar) \ 85 #define NSS_CK_ATTRIBUTE_TO_ULONG(attrib, ulongvar) \
85 if ((attrib)->ulValueLen > 0) { \ 86 if ((attrib)->ulValueLen > 0) { \
86 » ulongvar = *((CK_ULONG*)(attrib)->pValue); \ 87 ulongvar = *((CK_ULONG *)(attrib)->pValue); \
87 } 88 }
88 89
89 /* NSS_CK_ATTRIBUTE_TO_UTF8(attrib, str) 90 /* NSS_CK_ATTRIBUTE_TO_UTF8(attrib, str)
90 * 91 *
91 * Convert a CK_ATTRIBUTE to a string. 92 * Convert a CK_ATTRIBUTE to a string.
92 */ 93 */
93 #define NSS_CK_ATTRIBUTE_TO_UTF8(attrib, str) \ 94 #define NSS_CK_ATTRIBUTE_TO_UTF8(attrib, str) \
94 str = (NSSUTF8 *)((attrib)->pValue); 95 str = (NSSUTF8 *)((attrib)->pValue);
95 96
96 /* NSS_CK_ITEM_TO_ATTRIBUTE(item, attrib) 97 /* NSS_CK_ITEM_TO_ATTRIBUTE(item, attrib)
97 * 98 *
98 * Convert an NSSItem to a CK_ATTRIBUTE. 99 * Convert an NSSItem to a CK_ATTRIBUTE.
99 */ 100 */
100 #define NSS_CK_ITEM_TO_ATTRIBUTE(item, attrib) \ 101 #define NSS_CK_ITEM_TO_ATTRIBUTE(item, attrib) \
101 (attrib)->pValue = (CK_VOID_PTR)(item)->data; \ 102 (attrib)->pValue = (CK_VOID_PTR)(item)->data; \
102 (attrib)->ulValueLen = (CK_ULONG)(item)->size; \ 103 (attrib)->ulValueLen = (CK_ULONG)(item)->size;
103 104
104 /* Get an array of attributes from an object. */ 105 /* Get an array of attributes from an object. */
105 NSS_EXTERN PRStatus 106 NSS_EXTERN PRStatus
106 nssCKObject_GetAttributes 107 nssCKObject_GetAttributes(
107 ( 108 CK_OBJECT_HANDLE object,
108 CK_OBJECT_HANDLE object, 109 CK_ATTRIBUTE_PTR obj_template,
109 CK_ATTRIBUTE_PTR obj_template, 110 CK_ULONG count,
110 CK_ULONG count, 111 NSSArena *arenaOpt,
111 NSSArena *arenaOpt, 112 nssSession *session,
112 nssSession *session, 113 NSSSlot *slot);
113 NSSSlot *slot
114 );
115 114
116 /* Get a single attribute as an item. */ 115 /* Get a single attribute as an item. */
117 NSS_EXTERN PRStatus 116 NSS_EXTERN PRStatus
118 nssCKObject_GetAttributeItem 117 nssCKObject_GetAttributeItem(
119 ( 118 CK_OBJECT_HANDLE object,
120 CK_OBJECT_HANDLE object, 119 CK_ATTRIBUTE_TYPE attribute,
121 CK_ATTRIBUTE_TYPE attribute, 120 NSSArena *arenaOpt,
122 NSSArena *arenaOpt, 121 nssSession *session,
123 nssSession *session, 122 NSSSlot *slot,
124 NSSSlot *slot, 123 NSSItem *rvItem);
125 NSSItem *rvItem
126 );
127 124
128 NSS_EXTERN PRBool 125 NSS_EXTERN PRBool
129 nssCKObject_IsAttributeTrue 126 nssCKObject_IsAttributeTrue(
130 ( 127 CK_OBJECT_HANDLE object,
131 CK_OBJECT_HANDLE object, 128 CK_ATTRIBUTE_TYPE attribute,
132 CK_ATTRIBUTE_TYPE attribute, 129 nssSession *session,
133 nssSession *session, 130 NSSSlot *slot,
134 NSSSlot *slot, 131 PRStatus *rvStatus);
135 PRStatus *rvStatus
136 );
137 132
138 NSS_EXTERN PRStatus 133 NSS_EXTERN PRStatus
139 nssCKObject_SetAttributes 134 nssCKObject_SetAttributes(
140 ( 135 CK_OBJECT_HANDLE object,
141 CK_OBJECT_HANDLE object, 136 CK_ATTRIBUTE_PTR obj_template,
142 CK_ATTRIBUTE_PTR obj_template, 137 CK_ULONG count,
143 CK_ULONG count, 138 nssSession *session,
144 nssSession *session, 139 NSSSlot *slot);
145 NSSSlot *slot
146 );
147 140
148 NSS_EXTERN PRBool 141 NSS_EXTERN PRBool
149 nssCKObject_IsTokenObjectTemplate 142 nssCKObject_IsTokenObjectTemplate(
150 ( 143 CK_ATTRIBUTE_PTR objectTemplate,
151 CK_ATTRIBUTE_PTR objectTemplate, 144 CK_ULONG otsize);
152 CK_ULONG otsize
153 );
154 145
155 PR_END_EXTERN_C 146 PR_END_EXTERN_C
156 147
157 #endif /* CKHELPER_H */ 148 #endif /* CKHELPER_H */
OLDNEW
« no previous file with comments | « nss/lib/cryptohi/secvfy.c ('k') | nss/lib/dev/ckhelper.c » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698