Skip to content

Commit 2201b8c

Browse files
committed
Fix: fixed wrong usages of CRYPTO_PUBLIC_KEY_SIZE to CRYPTO_SECRET_KEY_SIZE.
1 parent 190c038 commit 2201b8c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

toxcore/crypto_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ void crypto_hkdf(uint8_t *output1, uint8_t *output2, const uint8_t *data,
651651
*/
652652
int32_t noise_mix_key(uint8_t chaining_key[CRYPTO_SHA512_SIZE],
653653
uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE],
654-
const uint8_t private_key[CRYPTO_PUBLIC_KEY_SIZE],
654+
const uint8_t private_key[CRYPTO_SECRET_KEY_SIZE],
655655
const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE])
656656
{
657657
uint8_t dh_calculation[CRYPTO_PUBLIC_KEY_SIZE];

toxcore/crypto_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void crypto_hkdf(uint8_t *output1, uint8_t *output2, const uint8_t *data,
601601
* @param public_key X25519 public key
602602
*/
603603
int32_t noise_mix_key(uint8_t chaining_key[CRYPTO_SHA512_SIZE], uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE],
604-
const uint8_t private_key[CRYPTO_PUBLIC_KEY_SIZE],
604+
const uint8_t private_key[CRYPTO_SECRET_KEY_SIZE],
605605
const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]);
606606

607607
/**

toxcore/net_crypto.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static int noise_handshake_init
560560
/* Sets the initiator, s => ephemeral keys are set afterwards */
561561
noise_handshake->initiator = initiator;
562562
if (self_secret_key != nullptr) {
563-
memcpy(noise_handshake->static_private, self_secret_key, CRYPTO_PUBLIC_KEY_SIZE);
563+
memcpy(noise_handshake->static_private, self_secret_key, CRYPTO_SECRET_KEY_SIZE);
564564
crypto_derive_public_key(noise_handshake->static_public, self_secret_key);
565565

566566
//TODO: remove
@@ -661,7 +661,7 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u
661661
*/
662662
if (noise_handshake->initiator) {
663663
/* set ephemeral private+public */
664-
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_PUBLIC_KEY_SIZE);
664+
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_SECRET_KEY_SIZE);
665665
memcpy(noise_handshake->ephemeral_public, ephemeral_public, CRYPTO_PUBLIC_KEY_SIZE);
666666

667667
/* e */
@@ -756,7 +756,7 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u
756756
*/
757757
else {
758758
/* set ephemeral private+public */
759-
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_PUBLIC_KEY_SIZE);
759+
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_SECRET_KEY_SIZE);
760760
memcpy(noise_handshake->ephemeral_public, ephemeral_public, CRYPTO_PUBLIC_KEY_SIZE);
761761

762762
/* e */

toxcore/net_crypto.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ non_null() DHT *nc_get_dht(const Net_Crypto *c);
135135
*/
136136
typedef struct Noise_Handshake {
137137
//TODO: static_private?
138-
uint8_t static_private[CRYPTO_PUBLIC_KEY_SIZE];
138+
uint8_t static_private[CRYPTO_SECRET_KEY_SIZE];
139139
uint8_t static_public[CRYPTO_PUBLIC_KEY_SIZE];
140-
uint8_t ephemeral_private[CRYPTO_PUBLIC_KEY_SIZE];
140+
uint8_t ephemeral_private[CRYPTO_SECRET_KEY_SIZE];
141141
uint8_t ephemeral_public[CRYPTO_PUBLIC_KEY_SIZE];
142142
uint8_t remote_static[CRYPTO_PUBLIC_KEY_SIZE];
143143
uint8_t remote_ephemeral[CRYPTO_PUBLIC_KEY_SIZE];
@@ -161,8 +161,8 @@ typedef struct New_Connection {
161161
//TODO: if no struct necessary
162162
// uint8_t noise_hash[CRYPTO_SHA512_SIZE];
163163
// uint8_t noise_chaining_key[CRYPTO_SHA512_SIZE];
164-
// uint8_t niose_send_key[CRYPTO_PUBLIC_KEY_SIZE];
165-
// uint8_t noise_recv_key[CRYPTO_PUBLIC_KEY_SIZE];
164+
// uint8_t niose_send_key[CRYPTO_SHARED_KEY_SIZE];
165+
// uint8_t noise_recv_key[CRYPTO_SHARED_KEY_SIZE];
166166
// bool initiator;
167167

168168
uint8_t *cookie;

0 commit comments

Comments
 (0)