#ifndef WB_DEC_H_
#define WB_DEC_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wb_common.h"


/*
 * This method decrypts a ciphertext of any size in CBC mode, outputs a plaintext (pt), and returns the size of the plaintext.
 *
 * @param pt an output plaintext to be decrypted
 * @param ct an input ciphertext
 * @param size the size of a ciphertext (ct) in bytes
 * @param iv initialization vector
 * @return the size of a plaintext (pt)
 */
long cbc_wb_decrypt (unsigned char *pt, unsigned char *ct, long size, unsigned char *iv);
long WB_Dec (unsigned char *pt, unsigned char *ct, long size, unsigned char *iv);

/*
 * This method decrypts a ciphertext of multiple of 16 bytes in CBC mode, outputs a plaintext (pt), and returns the size of the plaintext.
 *
 * @param pt an output plaintext to be decrypted
 * @param ct an input ciphertext
 * @param size the size of a ciphertext (ct) in bytes
 * @param iv initialization vector
 * @return the size of a plaintext (pt)
 */
long cbc_wb_decrypt_nopadding (unsigned char *pt, unsigned char *ct, long size, unsigned char *iv);
long WB_Dec_Nopadding (unsigned char *pt, unsigned char *ct, long size, unsigned char *iv);

/*
 * This method decrypts a ciphertext of any size in ECB mode, outputs a plaintext (pt), and returns the size of the plaintext.
 *
 * @param pt an output plaintext to be decrypted
 * @param ct an input ciphertext
 * @param size the size of a ciphertext (ct) in bytes
 * @return the size of a plaintext (pt)
 * @deprecated replaced by cbc_wb_decrypt()
 */
long ecb_wb_decrypt (unsigned char *pt, unsigned char *ct, long size);

/*
 * decrypt a ciphertext of a block of 16 bytes
 * pt: plaintext, ct: ciphertext
 */
void decBlock (unsigned char pt[16], const unsigned char ct[16]);

/*
 * unpadding scheme
 */
long unpadding (unsigned char *pt_buf);

#endif /* WB_DEC_H_ */
