Skip to content

Commit

Permalink
lib.ipsec.esp.decrypt_payload: remove redundant bounds/spi checks
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Dec 15, 2017
1 parent 1600fcb commit ae09895
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/ipsec/esp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,13 @@ function decrypt:new (conf)
end

function decrypt:decrypt_payload (ptr, length)
if not self.esp:new_from_mem(ptr, length)
or self.esp:spi() ~= self.spi
then return nil end

-- NB: bounds check is performed by caller
local esp = self.esp:new_from_mem(ptr, esp:sizeof())
local iv_start = ptr + ESP_SIZE
local ctext_start = ptr + self.CTEXT_OFFSET
local ctext_length = length - self.PLAIN_OVERHEAD

local seq_low = self.esp:seq_no()
local seq_low = esp:seq_no()
local seq_high = tonumber(
C.check_seq_no(seq_low, self.seq.no, self.window, self.window_size)
)
Expand Down

0 comments on commit ae09895

Please sign in to comment.