Skip to content
Open
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
21 changes: 19 additions & 2 deletions tool/vapid.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <openssl/ec.h>
#include <openssl/obj_mac.h>
#include <openssl/sha.h>
#include <openssl/pem.h>

#include <ece.h>
#include <ece/keys.h>
Expand Down Expand Up @@ -263,8 +264,24 @@ vapid_build_token(EC_KEY* key, const char* aud, size_t audLen, uint32_t exp,
}

static EC_KEY*
vapid_import_private_key(const char* b64PrivKey) {
return NULL;
vapid_import_private_key(const char* b64PrivKeyPemFormat) {
size_t pv_key_len = strlen(b64PrivKeyPemFormat);
BIO *mem = BIO_new(BIO_s_mem());
if ((size_t)BIO_write(mem, b64PrivKeyPemFormat, pv_key_len) != pv_key_len) {
return NULL;
}

EC_KEY *EC_KEY_ptr = PEM_read_bio_ECPrivateKey(mem , NULL, NULL, NULL);
BIO_free_all(mem);
if(EC_KEY_ptr == NULL) {
BIO_free_all(mem);
return NULL;
}

if(EC_KEY_check_key(EC_KEY_ptr) == 0) {
return NULL;
}
return EC_KEY_ptr;
}

static EC_KEY*
Expand Down