Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/pkcs1_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,25 @@ EXPORT_SYM int pkcs1_decode(const uint8_t *em, size_t len_em_output,
size_t pos;
uint8_t match, selector;
uint8_t *padded_sentinel;
int result;

result = -1;
int result = -1;

if (NULL == em || NULL == output || NULL == sentinel) {
return -1;
return result;
}
if (len_em_output < (PKCS1_PREFIX_LEN + 2)) {
return -1;
return result;
}
if (len_sentinel > len_em_output) {
return -1;
return result;
}
if (expected_pt_len > 0 && expected_pt_len > (len_em_output - PKCS1_PREFIX_LEN - 1)) {
return -1;
return result;
}

/** Pad sentinel (on the left) so that it matches em in length **/
padded_sentinel = (uint8_t*) calloc(1, len_em_output);
if (NULL == padded_sentinel) {
return -1;
return result;
}
memcpy(padded_sentinel + (len_em_output - len_sentinel), sentinel, len_sentinel);

Expand All @@ -254,7 +252,6 @@ EXPORT_SYM int pkcs1_decode(const uint8_t *em, size_t len_em_output,
*/
pos = safe_search(em + 10, 0, len_em_output - 10) + 10;
if (pos == SIZE_T_MAX) {
result = -1;
goto end;
}

Expand Down
Loading