OLD | NEW |
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 * This file manages object type indepentent functions. | 5 * This file manages object type indepentent functions. |
6 */ | 6 */ |
7 #include "seccomon.h" | 7 #include "seccomon.h" |
8 #include "secmod.h" | 8 #include "secmod.h" |
9 #include "secmodi.h" | 9 #include "secmodi.h" |
10 #include "secmodti.h" | 10 #include "secmodti.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return rv; | 77 return rv; |
78 } | 78 } |
79 | 79 |
80 /* | 80 /* |
81 * Read in a single attribute into a SECItem. Allocate space for it with | 81 * Read in a single attribute into a SECItem. Allocate space for it with |
82 * PORT_Alloc unless an arena is supplied. In the latter case use the arena | 82 * PORT_Alloc unless an arena is supplied. In the latter case use the arena |
83 * to allocate the space. | 83 * to allocate the space. |
84 */ | 84 */ |
85 SECStatus | 85 SECStatus |
86 PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id, | 86 PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id, |
87 » CK_ATTRIBUTE_TYPE type, PRArenaPool *arena, SECItem *result) { | 87 » CK_ATTRIBUTE_TYPE type, PLArenaPool *arena, SECItem *result) { |
88 CK_ATTRIBUTE attr = { 0, NULL, 0 }; | 88 CK_ATTRIBUTE attr = { 0, NULL, 0 }; |
89 CK_RV crv; | 89 CK_RV crv; |
90 | 90 |
91 attr.type = type; | 91 attr.type = type; |
92 | 92 |
93 PK11_EnterSlotMonitor(slot); | 93 PK11_EnterSlotMonitor(slot); |
94 crv = PK11_GETTAB(slot)->C_GetAttributeValue(slot->session,id,&attr,1); | 94 crv = PK11_GETTAB(slot)->C_GetAttributeValue(slot->session,id,&attr,1); |
95 if (crv != CKR_OK) { | 95 if (crv != CKR_OK) { |
96 PK11_ExitSlotMonitor(slot); | 96 PK11_ExitSlotMonitor(slot); |
97 PORT_SetError(PK11_MapError(crv)); | 97 PORT_SetError(PK11_MapError(crv)); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 return ckvalue; | 168 return ckvalue; |
169 } | 169 } |
170 | 170 |
171 /* | 171 /* |
172 * returns a full list of attributes. Allocate space for them. If an arena is | 172 * returns a full list of attributes. Allocate space for them. If an arena is |
173 * provided, allocate space out of the arena. | 173 * provided, allocate space out of the arena. |
174 */ | 174 */ |
175 CK_RV | 175 CK_RV |
176 PK11_GetAttributes(PRArenaPool *arena,PK11SlotInfo *slot, | 176 PK11_GetAttributes(PLArenaPool *arena,PK11SlotInfo *slot, |
177 CK_OBJECT_HANDLE obj,CK_ATTRIBUTE *attr, int count) | 177 CK_OBJECT_HANDLE obj,CK_ATTRIBUTE *attr, int count) |
178 { | 178 { |
179 int i; | 179 int i; |
180 /* make pedantic happy... note that it's only used arena != NULL */ | 180 /* make pedantic happy... note that it's only used arena != NULL */ |
181 void *mark = NULL; | 181 void *mark = NULL; |
182 CK_RV crv; | 182 CK_RV crv; |
183 PORT_Assert(slot->session != CK_INVALID_SESSION); | 183 PORT_Assert(slot->session != CK_INVALID_SESSION); |
184 if (slot->session == CK_INVALID_SESSION) | 184 if (slot->session == CK_INVALID_SESSION) |
185 return CKR_SESSION_HANDLE_INVALID; | 185 return CKR_SESSION_HANDLE_INVALID; |
186 | 186 |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 CK_ATTRIBUTE theTemplate[] = { | 1729 CK_ATTRIBUTE theTemplate[] = { |
1730 { CKA_ID, NULL, 0 }, | 1730 { CKA_ID, NULL, 0 }, |
1731 { CKA_CLASS, NULL, 0 } | 1731 { CKA_CLASS, NULL, 0 } |
1732 }; | 1732 }; |
1733 /* if you change the array, change the variable below as well */ | 1733 /* if you change the array, change the variable below as well */ |
1734 CK_ATTRIBUTE *keyclass = &theTemplate[1]; | 1734 CK_ATTRIBUTE *keyclass = &theTemplate[1]; |
1735 int tsize = sizeof(theTemplate)/sizeof(theTemplate[0]); | 1735 int tsize = sizeof(theTemplate)/sizeof(theTemplate[0]); |
1736 /* if you change the array, change the variable below as well */ | 1736 /* if you change the array, change the variable below as well */ |
1737 CK_OBJECT_HANDLE peerID; | 1737 CK_OBJECT_HANDLE peerID; |
1738 CK_OBJECT_HANDLE parent; | 1738 CK_OBJECT_HANDLE parent; |
1739 PRArenaPool *arena; | 1739 PLArenaPool *arena; |
1740 CK_RV crv; | 1740 CK_RV crv; |
1741 | 1741 |
1742 /* now we need to create space for the public key */ | 1742 /* now we need to create space for the public key */ |
1743 arena = PORT_NewArena( DER_DEFAULT_CHUNKSIZE); | 1743 arena = PORT_NewArena( DER_DEFAULT_CHUNKSIZE); |
1744 if (arena == NULL) return CK_INVALID_HANDLE; | 1744 if (arena == NULL) return CK_INVALID_HANDLE; |
1745 | 1745 |
1746 crv = PK11_GetAttributes(arena,slot,searchID,theTemplate,tsize); | 1746 crv = PK11_GetAttributes(arena,slot,searchID,theTemplate,tsize); |
1747 if (crv != CKR_OK) { | 1747 if (crv != CKR_OK) { |
1748 PORT_FreeArena(arena,PR_FALSE); | 1748 PORT_FreeArena(arena,PR_FALSE); |
1749 PORT_SetError( PK11_MapError(crv) ); | 1749 PORT_SetError( PK11_MapError(crv) ); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 PORT_SetError( PK11_MapError(crv) ); | 1969 PORT_SetError( PK11_MapError(crv) ); |
1970 return NULL; | 1970 return NULL; |
1971 } | 1971 } |
1972 | 1972 |
1973 item->data = (unsigned char*) theTemplate[0].pValue; | 1973 item->data = (unsigned char*) theTemplate[0].pValue; |
1974 item->len =theTemplate[0].ulValueLen; | 1974 item->len =theTemplate[0].ulValueLen; |
1975 | 1975 |
1976 return item; | 1976 return item; |
1977 } | 1977 } |
1978 | 1978 |
OLD | NEW |