Skip to content

Commit

Permalink
Revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Sep 4, 2024
1 parent e217e82 commit 61cc36d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,11 @@ bool read_ed25519_key(uint8_t *in, size_t in_len, uint8_t *out,
uint8_t decoded[128];
size_t decoded_len = sizeof(decoded);

if (in_len < (sizeof(PEM_private_header) + sizeof(PEM_private_trailer) -
3)) { // -3 to account for null bytes in PEM_private_header and
// PEM_private_trailer
if (in_len < (sizeof(PEM_private_header) + sizeof(PEM_private_trailer) - 2)) {
return false;
}
if (memcmp(in, PEM_private_header, sizeof(PEM_private_header) - 1) != 0 ||
memcmp(in + in_len - (sizeof(PEM_private_trailer) - 1),
PEM_private_trailer, sizeof(PEM_private_trailer) - 2) != 0) {
if (memcmp(in, PEM_private_header, 28) != 0 ||
memcmp(in + in_len - 26, PEM_private_trailer, 25) != 0) {
return false;
}

Expand All @@ -97,9 +94,7 @@ bool read_ed25519_key(uint8_t *in, size_t in_len, uint8_t *out,
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
BIO_push(b64, bio);

if (BIO_write(bio, in + (sizeof(PEM_private_header) - 1),
in_len - (sizeof(PEM_private_header) - 1) -
(sizeof(PEM_private_trailer) - 2)) <= 0) {
if (BIO_write(bio, in + 28, in_len - 28 - 25) <= 0) {
BIO_free_all(b64);
return false;
}
Expand Down

0 comments on commit 61cc36d

Please sign in to comment.