  In this paper we model a class of stream and block ciphers as systems of
(ordinary) explicit difference equations over a finite field. We call this
class "difference ciphers" and we show that ciphers of application interest, as
for example systems of LFSRs with a combiner, Trivium and Keeloq, belong to the
class. By using Difference Algebra, that is, the formal theory of difference
equations, we can properly define and study important properties of these
ciphers, such as their invertibility and periodicity. We describe then general
cryptanalytic methods for difference ciphers that follow from these properties
and are useful to assess the security. We illustrate such algebraic attacks in
practice by means of the ciphers Bivium and Keeloq.
