Skip to content

Commit be15345

Browse files
authored
Merge pull request #597 from LinuxJedi/wolfpkcs11-2.0
wolfPKCS 2.0 support
2 parents 004e91d + 2276a63 commit be15345

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lib/wolfPKCS11

Submodule wolfPKCS11 updated 54 files

src/pkcs11_store.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,17 @@ int wolfPKCS11_Store_Write(void* store, unsigned char* buffer, int len)
530530
return len;
531531
}
532532

533+
int wolfPKCS11_Store_Remove(int type, CK_ULONG id1, CK_ULONG id2)
534+
{
535+
uint8_t* buf;
536+
537+
check_vault();
538+
buf = find_object_buffer((int32_t)type, (uint32_t)id1, (uint32_t)id2);
539+
if (buf == NULL)
540+
return NOT_AVAILABLE_E;
541+
542+
delete_object((int32_t)type, (uint32_t)id1, (uint32_t)id2);
543+
return 0;
544+
}
545+
533546
#endif /* SECURE_PKCS11 */

tools/unit-tests/unit-pkcs11_store.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
#include "user_settings.h"
5757
#include "wolfssl/wolfcrypt/sha.h"
58+
#include "wolfssl/wolfcrypt/error-crypt.h"
5859
#include "wolfboot/wolfboot.h"
5960
#include "wolfpkcs11/pkcs11.h"
6061
#include "hal.h"
@@ -264,6 +265,18 @@ START_TEST (test_store_and_load_objs) {
264265
ck_assert(ret == strlen(short_string) + 1);
265266
ck_assert(strcmp(short_string, secret_rd) == 0);
266267
wolfPKCS11_Store_Close(store);
268+
269+
/* Remove the object and confirm it is no longer addressable */
270+
ret = wolfPKCS11_Store_Remove(type, id_tok, id_obj);
271+
ck_assert_msg(ret == 0, "Failed to delete vault: %d", ret);
272+
273+
readonly = 1;
274+
ret = wolfPKCS11_Store_Open(type, id_tok, id_obj, readonly, &store);
275+
ck_assert_int_eq(ret, NOT_AVAILABLE_E);
276+
277+
/* Second removal attempt should report the object is already gone */
278+
ret = wolfPKCS11_Store_Remove(type, id_tok, id_obj);
279+
ck_assert_int_eq(ret, NOT_AVAILABLE_E);
267280
}
268281
END_TEST
269282

0 commit comments

Comments
 (0)