Add sample public keys and more error check
This commit is contained in:
parent
b3952e922a
commit
a36ee089fe
3 changed files with 26 additions and 9 deletions
|
@ -125,6 +125,12 @@ uint8_t *get_pk_from_ks(char *username)
|
||||||
} else if (strcmp(username, "palanix") == 0) {
|
} else if (strcmp(username, "palanix") == 0) {
|
||||||
sodium_hex2bin(bin, bin_len, "932aee08aa338108e49f65a5c4f0eb0a08a15bf717fdf8c0ff60eefd0ea014ae", PK_ED25519_SIZE * 2, NULL, NULL, NULL);
|
sodium_hex2bin(bin, bin_len, "932aee08aa338108e49f65a5c4f0eb0a08a15bf717fdf8c0ff60eefd0ea014ae", PK_ED25519_SIZE * 2, NULL, NULL, NULL);
|
||||||
return bin;
|
return bin;
|
||||||
|
} else if (strcmp(username, "martinmimi") == 0) {
|
||||||
|
sodium_hex2bin(bin, bin_len, "3d381d61114234bcb0e17d650e0be2e3528b592af665f1c503ba2667c69f2d72", PK_ED25519_SIZE * 2, NULL, NULL, NULL);
|
||||||
|
return bin;
|
||||||
|
} else if (strcmp(username, "finnimo") == 0) {
|
||||||
|
sodium_hex2bin(bin, bin_len, "fdd6710716a01d1421a341017d087945c721151c4d541b46092ec2bbc31d7e8f", PK_ED25519_SIZE * 2, NULL, NULL, NULL);
|
||||||
|
return bin;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
16
src/zen/ui.c
16
src/zen/ui.c
|
@ -24,8 +24,6 @@ int sockfd;
|
||||||
static int curs_pos = 0;
|
static int curs_pos = 0;
|
||||||
static char content[MAX_MESSAGE_LENGTH];
|
static char content[MAX_MESSAGE_LENGTH];
|
||||||
|
|
||||||
void send_message();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free and close everything
|
* Free and close everything
|
||||||
*/
|
*/
|
||||||
|
@ -538,11 +536,17 @@ void send_message()
|
||||||
uint8_t from_pk[PK_X25519_SIZE];
|
uint8_t from_pk[PK_X25519_SIZE];
|
||||||
uint8_t to_pk[PK_X25519_SIZE];
|
uint8_t to_pk[PK_X25519_SIZE];
|
||||||
uint8_t from_sk[SK_X25519_SIZE];
|
uint8_t from_sk[SK_X25519_SIZE];
|
||||||
crypto_sign_ed25519_pk_to_curve25519(from_pk, kp_from->pk.raw);
|
if (crypto_sign_ed25519_pk_to_curve25519(from_pk, kp_from->pk.raw) != 0
|
||||||
crypto_sign_ed25519_pk_to_curve25519(to_pk, pk_to);
|
) {
|
||||||
crypto_sign_ed25519_sk_to_curve25519(from_sk, kp_from->sk);
|
error(1, "Error converting ED25519 PK to X25519 PK");
|
||||||
|
}
|
||||||
|
if (crypto_sign_ed25519_pk_to_curve25519(to_pk, pk_to) != 0) {
|
||||||
|
error(1, "Error converting ED25519 PK to X25519 PK");
|
||||||
|
}
|
||||||
|
if (crypto_sign_ed25519_sk_to_curve25519(from_sk, kp_from->sk) != 0) {
|
||||||
|
error(1, "Error converting ED25519 SK to X25519 SK");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (crypto_kx_client_session_keys(shared_key, NULL, from_pk, from_sk,
|
if (crypto_kx_client_session_keys(shared_key, NULL, from_pk, from_sk,
|
||||||
to_pk) != 0) {
|
to_pk) != 0) {
|
||||||
deinit();
|
deinit();
|
||||||
|
|
|
@ -100,9 +100,16 @@ void *receive_worker(void *arg)
|
||||||
uint8_t to_pk[PK_X25519_SIZE];
|
uint8_t to_pk[PK_X25519_SIZE];
|
||||||
uint8_t from_pk[PK_X25519_SIZE];
|
uint8_t from_pk[PK_X25519_SIZE];
|
||||||
uint8_t to_sk[SK_X25519_SIZE];
|
uint8_t to_sk[SK_X25519_SIZE];
|
||||||
crypto_sign_ed25519_pk_to_curve25519(to_pk, kp_to->pk.raw);
|
if (crypto_sign_ed25519_pk_to_curve25519(to_pk, kp_to->pk.raw)
|
||||||
crypto_sign_ed25519_pk_to_curve25519(from_pk, pk_from);
|
!= 0) {
|
||||||
crypto_sign_ed25519_sk_to_curve25519(to_sk, kp_to->sk);
|
error(1, "Error converting ED25519 PK to X25519 PK");
|
||||||
|
}
|
||||||
|
if (crypto_sign_ed25519_pk_to_curve25519(from_pk, pk_from) != 0) {
|
||||||
|
error(1, "Error converting ED25519 PK to X25519 PK");
|
||||||
|
}
|
||||||
|
if (crypto_sign_ed25519_sk_to_curve25519(to_sk, kp_to->sk) != 0) {
|
||||||
|
error(1, "Error converting ED25519 SK to X25519 SK");
|
||||||
|
}
|
||||||
|
|
||||||
if (crypto_kx_server_session_keys(shared_key, NULL, to_pk,
|
if (crypto_kx_server_session_keys(shared_key, NULL, to_pk,
|
||||||
to_sk, from_pk) != 0) {
|
to_sk, from_pk) != 0) {
|
||||||
|
|
Loading…
Reference in a new issue