assertion failure was a bit heavy-handed here. Raise error instead
This commit is contained in:
parent
d64e567dbd
commit
c5ffd71eed
|
@ -105,7 +105,11 @@ pub fn decryptWithKey(allocator: std.mem.Allocator, key: [key_size]u8, data: []c
|
||||||
// deal with final block, PKCS#7 padding
|
// deal with final block, PKCS#7 padding
|
||||||
in = @ptrCast(*const [block_size]u8, data[(current_block * block_size)..(((current_block + 1) * block_size) - 1)]);
|
in = @ptrCast(*const [block_size]u8, data[(current_block * block_size)..(((current_block + 1) * block_size) - 1)]);
|
||||||
ctx.decrypt(out[0..], in.*[0..]);
|
ctx.decrypt(out[0..], in.*[0..]);
|
||||||
std.debug.assert(out[block_size - 1] <= block_size);
|
// Assertion was triggering when data was plain text
|
||||||
|
if (out[block_size - 1] > block_size) {
|
||||||
|
return error.DecryptionFailed;
|
||||||
|
}
|
||||||
|
// std.debug.assert(out[block_size - 1] <= block_size);
|
||||||
try decrypted.appendSlice(out[0 .. block_size - out[block_size - 1]]);
|
try decrypted.appendSlice(out[0 .. block_size - out[block_size - 1]]);
|
||||||
return decrypted.toOwnedSlice();
|
return decrypted.toOwnedSlice();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user