mirror of
https://github.com/CPunch/Laika.git
synced 2025-11-30 06:30:05 +00:00
Added lsodium.c, laikaK_loadKeys, laikaK_genKeys
This commit is contained in:
19
lib/src/lsodium.c
Normal file
19
lib/src/lsodium.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "lsodium.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
bool laikaK_loadKeys(uint8_t *outPub, uint8_t *outPriv, const char *inPub, const char *inPriv) {
|
||||
size_t _unused;
|
||||
|
||||
if (outPub && sodium_hex2bin(outPub, crypto_kx_PUBLICKEYBYTES, inPub, strlen(inPub), NULL, &_unused, NULL) != 0)
|
||||
return false;
|
||||
|
||||
if (outPriv && sodium_hex2bin(outPriv, crypto_kx_SECRETKEYBYTES, inPriv, strlen(inPriv), NULL, &_unused, NULL) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool laikaK_genKeys(uint8_t *outPub, uint8_t *outPriv) {
|
||||
return crypto_kx_keypair(outPub, outPriv) == 0;
|
||||
}
|
||||
Reference in New Issue
Block a user