From owner-p4-projects Thu Jun 13 7:30: 6 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4A24337B4BD; Thu, 13 Jun 2002 07:29:24 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id AB4AF37B4A6 for ; Thu, 13 Jun 2002 07:28:46 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5DESkE09164 for perforce@freebsd.org; Thu, 13 Jun 2002 07:28:46 -0700 (PDT) (envelope-from des@freebsd.org) Date: Thu, 13 Jun 2002 07:28:46 -0700 (PDT) Message-Id: <200206131428.g5DESkE09164@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to des@freebsd.org using -f From: Dag-Erling Smorgrav Subject: PERFORCE change 12820 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 + #include +#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 +#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