Commit bf3a7160 authored by Daiki Ueno's avatar Daiki Ueno

From 23c0949786a1a7ac222be2b5391ab2d654342e99 Mon Sep 17 00:00:00 2001

Bug 1162897, pk11wrap: add pk11_MatchString, r=rrelyea
parent 0e99f0e4
......@@ -45,6 +45,8 @@ CK_ULONG PK11_ReadULongAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
CK_ATTRIBUTE_TYPE type);
char *PK11_MakeString(PLArenaPool *arena, char *space, char *staticSring,
int stringLen);
PRBool pk11_MatchString(const char *string,
const char *staticString, int staticStringLen);
int PK11_MapError(CK_RV error);
CK_SESSION_HANDLE PK11_GetRWSession(PK11SlotInfo *slot);
void PK11_RestoreROSession(PK11SlotInfo *slot, CK_SESSION_HANDLE rwsession);
......
......@@ -1076,6 +1076,29 @@ PK11_MakeString(PLArenaPool *arena, char *space,
return newString;
}
/*
* check if a null-terminated string matches with a PKCS11 Static Label
*/
PRBool
pk11_MatchString(const char *string,
const char *staticString, int staticStringLen)
{
int i;
for (i = (staticStringLen - 1); i >= 0; i--) {
if (staticString[i] != ' ')
break;
}
/* move i to point to the last space */
i++;
if (strlen(string) == i && memcmp(string, staticString, i) == 0) {
return PR_TRUE;
}
return PR_FALSE;
}
/*
* Reads in the slots mechanism list for later use
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment