OLD | NEW |
1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
3 * | 3 * |
4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
8 * | 8 * |
9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 /* | 211 /* |
212 * destroy a symetric key | 212 * destroy a symetric key |
213 */ | 213 */ |
214 void | 214 void |
215 PK11_FreeSymKey(PK11SymKey *symKey) | 215 PK11_FreeSymKey(PK11SymKey *symKey) |
216 { | 216 { |
217 PK11SlotInfo *slot; | 217 PK11SlotInfo *slot; |
218 PRBool freeit = PR_TRUE; | 218 PRBool freeit = PR_TRUE; |
219 | 219 |
220 if (PR_AtomicDecrement(&symKey->refCount) == 0) { | 220 if (PR_ATOMIC_DECREMENT(&symKey->refCount) == 0) { |
221 PK11SymKey *parent = symKey->parent; | 221 PK11SymKey *parent = symKey->parent; |
222 | 222 |
223 symKey->parent = NULL; | 223 symKey->parent = NULL; |
224 if ((symKey->owner) && symKey->objectID != CK_INVALID_HANDLE) { | 224 if ((symKey->owner) && symKey->objectID != CK_INVALID_HANDLE) { |
225 pk11_EnterKeyMonitor(symKey); | 225 pk11_EnterKeyMonitor(symKey); |
226 (void) PK11_GETTAB(symKey->slot)-> | 226 (void) PK11_GETTAB(symKey->slot)-> |
227 C_DestroyObject(symKey->session, symKey->objectID); | 227 C_DestroyObject(symKey->session, symKey->objectID); |
228 pk11_ExitKeyMonitor(symKey); | 228 pk11_ExitKeyMonitor(symKey); |
229 } | 229 } |
230 if (symKey->data.data) { | 230 if (symKey->data.data) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 if (parent) { | 273 if (parent) { |
274 PK11_FreeSymKey(parent); | 274 PK11_FreeSymKey(parent); |
275 } | 275 } |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 PK11SymKey * | 279 PK11SymKey * |
280 PK11_ReferenceSymKey(PK11SymKey *symKey) | 280 PK11_ReferenceSymKey(PK11SymKey *symKey) |
281 { | 281 { |
282 PR_AtomicIncrement(&symKey->refCount); | 282 PR_ATOMIC_INCREMENT(&symKey->refCount); |
283 return symKey; | 283 return symKey; |
284 } | 284 } |
285 | 285 |
286 /* | 286 /* |
287 * Accessors | 287 * Accessors |
288 */ | 288 */ |
289 CK_MECHANISM_TYPE | 289 CK_MECHANISM_TYPE |
290 PK11_GetMechanism(PK11SymKey *symKey) | 290 PK11_GetMechanism(PK11SymKey *symKey) |
291 { | 291 { |
292 return symKey->type; | 292 return symKey->type; |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 { | 1147 { |
1148 PK11SlotInfo *slot; | 1148 PK11SlotInfo *slot; |
1149 CK_ULONG len = wrappedKey->len; | 1149 CK_ULONG len = wrappedKey->len; |
1150 PK11SymKey *newKey = NULL; | 1150 PK11SymKey *newKey = NULL; |
1151 CK_OBJECT_HANDLE id; | 1151 CK_OBJECT_HANDLE id; |
1152 CK_MECHANISM mechanism; | 1152 CK_MECHANISM mechanism; |
1153 PRBool owner = PR_TRUE; | 1153 PRBool owner = PR_TRUE; |
1154 CK_SESSION_HANDLE session; | 1154 CK_SESSION_HANDLE session; |
1155 CK_RV crv; | 1155 CK_RV crv; |
1156 | 1156 |
| 1157 if (symKey == NULL) { |
| 1158 PORT_SetError( SEC_ERROR_INVALID_ARGS ); |
| 1159 return SECFailure; |
| 1160 } |
| 1161 |
1157 /* if this slot doesn't support the mechanism, go to a slot that does */ | 1162 /* if this slot doesn't support the mechanism, go to a slot that does */ |
1158 newKey = pk11_ForceSlot(symKey,type,CKA_ENCRYPT); | 1163 newKey = pk11_ForceSlot(symKey,type,CKA_ENCRYPT); |
1159 if (newKey != NULL) { | 1164 if (newKey != NULL) { |
1160 symKey = newKey; | 1165 symKey = newKey; |
1161 } | 1166 } |
1162 | 1167 |
1163 if ((symKey == NULL) || (symKey->slot == NULL)) { | 1168 if (symKey->slot == NULL) { |
1164 PORT_SetError( SEC_ERROR_NO_MODULE ); | 1169 PORT_SetError( SEC_ERROR_NO_MODULE ); |
1165 return SECFailure; | 1170 return SECFailure; |
1166 } | 1171 } |
1167 | 1172 |
1168 slot = symKey->slot; | 1173 slot = symKey->slot; |
1169 mechanism.mechanism = pk11_mapWrapKeyType(pubKey->keyType); | 1174 mechanism.mechanism = pk11_mapWrapKeyType(pubKey->keyType); |
1170 mechanism.pParameter = NULL; | 1175 mechanism.pParameter = NULL; |
1171 mechanism.ulParameterLen = 0; | 1176 mechanism.ulParameterLen = 0; |
1172 | 1177 |
1173 id = PK11_ImportPublicKey(slot,pubKey,PR_FALSE); | 1178 id = PK11_ImportPublicKey(slot,pubKey,PR_FALSE); |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 PK11_ExitSlotMonitor(symKey->slot); | 2307 PK11_ExitSlotMonitor(symKey->slot); |
2303 return rv; | 2308 return rv; |
2304 } | 2309 } |
2305 | 2310 |
2306 CK_OBJECT_HANDLE | 2311 CK_OBJECT_HANDLE |
2307 PK11_GetSymKeyHandle(PK11SymKey *symKey) | 2312 PK11_GetSymKeyHandle(PK11SymKey *symKey) |
2308 { | 2313 { |
2309 return symKey->objectID; | 2314 return symKey->objectID; |
2310 } | 2315 } |
2311 | 2316 |
OLD | NEW |