Collection of steganography embedding routines for JPEG images.
Module: | pysteg.jsteg |
---|---|
Date: | $Date: 2010-07-16 10:43:38 +0100 (Fri, 16 Jul 2010) $ |
Revision: | $Revision: 1559 $ |
Copyright: | © 2010: University of Surrey, UK © 2011: Høgskolen i Ålesund, Norway |
Author: | Hans Georg Schaathun <georg@schaathun.net> (2010-2011) |
The abstract stegbase class defines a standard interface for stego-systems. All the other classes provide this interface.
Bases: pysteg.jsteg.stegbase.stegbase
The F1 object handles a list of JPEG AC coefficients and embeds and extracts messages using Jsteg.
Check that the next coefficient can be used for Jsteg. Move pointer if necessary.
Estimate the embedding capacity.
Flip the message bit in the next position. (Does not proceed to the subsequent bit.)
Bases: pysteg.jsteg.f4.f4coef
This object handles a list of JPEG AC coefficients and embeds and extracts messages using F3.
Decode a coefficient y F3 style. Returns None when y=0.
Bases: pysteg.jsteg.stegbase.stegbase
The F4 object handles a list of JPEG AC coefficients and embeds and extracts messages using F4.
Check that the next coefficient can be used. Move pointer if necessary.
Estimate the embedding capacity.
Print and return quantitative measures of the embedding performance.
Embed a message using F4 without any status word or length indicator. (Auxiliary function.)
Print a report on F5 capacity.
Embed a single F5 block (representing k message bits) at the current position.
Extract and decode a single block using F5.
Embed a complete message including status block, using F5 block. If k=None, an optimal code is chosen based on estimated capacity.
Flip bit no in the current block ignoring all zeros. The next coefficient counter is rewound to the start of the block.
Flip the message bit in the next position. (Does not proceed to the subsequent bit.)
Extract a single bit using F4.
Decode a coefficient x F4 style. Returns None when x=0.
Embed a message in the coefficients.
Extract a message from the coefficients.
Bases: pysteg.jsteg.f5.f5v2
Bases: pysteg.jsteg.f4.f4coef
The F5 object handles a list of JPEG AC coefficients and embeds and extracts messages using F5.
Bases: pysteg.jsteg.f5.f5coef
The F5 object handles a list of JPEG AC coefficients and embeds and extracts messages using F5. This extends the basic F5 class to skip every other pm1. The F5 object also gives full access to F4 methods.
Check that the next coefficient can be used. Move pointer if necessary. This method should always be called when the next pointer has been updated, or a coefficient has been changed.
Embed a random message of length msglength in image im using algorithm alg. im should be a JPEG object. Note, to embed in random locations, the im object must be prepared for this. The jembed.py script does this correctly.
Bases: list
A message class for communications systems. It allows getting a bit at a time from a sequence of bytes. Not perfect; it should be extended to work on sequences of other objects, such as int32 or Unicode characters.
Drop the last byte if zero. It is an error to call this method if the last byte is non-zero. It is used by the extractor when the last byte only contains padding zeros used to fill up the last block.
Return the next bit of the messaage. None is returned if there are no remaining bits.
Return the next /count/ bits of the messaage. None is returned if there are no remaining bits.
Compare the message to another message object or arbitrary list.
Insert new bits in the message. Used at the receiver end.
The F5 Algorithm
Module: | pysteg.jsteg.f5 |
---|---|
Date: | $Date: 2010-07-16 10:43:38 +0100 (Fri, 16 Jul 2010) $ |
Revision: | $Revision: 1559 $ |
Copyright: | © 2009-10: University of Surrey, UK |
Author: | Hans Georg Schaathun <georg@schaathun.net> (2009-2010) |
This module supports steganographic embedding in JPEG using Andreas Westfeld’s F5 algorithm. Two versions are provided. The f5coef class follows Westfeld’s paper and used every non-zero coefficient. The f5v2 class follows Westfeld’s implementation, skiping every other pm1 coefficient.
Bases: pysteg.jsteg.f5.f5v2
Bases: pysteg.jsteg.f4.f4coef
The F5 object handles a list of JPEG AC coefficients and embeds and extracts messages using F5.
Bases: pysteg.jsteg.f5.f5coef
The F5 object handles a list of JPEG AC coefficients and embeds and extracts messages using F5. This extends the basic F5 class to skip every other pm1. The F5 object also gives full access to F4 methods.
Bases: pysteg.jsteg.stegbase.stegbase
The F4 object handles a list of JPEG AC coefficients and embeds and extracts messages using F4.
Embed a message using F4 without any status word or length indicator. (Auxiliary function.)
Embed a single F5 block (representing k message bits) at the current position.
Embed a complete message including status block, using F5 block. If k=None, an optimal code is chosen based on estimated capacity.
Flip bit no in the current block ignoring all zeros. The next coefficient counter is rewound to the start of the block.
Decode a block using an [n,k] Hamming code as the matrix code. (k is actually ignored in the present version.)
Calculate code parameters for the matrix code. Returns a pair (n,k).
F3 should be a simple inheritance from F4, overriding only the interpret function.
Bases: pysteg.jsteg.f4.f4coef
This object handles a list of JPEG AC coefficients and embeds and extracts messages using F3.
The JSTEG stego-system.
Bases: pysteg.jsteg.stegbase.stegbase
The F1 object handles a list of JPEG AC coefficients and embeds and extracts messages using Jsteg.
Check that the next coefficient can be used for Jsteg. Move pointer if necessary.
Decode a coefficient x Jsteg style. Returns None when x=0,1.
Definition of exceptions used in the JPEG based steganography classes.
Bases: exceptions.RuntimeError
CapacityError indicates a programming error, where the application tries to access beyond the end of the sequence, without having checked for a CapacityException.
Bases: exceptions.LookupError
A CapacityException occurs when the file does not have sufficient capacity. This should be considered documented behaviour and should be dealt with.
Bases: exceptions.LookupError
UnusedCoefficientError occurs when the application attempts to flip a bit which should not be used.
Bases: list
A message class for communications systems. It allows getting a bit at a time from a sequence of bytes. Not perfect; it should be extended to work on sequences of other objects, such as int32 or Unicode characters.
Drop the last byte if zero. It is an error to call this method if the last byte is non-zero. It is used by the extractor when the last byte only contains padding zeros used to fill up the last block.
Return the next bit of the messaage. None is returned if there are no remaining bits.
Common interface for JPEG steganography classes.
Module: | pysteg.jsteg.stegbase |
---|---|
Date: | $Date$ |
Revision: | $Revision$ |
Copyright: | © 2010: University of Surrey, UK |
Author: | Hans Georg Schaathun <georg@schaathun.net> (2010) |
The stegbase class is a generic interface for Stego Objects, i.e. multimedia signals with the necessary methods to embed and extract steganographic messages.
Necessary exceptions are defined in the exceptions module. We will also need a Random Number Generator. SystemRandom provides one based on physical events, i.e. potential true randomness.
Bases: list
This is an abstract class, defining key components of the interface of the other JPEG steganography classes.
Check that the next coefficient can be used, and move the pointer if necessary. This must be overridden by any child class.
Embed N bits. It uses the embedbit() method and rarely requires overriding.
Embed a single bit in the next applicable position. This rarely requires overriding. It uses the interpret() and flipnext() methods, which should be overridden to define the modulation.
Flip the message bit in the next position. (Does not proceed to the subsequent bit.) This must be overridden by any child class.
Extract a single bit.
This uses the interpret() method, and will rarely need overriding. Instead the interpret() method is overridden.
Extract N bits.
This uses the getbit() method, and rarely needs overriding.