Skip to content

Commit

Permalink
fix most of reality bugs, works fine for now but needs more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed May 10, 2024
1 parent be49573 commit 63d930f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tunnels/client/reality/reality_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static void upStream(tunnel_t *self, context_t *c)
shift_buffer_t *buf = c->payload;
c->payload = NULL;

const int chunk_size = ((1 << 16) - (kSignLen + (kEncryptionBlockSize) + kIVlen));
const int chunk_size = ((1 << 16) - (kSignLen + (2*kEncryptionBlockSize) + kIVlen));

if (bufLen(buf) < chunk_size)
{
Expand Down
2 changes: 1 addition & 1 deletion tunnels/server/reality/reality_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static void downStream(tunnel_t *self, context_t *c)
case kConAuthorized:;
shift_buffer_t *buf = c->payload;
c->payload = NULL;
const int chunk_size = ((1 << 16) - (kSignLen + (kEncryptionBlockSize) + kIVlen));
const int chunk_size = ((1 << 16) - (kSignLen + (2*kEncryptionBlockSize) + kIVlen));

if (bufLen(buf) < chunk_size)
{
Expand Down
4 changes: 2 additions & 2 deletions tunnels/shared/reality/reality_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ static shift_buffer_t *genericEncrypt(shift_buffer_t *in, EVP_CIPHER_CTX *encryp
int input_length = (int) bufLen(in);

uint8_t iv[kIVlen];
for (int i; i < kIVlen / sizeof(uint32_t); i++)
for (int i = 0; i < kIVlen / sizeof(uint32_t); i++)
{
((uint32_t *) iv)[i] = fastRand();
}

EVP_EncryptInit_ex(encryption_context, EVP_aes_128_cbc(), NULL, (const uint8_t *) password, (const uint8_t *) iv);

reserveBufSpace(out, input_length + (input_length % kEncryptionBlockSize));
reserveBufSpace(out, input_length + kEncryptionBlockSize +(input_length % kEncryptionBlockSize));
int out_len = 0;

/*
Expand Down

0 comments on commit 63d930f

Please sign in to comment.