created why2_chat_ecc_serialize_public_key fn
This commit is contained in:
parent
7eb7940701
commit
7bb6e38a99
@ -43,6 +43,8 @@ void why2_chat_deallocate_keys(void); //DEALLOCATE :) (NO SLUR HERE)
|
||||
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
|
||||
|
||||
char *why2_sha256(char *input); //HASH input USING SHA256 AND RETURN IN STRING
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -189,6 +189,37 @@ why2_bool why2_chat_ecc_verify_signature(char *message, char *signature, EVP_PKE
|
||||
return returning;
|
||||
}
|
||||
|
||||
//TODO: Remove PEM
|
||||
char *why2_chat_ecc_serialize_public_key()
|
||||
{
|
||||
//VARIABLES
|
||||
BIO *bio = BIO_new(BIO_s_mem());
|
||||
char *data;
|
||||
size_t length;
|
||||
char *pubkey;
|
||||
char *base64_encoded;
|
||||
|
||||
//SEPARATE PUBKEY
|
||||
PEM_write_bio_PUBKEY(bio, keypair);
|
||||
|
||||
//ALLOCATE
|
||||
length = BIO_get_mem_data(bio, &data);
|
||||
pubkey = why2_malloc(length + 1);
|
||||
|
||||
//COPY
|
||||
memcpy(pubkey, data, length);
|
||||
pubkey[length] = '\0';
|
||||
|
||||
//ENCODE
|
||||
base64_encoded = base64_encode(pubkey, length);
|
||||
|
||||
//DEALLOCATION
|
||||
BIO_free(bio);
|
||||
why2_deallocate(pubkey);
|
||||
|
||||
return base64_encoded;
|
||||
}
|
||||
|
||||
void why2_chat_deallocate_keys(void)
|
||||
{
|
||||
//DEALLOCATE THE pkey
|
||||
|
Loading…
x
Reference in New Issue
Block a user