Date: Thu, 13 Jun 2002 07:28:46 -0700 (PDT) From: Dag-Erling Smorgrav <des@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 12820 for review Message-ID: <200206131428.g5DESkE09164@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=12820 Change 12820 by des@des.at.des.thinksec.com on 2002/06/13 07:28:00 Implement C_GetSlotList.c and C_GetSlotInfo.c (the latter isn't completely done) Sponsored by: DARPA, NAI Labs Affected files ... ... //depot/projects/cryptoki/lib/C_GetSlotInfo.c#4 edit ... //depot/projects/cryptoki/lib/C_GetSlotList.c#4 edit Differences ... ==== //depot/projects/cryptoki/lib/C_GetSlotInfo.c#4 (text+ko) ==== @@ -31,17 +31,26 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/cryptoki/lib/C_GetSlotInfo.c#3 $ + * $P4: //depot/projects/cryptoki/lib/C_GetSlotInfo.c#4 $ */ +#include <string.h> + #include <cryptoki.h> +#include "cryptoki_impl.h" + CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) { - (void)slotID; - (void)pInfo; - return (CKR_FUNCTION_NOT_SUPPORTED); + if (pInfo == NULL_PTR || slotID > _ck_NumSlots) + return (CKR_ARGUMENTS_BAD); + memset(pInfo, 0, sizeof *pInfo); + memset(pInfo->slotDescription, ' ', sizeof pInfo->slotDescription); + strncpy(pInfo->slotDescription, _ck_Slots[slotID].cks_dev, + strlen(_ck_Slots[slotID].cks_dev)); + memset(pInfo->manufacturerID, ' ', sizeof pInfo->manufacturerID); + return (CKR_OK); } ==== //depot/projects/cryptoki/lib/C_GetSlotList.c#4 (text+ko) ==== @@ -31,19 +31,40 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/cryptoki/lib/C_GetSlotList.c#3 $ + * $P4: //depot/projects/cryptoki/lib/C_GetSlotList.c#4 $ */ #include <cryptoki.h> +#include "cryptoki_impl.h" + +CK_ULONG _ck_NumSlots; +_ck_slot_ptr _ck_Slots; + CK_RV C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount) { + CK_SLOT_INFO Slot; + CK_ULONG id, n; + CK_RV rv; - (void)tokenPresent; - (void)pSlotList; - (void)pulCount; - return (CKR_FUNCTION_NOT_SUPPORTED); + if (pulCount == NULL_PTR) + return (CKR_ARGUMENTS_BAD); + for (id = n = 0; id < _ck_NumSlots; ++id) { + if (tokenPresent) + C_GetSlotInfo(id, &Slot); + if (!tokenPresent || (Slot.flags & CKF_TOKEN_PRESENT) != 0) { + if (pSlotList != NULL_PTR && n < *pulCount) + pSlotList[n] = id; + ++n; + } + } + if (pSlotList != NULL_PTR && n > *pulCount) + rv = CKR_BUFFER_TOO_SMALL; + else + rv = CKR_OK; + *pulCount = n; + return (rv); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206131428.g5DESkE09164>