Skip to content

Commit 6a2dd54

Browse files
committed
add check that pkcs #1 v1.5 is greater then 8 bytes
1 parent ce7b1d1 commit 6a2dd54

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: src/padding/pkcs_1_v1_5.jl

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ end
2525
Core implementation of the [PKCS#1 v1.5 padding](https://www.rfc-editor.org/rfc/rfc2313#section-8.1).
2626
"""
2727
function pad(msg::AbstractVector{T}, pad_length=32) where {T<:Base.BitInteger}
28+
pad_length > 8 || throw(error("Will not create pad with length < 8"))
2829
buff = rand(T(1):T(typemax(T)), pad_length + 3)
2930
buff[1] = 0
3031
buff[2] = 2
@@ -39,6 +40,7 @@ end
3940
Wrapper for the core pad function.
4041
"""
4142
function pad(msg::T, pad_length=32) where {T<:AbstractString}
43+
pad_length > 8 || throw(error("Will not create pad with length < 8"))
4244
msg_cu = codeunits(msg)
4345
msg_padded = pad(msg_cu, pad_length)
4446
return T(msg_padded)

0 commit comments

Comments
 (0)