The invention relates to pairing a slave device with a master device, for example decoders in a conditional access system. There is provided a security module that stores a device state that indicates whether a decoder shall be a master or a slave decoder. There is also provided a method in a conditional access system of providing a device with a device state stored on a security module. It is detected that the security module is in connection with the device and the device state is transferred from the security module to the device. There is further provided a method of pairing a slave device with a master device. The slave device asks the master device to identify itself, the master device returns an identification, and if the slave device has not yet been paired with a master device, it checks the identity of the master device and, if the identity is verified pairs with the master device. There is also provided a first, slave, device for pairing with a second, master, device. The first device comprises an interface for sending an identification command to and receiving an identification message from the master device, and a processor for checking the identity of the second device and pairing the first device with the second device.