using the Berlekamp-Massey algorithm