Match padding behaviour of official implementation