mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-16 19:40:57 +01:00
catch sodium_init() return
This commit is contained in:
@@ -43,7 +43,10 @@ PCPCTX *ptx_new() {
|
|||||||
p->pcppubkey_hash = NULL;
|
p->pcppubkey_hash = NULL;
|
||||||
p->pcpkeysig_hash = NULL;
|
p->pcpkeysig_hash = NULL;
|
||||||
|
|
||||||
sodium_init();
|
if(sodium_init() == -1) {
|
||||||
|
perror("failed to initialize libsodium");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void pr(char *var, unsigned char *d, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
sodium_init();
|
if(sodium_init() == -1) return 1;
|
||||||
|
|
||||||
pcp_key_t *a = pcpkey_new();
|
pcp_key_t *a = pcpkey_new();
|
||||||
pcp_key_t *b = pcpkey_new();
|
pcp_key_t *b = pcpkey_new();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ int main() {
|
|||||||
strcpy(o, "xxxx");
|
strcpy(o, "xxxx");
|
||||||
strcpy(m, "xxxx");
|
strcpy(m, "xxxx");
|
||||||
|
|
||||||
sodium_init();
|
if(sodium_init() == -1) return 1;
|
||||||
PCPCTX *ptx = ptx_new();
|
PCPCTX *ptx = ptx_new();
|
||||||
pcp_key_t *k = pcpkey_new ();
|
pcp_key_t *k = pcpkey_new ();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ int main() {
|
|||||||
pw *have = NULL;
|
pw *have = NULL;
|
||||||
unsigned char nonce[32] = {1};
|
unsigned char nonce[32] = {1};
|
||||||
|
|
||||||
sodium_init();
|
if(sodium_init() == -1) return 1;
|
||||||
|
|
||||||
for(i=97; i<126; ++i) {
|
for(i=97; i<126; ++i) {
|
||||||
pass[0] = i;
|
pass[0] = i;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "static.h"
|
#include "static.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
sodium_init();
|
if(sodium_init() == -1) return 1;
|
||||||
unsigned char *t = ucmalloc(12);
|
unsigned char *t = ucmalloc(12);
|
||||||
if(crypto_box_open_easy(t, cipher, cipher_len, nonce, public_a, secret_b) == 0) {
|
if(crypto_box_open_easy(t, cipher, cipher_len, nonce, public_a, secret_b) == 0) {
|
||||||
if(memcmp(t, message, message_len) == 0) {
|
if(memcmp(t, message, message_len) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user