-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapka.c
More file actions
29 lines (25 loc) · 719 Bytes
/
Copy pathcapka.c
File metadata and controls
29 lines (25 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <sodium.h>
#include <string.h>
int capka_makeKeypair(
const char* password, // in
const char* saltData, // in
int ops, // in
int mem, // in
unsigned char* pk, // out
unsigned char* sk // out
) {
unsigned char salt[crypto_pwhash_SALTBYTES] = {0};
if(crypto_generichash(
salt, sizeof(salt), (unsigned char*) saltData, strlen(saltData),
NULL, 0
) != 0)
return -1;
unsigned char seed[crypto_sign_SEEDBYTES] = {0};
if(crypto_pwhash(
seed, sizeof(seed), password, strlen(password), salt, ops, mem,
crypto_pwhash_ALG_ARGON2ID13
) != 0)
return -1;
if(crypto_sign_seed_keypair(pk, sk, seed) != 0) return -1;
return 0;
}