Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore compatibility with wolfPKCS11_Store_Open #41

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ static int wolfPKCS11_Store_GetMaxSize(int type, int variableSz)
* @return NOT_AVAILABLE_E when data not available.
* @return Other value to indicate failure.
*/
int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
int wolfPKCS11_Store_OpenSz(int type, CK_ULONG id1, CK_ULONG id2, int read,
int variableSz, void** store)
{
int ret = 0;
Expand Down Expand Up @@ -908,6 +908,24 @@ int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
return ret;
}

/**
* Opens access to location to read/write token data.
*
* @param [in] type Type of data to be stored. See WOLFPKCS11_STORE_*.
* @param [in] id1 Numeric identifier 1.
* @param [in] id2 Numeric identifier 2.
* @param [in] read 1 when opening for read and 0 for write.
* @param [out] store Returns file pointer.
* @return 0 on success.
* @return NOT_AVAILABLE_E when data not available.
* @return Other value to indicate failure.
*/
int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
void** store)
{
return wolfPKCS11_Store_OpenSz(type, id1, id2, read, 0, store);
}

/**
* Closes access to location being read or written.
* Any dynamic memory associated with the store is freed here.
Expand Down Expand Up @@ -1037,7 +1055,7 @@ int wolfPKCS11_Store_Write(void* store, unsigned char* buffer, int len)
static int wp11_storage_open_readonly(int type, CK_ULONG id1, CK_ULONG id2,
void** storage)
{
return wolfPKCS11_Store_Open(type, id1, id2, 1, 0, storage);
return wolfPKCS11_Store_OpenSz(type, id1, id2, 1, 0, storage);
}

/*
Expand All @@ -1055,7 +1073,7 @@ static int wp11_storage_open_readonly(int type, CK_ULONG id1, CK_ULONG id2,
static int wp11_storage_open(int type, CK_ULONG id1, CK_ULONG id2,
int variableSz, void** storage)
{
return wolfPKCS11_Store_Open(type, id1, id2, 0, variableSz, storage);
return wolfPKCS11_Store_OpenSz(type, id1, id2, 0, variableSz, storage);
}

/*
Expand Down
17 changes: 16 additions & 1 deletion wolfpkcs11/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,28 @@
* @param [in] id1 Numeric identifier 1.
* @param [in] id2 Numeric identifier 2.
* @param [in] read 1 when opening for read and 0 for write.
* @param [in] variableSz additional size needed for type (needed on write)
* @param [out] store Return pointer to context data.
* @return 0 on success.
* @return -4 when data not available.
* @return Other value to indicate failure.
*/
int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
void** store);

/*
* Opens access to location to read/write token data.
*
* @param [in] type Type of data to be stored. See WOLFPKCS11_STORE_* above.
* @param [in] id1 Numeric identifier 1.
* @param [in] id2 Numeric identifier 2.
* @param [in] read 1 when opening for read and 0 for write.
* @param [in] variableSz additional size needed for type (needed on write)
* @param [out] store Return pointer to context data.
* @return 0 on success.
* @return -4 when data not available.
* @return Other value to indicate failure.
*/
int wolfPKCS11_Store_OpenSz(int type, CK_ULONG id1, CK_ULONG id2, int read,
int variableSz, void** store);

/*
Expand Down
Loading