/*---------------------------------------------------------------------------*
  Project:  NitroSDK - DGT - include
  File:     common.h

  Copyright 2003,2004 Nintendo.  All rights reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., 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 Nintendo.

  $Log: common.h,v $
  Revision 1.3  2004/11/05 13:27:04  yasu
  Support OverlayTable mode

  Revision 1.2  2004/09/06 05:35:17  yasu
  Add some defines

  Revision 1.1  2004/09/02 12:40:32  yasu
  Digest library

  $NoKeywords: $
 *---------------------------------------------------------------------------*/

#ifndef NITRO_DGT_COMMON_H_
#define NITRO_DGT_COMMON_H_

#ifdef __cplusplus
extern "C" {
#endif

// Digest length
#define	DGT_HASH1_DIGEST_SIZE	(128/8)
#define	DGT_HASH2_DIGEST_SIZE	(160/8)

// Maximum digest length
#define DGT_HASH_DIGEST_SIZE_MAX  DGT_HASH2_DIGEST_SIZE

// Process block length
#define	DGT_HASH_BLOCK_SIZE	(512/8)

// Calculate HMAC
void	DGT_Hash1CalcHmac(
                    void*   digest,     //  Digest output region
		    void*   bin_ptr,    //  Pointer to data
		    int     bin_len,    //  Data length
		    void*   key_ptr,    //  Pointer to key
		    int     key_len     //  Key length
		    );

void	DGT_Hash2CalcHmac(
                    void*   digest,     //  Digest output region
		    void*   bin_ptr,    //  Pointer to data
		    int     bin_len,    //  Data length
		    void*   key_ptr,    //  Pointer to key
		    int     key_len     //  Key length
		    );

//  Create the HMAC value from these three regions: RomHeader,main & sub
int     DGT_Hash1CalcHmacForRms(
                    void*   digest,     //  Create digest region
                    void*   romh_ptr,   //  Pointer to data
                    int     romh_len,   //  Data length
                    void*   mbin_ptr,   //  Pointer to data
                    int     mbin_len,   //  Data length
                    void*   sbin_ptr,   //  Pointer to data
                    int     sbin_len,   //  Data length
                    void*   key_ptr,    //  Pointer to key
                    int     key_len     //  Key length
                    );

int     DGT_Hash2CalcHmacForRms(
                    void*   digest,     //  Create digest region
                    void*   romh_ptr,   //  Pointer to data
                    int     romh_len,   //  Data length
                    void*   mbin_ptr,   //  Pointer to data
                    int     mbin_len,   //  Data length
                    void*   sbin_ptr,   //  Pointer to data
                    int     sbin_len,   //  Data length
                    void*   key_ptr,    //  Pointer to key
                    int     key_len     //  Key length
                    );

//  Check the HMAC value from these three regions: RomHeader,main & sub
int     DGT_Hash1TestHmacForRms(
                    void*   digest,     //  Confirm digest region
                    void*   romh_ptr,   //  Pointer to data
                    int     romh_len,   //  Data length
                    void*   mbin_ptr,   //  Pointer to data
                    int     mbin_len,   //  Data length
                    void*   sbin_ptr,   //  Pointer to data
                    int     sbin_len,   //  Data length
                    void*   key_ptr,    //  Pointer to key
                    int     key_len     //  Key length
                    );

int     DGT_Hash2TestHmacForRms(
                    void*   digest,     //  Confirm digest region
                    void*   romh_ptr,   //  Pointer to data
                    int     romh_len,   //  Data length
                    void*   mbin_ptr,   //  Pointer to data
                    int     mbin_len,   //  Data length
                    void*   sbin_ptr,   //  Pointer to data
                    int     sbin_len,   //  Data length
                    void*   key_ptr,    //  Pointer to key
                    int     key_len     //  Key length
                    );

int     DGT_SetOverlayTableMode( int flag );

#ifdef __cplusplus
}
#endif
#endif
