Skip to content

Commit

Permalink
Fix: fixed wrong usages of CRYPTO_PUBLIC_KEY_SIZE to CRYPTO_SECRET_KE…
Browse files Browse the repository at this point in the history
…Y_SIZE.
  • Loading branch information
goldroom committed Mar 18, 2024
1 parent 190c038 commit 2201b8c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion toxcore/crypto_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void crypto_hkdf(uint8_t *output1, uint8_t *output2, const uint8_t *data,
*/
int32_t noise_mix_key(uint8_t chaining_key[CRYPTO_SHA512_SIZE],
uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE],
const uint8_t private_key[CRYPTO_PUBLIC_KEY_SIZE],
const uint8_t private_key[CRYPTO_SECRET_KEY_SIZE],
const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE])
{
uint8_t dh_calculation[CRYPTO_PUBLIC_KEY_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion toxcore/crypto_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void crypto_hkdf(uint8_t *output1, uint8_t *output2, const uint8_t *data,
* @param public_key X25519 public key
*/
int32_t noise_mix_key(uint8_t chaining_key[CRYPTO_SHA512_SIZE], uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE],
const uint8_t private_key[CRYPTO_PUBLIC_KEY_SIZE],
const uint8_t private_key[CRYPTO_SECRET_KEY_SIZE],
const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]);

/**
Expand Down
6 changes: 3 additions & 3 deletions toxcore/net_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static int noise_handshake_init
/* Sets the initiator, s => ephemeral keys are set afterwards */
noise_handshake->initiator = initiator;
if (self_secret_key != nullptr) {
memcpy(noise_handshake->static_private, self_secret_key, CRYPTO_PUBLIC_KEY_SIZE);
memcpy(noise_handshake->static_private, self_secret_key, CRYPTO_SECRET_KEY_SIZE);
crypto_derive_public_key(noise_handshake->static_public, self_secret_key);

//TODO: remove
Expand Down Expand Up @@ -661,7 +661,7 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u
*/
if (noise_handshake->initiator) {
/* set ephemeral private+public */
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_PUBLIC_KEY_SIZE);
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_SECRET_KEY_SIZE);
memcpy(noise_handshake->ephemeral_public, ephemeral_public, CRYPTO_PUBLIC_KEY_SIZE);

/* e */
Expand Down Expand Up @@ -756,7 +756,7 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u
*/
else {
/* set ephemeral private+public */
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_PUBLIC_KEY_SIZE);
memcpy(noise_handshake->ephemeral_private, ephemeral_private, CRYPTO_SECRET_KEY_SIZE);
memcpy(noise_handshake->ephemeral_public, ephemeral_public, CRYPTO_PUBLIC_KEY_SIZE);

/* e */
Expand Down
8 changes: 4 additions & 4 deletions toxcore/net_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ non_null() DHT *nc_get_dht(const Net_Crypto *c);
*/
typedef struct Noise_Handshake {
//TODO: static_private?
uint8_t static_private[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t static_private[CRYPTO_SECRET_KEY_SIZE];
uint8_t static_public[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t ephemeral_private[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t ephemeral_private[CRYPTO_SECRET_KEY_SIZE];
uint8_t ephemeral_public[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t remote_static[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t remote_ephemeral[CRYPTO_PUBLIC_KEY_SIZE];
Expand All @@ -161,8 +161,8 @@ typedef struct New_Connection {
//TODO: if no struct necessary
// uint8_t noise_hash[CRYPTO_SHA512_SIZE];
// uint8_t noise_chaining_key[CRYPTO_SHA512_SIZE];
// uint8_t niose_send_key[CRYPTO_PUBLIC_KEY_SIZE];
// uint8_t noise_recv_key[CRYPTO_PUBLIC_KEY_SIZE];
// uint8_t niose_send_key[CRYPTO_SHARED_KEY_SIZE];
// uint8_t noise_recv_key[CRYPTO_SHARED_KEY_SIZE];
// bool initiator;

uint8_t *cookie;
Expand Down

0 comments on commit 2201b8c

Please sign in to comment.