Let's swap a signature and a half of a nonce. And sign both a pub key and the half of a nonce.
This commit is contained in:
parent
1afd678fd4
commit
944a81a8bf
@ -113,12 +113,13 @@ unsigned char *crypt_hello(const crypt_key_t *const own) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crypto_sign_detached(hello+CRYPT_PKEY_HEXLEN, NULL, (const unsigned char *)hello, CRYPT_PKEY_HEXLEN, own->sign_sec) == -1) {
|
randombytes_buf(hello+CRYPT_PKEY_HEXLEN, CRYPT_NONCEHALF_LEN);
|
||||||
|
|
||||||
|
if (crypto_sign_detached(hello+CRYPT_PKEY_HEXLEN+CRYPT_NONCEHALF_LEN, NULL, (const unsigned char *)hello, CRYPT_PKEY_HEXLEN+CRYPT_NONCEHALF_LEN, own->sign_sec) == -1) {
|
||||||
free(hello);
|
free(hello);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
randombytes_buf(hello+CRYPT_PKEY_HEXLEN+CRYPT_SIGN_LEN, CRYPT_NONCEHALF_LEN);
|
|
||||||
|
|
||||||
return hello;
|
return hello;
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ int crypt_hello_verify(const unsigned char *const hello, crypt_key_t *const remo
|
|||||||
if (crypt_key_from_hex_public(remote, (const char *const)hello) == -1)
|
if (crypt_key_from_hex_public(remote, (const char *const)hello) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (crypto_sign_verify_detached(hello+CRYPT_PKEY_HEXLEN, (const unsigned char *const)hello, CRYPT_PKEY_HEXLEN, remote->sign_pub))
|
if (crypto_sign_verify_detached(hello+CRYPT_PKEY_HEXLEN+CRYPT_NONCEHALF_LEN, (const unsigned char *const)hello, CRYPT_PKEY_HEXLEN+CRYPT_NONCEHALF_LEN, remote->sign_pub))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user