padding: use new function clear()

This commit is contained in:
Sun Yimin 2025-02-26 11:41:47 +08:00 committed by GitHub
parent 51a003b022
commit a98b806453
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 6 deletions

View File

@ -17,9 +17,7 @@ func (pad ansiX923Padding) Pad(src []byte) []byte {
overhead := pad.BlockSize() - len(src)%pad.BlockSize()
ret, out := alias.SliceForAppend(src, overhead)
out[overhead-1] = byte(overhead)
for i := 0; i < overhead-1; i++ {
out[i] = 0
}
clear(out[:overhead-1])
return ret
}

View File

@ -21,9 +21,7 @@ func (pad iso9797M2Padding) Pad(src []byte) []byte {
overhead := pad.BlockSize() - len(src)%pad.BlockSize()
ret, out := alias.SliceForAppend(src, overhead)
out[0] = 0x80
for i := 1; i < overhead; i++ {
out[i] = 0
}
clear(out[1:overhead])
return ret
}