libpqstego - Perturbed quantization steganography library
Copyright (C) 2008 Christian Kuka

=========================================================

INTRODUCTION
Libpqstego is a C implementation of J. Fridrich, M. Goljan 
and D. Soukal algorithm for embedding secret messages in 
JPEG images using wet paper codes and perturbed 
quantization as described in:
* Jessica J. Fridrich, Miroslav Goljan, David Soukal: 
  Efficient Wet Paper Codes. Information Hiding 2005 
* Jessica J. Fridrich, Miroslav Goljan, Petr Lisonek, 
  David Soukal: Writing on wet paper. Security, 
  Steganography, and Watermarking of Multimedia Contents 
  2005
* Jessica J. Fridrich, Miroslav Goljan, David Soukal: 
  Perturbed quantization steganography. Multimedia Syst. 
  11
* Jessica J. Fridrich, Miroslav Goljan, David Soukal: 
  Perturbed quantization steganography with wet paper 
  codes. MM&Sec 2004

=========================================================
STRUCTURES

PQ_PARAMETER_T:
This structure holds all information that are nessary for
the algorithm

typedef struct {

        /* The password */ 
        uint8_t* password;

        /* The length of password (in bytes) */
        uint32_t pwlen;

        /* The quality of the resulting steganogram.  
           If this is 0 the algorithm will use the quality 
           with the highest capacity */  
        uint32_t quality;

        /* The number of DCT-coefficients divided by 8 for 
           embedding the message length. This information 
           must be known by a possible receiver.
           Default is 64 */
        uint32_t header_size;

} pq_parameter_t;

PQ_DATA_T:
This structure holds the information about the cover (JPEG)

typedef struct {

        /* Number of components (1 = gray scale, 3 = color) */
        uint8_t components;

        /* Components tables */
        pq_component_t *component;

        /* Width of the image in blocks (X-axis). */
        uint32_t size_x;

        /* Height of the image in blocks (Y-axis). */
        uint32_t size_y;

} pq_data_t

typedef struct {

        /* Pointer to the quantization table of this 
           component */
        pq_quant_t *quant;

        /* Pointer to the DCT-blocks */
        pq_block_t *block;

        /* Number of DCT-blocks of this component */
        uint32_t blocks;

} pq_component_t;

typedef struct {

        /* Array of the 64 DCT-coefficients of a block */
        int16_t values[64];

} pq_block_t

typedef struct {

        /* Array of the 64 values of a quantization table */
        uint16_t values[64];

} pq_quant_t;

=========================================================
FUNCTIONS

/**
 * Embeds a message in a JPEG-image
 * ... 
 * @param *src_data a struct for JPEG-data to provide the original image
 * @param *stego_data a struct for JPEG-data to return the steganogram
 * @param *message pointer to the message
 * @param msglen the length of the message
 * @param *param additional parameters, including passphrase
 * @return an errorcode or 0 if success
 */
uint32_t 
pq_embed(
    const pq_data_t *src_data, 
    pq_data_t *stego_data, 
    uint8_t *message, 
    uint32_t msglen, 
    const pq_parameter_t *param
);

/**
 * Extracts an embedded message from a stegonogram
 * ...
 * @param *stego_data a struct for JPEG-data containing the stegonagram
 * @param **message return pointer for the extracted message
 * @param msglen the length of the message
 * @param *param additional parameters, including password
 * @return an errorcode or 0 if success
 */
uint32_t 
pq_extract(
    const pq_data_t *stego_data, 
    uint8_t **message, 
    uint32_t *msglen, 
    const pq_parameter_t *param
);

/**
 * Returns the length of an embedded message from a stegonogram
 * ...
 * @param *stego_data a struct for JPEG-data containing the stegonagram
 * @param *param additional parameters, including password
 * @return the length of the embedded message
 */
int32_t 
pq_get_message_length(
    const pq_data_t *stego_data, 
    const pq_parameter_t *param
);

/**
 * Returns the capacity of a cover image
 * 
 * @param *src_data a struct for JPEG-data to provide the original image
 * @param *param additional parameters, including password
 * @param *capacity Pointer for the capacity
 * @return an errorcode or 0 if success
 */
int32_t 
pq_check_capacity(
    const pq_data_t *src_data, 
    const pq_parameter_t *param, 
    uint32_t *capacity
);

/**
 * Returns the string for an errorcode
 * 
 * @param *errno errcode
 * @return errorcode explanation
 */
const uint8_t 
*pq_strerror(
    const enum PQ_ERROR_CODE errno
);

=========================================================
ERROR-CODES

300 PQ_E_INSUFFHEADERCAP
Insufficient header capacity.
The algorithm couldn't find enough changeable 
DCT-coefficients to embed the message length

301 PQ_E_INSUFFBODYCAP
Insufficient body capacity.
The algorithm couldn't find enough changeable 
DCT-coefficients to embed the message

302 PQ_E_MSGTOOLONG 
Message too long.
The message is too long for the cover

303 PQ_E_MALLOC
Memory allocation failed.
A malloc call failed

304 PQ_E_LTPROCESS  
LT-Process failed
The algorithm couldn't solve the equation for embedding 
the message. 
Try to change the password or change cover

305 PQ_E_GAUSS
Gauss elimination failed
The algorithm couldn't solve the equation for embedding 
the message length.
Try to change the password or the cover. If it still not 
work use a higher header_size but don't forget that the 
receiver has to know the header_size

=========================================================
WARNING
The possibility that steganography can be detected depends 
heavily on the cover and the used capacity.
Never use computer graphics or the full capacity!!
 
=========================================================
COPYRIGHT

    Please read the `COPYRIGHT' file for copyright and 
    warranty information.

    Send comments, bug reports, suggestions, etc. to:

      Christian Kuka <ckuka@madkooky.de>
