Skip to content

Commit 6bee701

Browse files
authored
Merge pull request #41 from dgarske/store_api_compat
Restore compatibility with `wolfPKCS11_Store_Open`
2 parents b96cdfb + b4466aa commit 6bee701

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/internal.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static int wolfPKCS11_Store_GetMaxSize(int type, int variableSz)
731731
* @return NOT_AVAILABLE_E when data not available.
732732
* @return Other value to indicate failure.
733733
*/
734-
int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
734+
int wolfPKCS11_Store_OpenSz(int type, CK_ULONG id1, CK_ULONG id2, int read,
735735
int variableSz, void** store)
736736
{
737737
int ret = 0;
@@ -908,6 +908,24 @@ int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
908908
return ret;
909909
}
910910

911+
/**
912+
* Opens access to location to read/write token data.
913+
*
914+
* @param [in] type Type of data to be stored. See WOLFPKCS11_STORE_*.
915+
* @param [in] id1 Numeric identifier 1.
916+
* @param [in] id2 Numeric identifier 2.
917+
* @param [in] read 1 when opening for read and 0 for write.
918+
* @param [out] store Returns file pointer.
919+
* @return 0 on success.
920+
* @return NOT_AVAILABLE_E when data not available.
921+
* @return Other value to indicate failure.
922+
*/
923+
int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
924+
void** store)
925+
{
926+
return wolfPKCS11_Store_OpenSz(type, id1, id2, read, 0, store);
927+
}
928+
911929
/**
912930
* Closes access to location being read or written.
913931
* Any dynamic memory associated with the store is freed here.
@@ -1037,7 +1055,7 @@ int wolfPKCS11_Store_Write(void* store, unsigned char* buffer, int len)
10371055
static int wp11_storage_open_readonly(int type, CK_ULONG id1, CK_ULONG id2,
10381056
void** storage)
10391057
{
1040-
return wolfPKCS11_Store_Open(type, id1, id2, 1, 0, storage);
1058+
return wolfPKCS11_Store_OpenSz(type, id1, id2, 1, 0, storage);
10411059
}
10421060

10431061
/*
@@ -1055,7 +1073,7 @@ static int wp11_storage_open_readonly(int type, CK_ULONG id1, CK_ULONG id2,
10551073
static int wp11_storage_open(int type, CK_ULONG id1, CK_ULONG id2,
10561074
int variableSz, void** storage)
10571075
{
1058-
return wolfPKCS11_Store_Open(type, id1, id2, 0, variableSz, storage);
1076+
return wolfPKCS11_Store_OpenSz(type, id1, id2, 0, variableSz, storage);
10591077
}
10601078

10611079
/*

wolfpkcs11/store.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,28 @@
4040
* @param [in] id1 Numeric identifier 1.
4141
* @param [in] id2 Numeric identifier 2.
4242
* @param [in] read 1 when opening for read and 0 for write.
43-
* @param [in] variableSz additional size needed for type (needed on write)
4443
* @param [out] store Return pointer to context data.
4544
* @return 0 on success.
4645
* @return -4 when data not available.
4746
* @return Other value to indicate failure.
4847
*/
4948
int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
49+
void** store);
50+
51+
/*
52+
* Opens access to location to read/write token data.
53+
*
54+
* @param [in] type Type of data to be stored. See WOLFPKCS11_STORE_* above.
55+
* @param [in] id1 Numeric identifier 1.
56+
* @param [in] id2 Numeric identifier 2.
57+
* @param [in] read 1 when opening for read and 0 for write.
58+
* @param [in] variableSz additional size needed for type (needed on write)
59+
* @param [out] store Return pointer to context data.
60+
* @return 0 on success.
61+
* @return -4 when data not available.
62+
* @return Other value to indicate failure.
63+
*/
64+
int wolfPKCS11_Store_OpenSz(int type, CK_ULONG id1, CK_ULONG id2, int read,
5065
int variableSz, void** store);
5166

5267
/*

0 commit comments

Comments
 (0)