created why2_chat_ecc_deserialize_public_key fn

This commit is contained in:
Václav Šmejkal 2025-02-01 13:03:03 +01:00
parent 313c2930e9
commit bf354372ff
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 19 additions and 0 deletions

View File

@ -44,6 +44,7 @@ char *why2_chat_ecc_sign(char *message); //SIGN message WITH ECC KEY
why2_bool why2_chat_ecc_verify_signature(char *message, char *signature, EVP_PKEY *key);
char *why2_chat_ecc_serialize_public_key(); //GET PUBLIC ECC KEY IN BASE64
EVP_PKEY* why2_chat_ecc_deserialize_public_key(char *pubkey); //GET EVP_PKEY FROM BASE64 PUBLIC ECC KEY
char *why2_sha256(char *input); //HASH input USING SHA256 AND RETURN IN STRING

View File

@ -223,6 +223,24 @@ char *why2_chat_ecc_serialize_public_key()
return base64_encoded;
}
//TODO: Remove PEM
EVP_PKEY* why2_chat_ecc_deserialize_public_key(char *pubkey)
{
//VARIABLES
BIO *bio;
EVP_PKEY *key;
char *base64_decoded = base64_decode(pubkey, NULL);
//EXTRACT KEY
bio = BIO_new_mem_buf(base64_decoded, -1);
key = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
//DEALLOCATION
BIO_free(bio);
return key;
}
void why2_chat_deallocate_keys(void)
{
//DEALLOCATE THE pkey