#ident "$Id: image_superblock.h,v 1.3 2006/03/28 04:04:40 craig Exp $"
/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

#ifndef _IMAGE_SUPERBLOCK_H_
#define _IMAGE_SUPERBLOCK_H_

#include <stdint.h>
#include <stdbool.h>

/* A superblock consists of all DVD blocks that have the same H2 hash */
#define BLOCKS_FOR_H3                   3
#define DATA_PER_H0                     1024
#define H0_PER_H1                       31
#define H1_PER_H2                       8
#define H0_PER_SUPERBLOCK               (H0_PER_H1 * H1_PER_H2 * H2_PER_SUPERBLOCK)
#define H1_PER_SUPERBLOCK               (H1_PER_H2 * H2_PER_SUPERBLOCK)
#define H2_PER_SUPERBLOCK               8
#define SUBBLOCK_SIZE                   1024
#define DVD_BLOCK_SIZE                  (32 * 1024)
#define DVD_DATA_BYTES_PER_BLOCK        (31 * 1024)
#define BLOCKS_PER_SUPERBLOCK           64
#define DVD_DATA_BYTES_PER_SUPERBLOCK        (DVD_DATA_BYTES_PER_BLOCK * BLOCKS_PER_SUPERBLOCK)
#define H0_PAD_BYTES                    20
#define H1_PAD_BYTES                    32
#define H2_PAD_BYTES                    8

/*
 * Offset to the last 16 bytes of the H2 hash in the hash subblock
 * H0 size (w/pad) + H1 size (w/pad) + H2 size (no pad) - the 16
 */
#define DVD_DATA_IV_OFFSET (640 + 192 + 160 - 16)

/* Functions exported */
bool computeSuperBlock(FILE *inFile, FILE *outFile, uint8_t* h3Ptr,
                       const uint8_t* const titleKey, const bool encrypt,
                       const bool hash);
#endif
