/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 *
 * $Author$
 * $Date$
 * $RCSfile: dmx_ide.h,v $
 * $Revision$
 *
 *---------------------------------------------------------------------------*/

/** @file dmx_drm.h
 *  Header of PD-DRM interfaces
 */


#ifndef _DMX_DRM_H_
#define _DMX_DRM_H_

//-----------------------------------------------------------------------------
// Include files
//-----------------------------------------------------------------------------
#include "x_typedef.h"
//#include "dmx_if.h"
//#include "dmx_mm_if.h"
//#include "dmx_drm_if.h"
#include "x_os.h"

//-----------------------------------------------------------------------------
//
// SHA
//
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Configurations
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Constant definitions
//-----------------------------------------------------------------------------

#define SHA1_HASH_SIZE      (20)
#define SHA224_HASH_SIZE    (28)
#define SHA256_HASH_SIZE    (32)
#define SHA_BLOCK_SIZE      (64)    //512-bit

//-----------------------------------------------------------------------------
// Type definitions
//-----------------------------------------------------------------------------
#ifndef _SHA_enum_
#define _SHA_enum_
enum
{
    shaSuccess = 0,
    shaNull,            /* Null pointer parameter */
    shaInputTooLong,    /* input data too long */
    shaStateError       /* called Input after Result */
};
#endif


// This structure will hold context information for the SHA-1
// hashing operation
typedef struct
{
    UINT32 Intermediate_Hash[SHA1_HASH_SIZE/4]; /* Message Digest  */

    UINT32 Length_Low;                          /* Message length in bits      */
    UINT32 Length_High;                         /* Message length in bits      */

                                                /* Index into message block array   */
    INT32 Message_Block_Index;
    UINT8 Message_Block[64];                    /* 512-bit message blocks      */

    INT32 Computed;                             /* Is the digest computed?         */
    INT32 Corrupted;                            /* Is the message digest corrupted? */
} SHA1_CONTEXT_T;

// This structure will hold context information for the SHA-256
// hashing operation
typedef struct
{
    UINT32 Intermediate_Hash[SHA256_HASH_SIZE/4];   /* Message Digest  */

    UINT32 Length_Low;                              /* Message length in bits      */
    UINT32 Length_High;                             /* Message length in bits      */

                                                    /* Index into message block array   */
    INT32 Message_Block_Index;
    UINT8 Message_Block[64];                        /* 512-bit message blocks      */

    INT32 Computed;                                 /* Is the digest computed?         */
    INT32 Corrupted;                                /* Is the message digest corrupted? */
} SHA256_CONTEXT_T;

//-----------------------------------------------------------------------------
// Macro definitions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Prototype  of inter-file functions
//-----------------------------------------------------------------------------

EXTERN INT32 SHA1_Reset(SHA1_CONTEXT_T *);
EXTERN INT32 SHA1_Input(SHA1_CONTEXT_T *, const UINT8 *, UINT32);
EXTERN INT32 SHA1_Result(SHA1_CONTEXT_T *, UINT8 Message_Digest[SHA1_HASH_SIZE]);

// SHA-224 has the same struct of SHA-256,
// the main different is initial constant and result size is 224 bit
EXTERN INT32 SHA224_Reset(SHA256_CONTEXT_T *);
EXTERN INT32 SHA224_Input(SHA256_CONTEXT_T *, const UINT8 *, UINT32);
EXTERN INT32 SHA224_Result(SHA256_CONTEXT_T *, UINT8 Message_Digest[SHA224_HASH_SIZE]);

EXTERN INT32 SHA256_Reset(SHA256_CONTEXT_T *);
EXTERN INT32 SHA256_Input(SHA256_CONTEXT_T *, const UINT8 *, UINT32);
EXTERN INT32 SHA256_Result(SHA256_CONTEXT_T *, UINT8 Message_Digest[SHA256_HASH_SIZE]);
EXTERN INT32 SHA256(const UINT8 *message_array, UINT32 length, UINT8 Message_Digest[SHA256_HASH_SIZE]);
EXTERN INT32 mtk_hmac_sha256(UINT8 * key, UINT32 key_size, UINT8 * msg, UINT32 msg_size,  UINT8 result[SHA256_HASH_SIZE]);
#ifdef TEST_MODE
EXTERN void Sha256_unit_test(void);
#endif

//-----------------------------------------------------------------------------
//
// MD
//
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Configurations
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Constant definitions
//-----------------------------------------------------------------------------

#define MD5_HASH_SIZE      (16)

//-----------------------------------------------------------------------------
// Type definitions
//-----------------------------------------------------------------------------

// This structure will hold context information for the MD5
// hashing operation
typedef struct {
  UINT32 au4State[4];                           /* state  */
  UINT32 au4Count[2];                           /* number of bits, modulo 2^64 (lsb first) */
  UINT8 au1Buffer[64];                          /* input buffer */
} MD5_CONTEXT_T;

//-----------------------------------------------------------------------------
// Macro definitions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Prototype  of inter-file functions
//-----------------------------------------------------------------------------
EXTERN void MD5_Reset(MD5_CONTEXT_T*);
EXTERN void MD5_Input(MD5_CONTEXT_T *, const UINT8 *, UINT32);
EXTERN void MD5_Result(MD5_CONTEXT_T *, UINT8 Message_Digest[MD5_HASH_SIZE]);

//-----------------------------------------------------------------------------
//
// RC4
//
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Configurations
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// Constant definitions
//-----------------------------------------------------------------------------

#define RC4_TABLESIZE 256

//-----------------------------------------------------------------------------
// Type definitions
//-----------------------------------------------------------------------------


/// RC4 key structure
typedef struct
{
	UINT8 S[(RC4_TABLESIZE)];       /* State table */
	UINT8 i, j;                     /* Indices */
} RC4_KEY_T;

//-----------------------------------------------------------------------------
// Macro definitions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Prototype  of inter-file functions
//-----------------------------------------------------------------------------

EXTERN void RC4_Init(RC4_KEY_T *prRC4Key, UINT32 u4KeyLen, const UINT8 *pu1Key);
EXTERN void RC4_Output(RC4_KEY_T *prRC4Key, UINT32 u4Size, UINT8 *pu1Buf);

//-----------------------------------------------------------------------------
//
// CBC-MAC
//
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Configurations
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Constant definitions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Type definitions
//-----------------------------------------------------------------------------

typedef struct
{
    UINT32 a1, b1, c1, d1, e1, f1, a2, b2, c2, d2, e2, f2;
} DRM_CBCKey;

typedef struct
{
    UINT32 sum,t;
    UINT8 buf[8];
    UINT32 dwBufLen;
} DRM_CBCState_T;

//-----------------------------------------------------------------------------
// Macro definitions
//-----------------------------------------------------------------------------
#ifndef __KERNEL__
#define min(x, y) ((x < y) ? x : y)
#endif

#define WORDSWAP(d) ( ( (d) >> 16 ) + ( (d) << 16 ) )

#define BYTES_TO_DWORD BYTE2LITTLEENDIAN
#define DWORD_TO_BYTES DWORD2LITTLEENDIAN

#define BYTE2LITTLEENDIAN(dword, byte)     DRM_BYT_CopyBytes((UINT8*)&(dword),0,(byte),0,sizeof(UINT32));
#define DWORD2LITTLEENDIAN(byte, dword)  DRM_BYT_CopyBytes((byte),0,(UINT8*)&(dword),0,sizeof(UINT32));

#define DRM_BYT_CopyBytes(to,tooffset,from,fromoffset,count) x_memcpy(&((to)[(tooffset)]),&((from)[(fromoffset)]),(count))

//-----------------------------------------------------------------------------
// Prototype  of inter-file functions
//-----------------------------------------------------------------------------

EXTERN UINT32 DRM_MAC_inv32(UINT32 n);
EXTERN void DRM_CBC_Mac(UINT8 *pbData, UINT32 cBlocks, UINT32 rgdwKeys[2], const DRM_CBCKey *pCBCkey);
EXTERN void DRM_CBC_InverseMac(UINT8 *pbData,UINT32 cBlocks, const DRM_CBCKey *key, const DRM_CBCKey *ikey);
EXTERN void DRM_CBC64InitState( DRM_CBCState_T *cbcstate );
EXTERN void DRM_CBC64Init( DRM_CBCKey *cbckey, DRM_CBCState_T *cbcstate, UINT8 *pKey );
EXTERN void DRM_CBC64InvKey( DRM_CBCKey *cbckey, DRM_CBCKey *cbcInvKey );
EXTERN void DRM_CBC64Update(DRM_CBCKey *key, DRM_CBCState_T *cbcstate, UINT32 cbData, UINT8 *pbData);
EXTERN UINT32 DRM_CBC64Finalize( DRM_CBCKey *key, DRM_CBCState_T *cbcstate, UINT32 *pKey2 );
EXTERN UINT32 DRM_CBC64Invert( DRM_CBCKey *key, DRM_CBCKey *ikey, UINT32 MacA1, UINT32 MacA2,
        UINT32 MacB1, UINT32 MacB2, UINT32 *pInvKey2);

//-----------------------------------------------------------------------------
//
// DES
//
//-----------------------------------------------------------------------------
#define DES_ENCRYPT     0
#define DES_DECRYPT     1

typedef UINT32 DES_KS[16][2];	/* Single-key DES key schedule */
typedef UINT32 DES3_KS[48][2];	/* Triple-DES key schedule */

/* In deskey.c: */
void deskey(DES_KS,unsigned char *,int);
void des3key(DES3_KS,unsigned char *,int);

/* In desport.c, desborl.cas or desgnu.s: */
void des(DES_KS,unsigned char *);
/* In des3port.c, des3borl.cas or des3gnu.s: */
void des3(DES3_KS,unsigned char *);

extern int Asmversion;	/* 1 if we're linked with an asm version, 0 if C */

void des_crypt_cfb( DES_KS ks,
                    int mode,
                    int length,
                    int *iv_off,
                    unsigned char iv[8],
                    unsigned char *input,
                    unsigned char *output );

void des_crypt_ofb( DES_KS ks,
                    int mode,
                    int length,
                    int *iv_off,
                    unsigned char iv[8],
                    unsigned char *input,
                    unsigned char *output );

void des3_crypt_cfb( DES3_KS ks,
                    int mode,
                    int length,
                    int *iv_off,
                    unsigned char iv[8],
                    unsigned char *input,
                    unsigned char *output );

void des3_crypt_ofb( DES3_KS ks,
                    int mode,
                    int length,
                    int *iv_off,
                    unsigned char iv[8],
                    unsigned char *input,
                    unsigned char *output );

//-----------------------------------------------------------------------------
//
// PD-DRM
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Constant definitions
//-----------------------------------------------------------------------------

#define PK_ENC_PLAINTEXT_LEN	16

//-----------------------------------------------------------------------------
// Type definitions
//-----------------------------------------------------------------------------

typedef struct
{
    UINT8 au1SHAOut[SHA1_HASH_SIZE];
    UINT32 au4DESS1[2];
    UINT32 au4DESS2[2];
    UINT32 u4DES_KS[16][2];
    DRM_CBCKey rMacKey;
    DRM_CBCKey rInvMacKey;
    RC4_KEY_T rRC4Key;
    BOOL fgInited;
    BOOL fgDecryptInited;
    DRM_CBCState_T rCBCState;
    UINT32 au4RC4Key[2];
    UINT32 au4Last8[2];
    UINT32 u4TotalLen;
    UINT32 u4OPedLen;
    UINT32 u4ContentKeyLen;
    UINT8 au1ContentKey[PK_ENC_PLAINTEXT_LEN];
} DRM_CONTEXT_T;

//-----------------------------------------------------------------------------
// Macro definitions
//-----------------------------------------------------------------------------

#ifndef NO_OF
    #define NO_OF( x )  ( sizeof( (x) ) / sizeof( (x)[0] ) )
#endif

//-----------------------------------------------------------------------------
//
// AES
//
//-----------------------------------------------------------------------------
#define AES_ENCRYPT     0
#define AES_DECRYPT     1

/**
 * \brief          AES context structure
 */
typedef struct
{
    INT32 nr;                     /*!<  number of rounds  */
    UINT32 *rk;          /*!<  AES round keys    */
    UINT32 buf[68];      /*!<  unaligned data    */
} aes_context;

/**
 * \brief          AES key schedule (encryption)
 *
 * \param ctx      AES context to be initialized
 * \param key      encryption key
 * \param keysize  must be 128, 192 or 256
 */
void aes_setkey_enc( aes_context *ctx, const UINT8 *key, INT32 keysize );

/**
 * \brief          AES key schedule (decryption)
 *
 * \param ctx      AES context to be initialized
 * \param key      decryption key
 * \param keysize  must be 128, 192 or 256
 */
void aes_setkey_dec( aes_context *ctx, const UINT8 *key, INT32 keysize );

/**
 * \brief          AES-ECB block encryption/decryption
 *
 * \param ctx      AES context
 * \param mode     AES_ENCRYPT or AES_DECRYPT
 * \param input    16-byte input block
 * \param output   16-byte output block
 */
void aes_crypt_ecb( aes_context *ctx,
                    INT32 mode,
                    UINT8 input[16],
                    UINT8 output[16] );

/**
 * \brief          AES-CBC buffer encryption/decryption
 *
 * \param ctx      AES context
 * \param mode     AES_ENCRYPT or AES_DECRYPT
 * \param length   length of the input data
 * \param iv       initialization vector (updated after use)
 * \param input    buffer holding the input data
 * \param output   buffer holding the output data
 */
void aes_crypt_cbc( aes_context *ctx,
                    INT32 mode,
                    INT32 length,
                    UINT8 iv[16],
                    UINT8 *input,
                    UINT8 *output );

void aes_crypt_cbc_scte52( aes_context *ctx,
                    INT32 mode,
                    INT32 length,
                    UINT8 iv[16],
                    UINT8 *input,
                    UINT8 *output );

/**
 * \brief          AES-CFB buffer encryption/decryption
 *
 * \param ctx      AES context
 * \param mode     AES_ENCRYPT or AES_DECRYPT
 * \param length   length of the input data
 * \param iv_off   offset in IV (updated after use)
 * \param iv       initialization vector (updated after use)
 * \param input    buffer holding the input data
 * \param output   buffer holding the output data
 */
void aes_crypt_cfb( aes_context *ctx,
                    INT32 mode,
                    INT32 length,
                    INT32 *iv_off,
                    UINT8 iv[16],
                    UINT8 *input,
                    UINT8 *output );

void aes_crypt_ofb( aes_context *ctx,
                    int mode,
                    int length,
                    int *iv_off,
                    unsigned char iv[16],
                    unsigned char *input,
                    unsigned char *output );

//-----------------------------------------------------------------------------
// Configurations
//-----------------------------------------------------------------------------
#define AES_MAX_ENGINE_INDEX    (32)
#define AES_NULL_ENGINE_INDEX   (0xff)

#define AES_RESERVED_ENGINE_NUM (3)     // 0: Legacy AES 1: MTD AES 2. WV AES
//-----------------------------------------------------------------------------
// Constant definitions
//-----------------------------------------------------------------------------
#define AES_LEGACY_INDEX        (0)
#define AES_MTD_INDEX           (1)
#define AES_WV_INDEX            (2)
#define AES_HDCP2_INDEX         (3)

#define AES_WV_SECURE_KEY_PTR       (88)
#define AES_HDCP2_SECURE_KEY_PTR    (84)
#define AES_PLAYREADY_KEY_PTR       (80)
#define AES_SVP_CTR_KEY_PTR         (76)
#define AES_PLAYREADY_AUD_KEY_PTR   (72)
#define AES_TZ_SECURE_KEY_PTR       (68)
#define AES_TZ_SECURE_IV_PTR        (64)
#define AES_MTD_SECURE_KEY_PTR      (60)

#define AES_BLOCK_LEN           (16)
//-----------------------------------------------------------------------------
/** _DMX_NAND_AES_INIT
 *  NAND AES Initialization
 *
 *  @param  pu1Key          key pointer
 *  @param  u2KeyLen        key length [128|192|256]
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------
EXTERN BOOL _DMX_NAND_AES_INIT(UINT8 *pu1Key, UINT16 u2KeyLen);

//-----------------------------------------------------------------------------
/** _DMX_NAND_AES_Encryption
 *  NAND AES encryption
 *
 *  @param  u4InBufStart    input buffer address
 *  @param  u4OutBufStart   output buffer address
 *  @param  u4BufSize       buffer size
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------
EXTERN BOOL _DMX_NAND_AES_Encryption(UPTR u4InBufStart, UPTR u4OutBufStart, USIZE u4BufSize);

//-----------------------------------------------------------------------------
/** _DMX_NAND_AES_Decryption
 *  NAND AES decryption
 *
 *  @param  u4InBufStart    input buffer address
 *  @param  u4OutBufStart   output buffer address
 *  @param  u4BufSize       buffer size
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------
EXTERN BOOL _DMX_NAND_AES_Decryption(UPTR u4InBufStart, UPTR u4OutBufStart, USIZE u4BufSize);


//-----------------------------------------------------------------------------
/** _DMX_SHA1_Onece
 *  NAND AES decryption
 *
 *  @param  u4BufStart    input buffer address
 *  @param  u4BufSize      buffer size ,no need 64 byte alignment
 *  @param  u1HashValue       hashvalue output buffer size;
 *  @param  u4HashValueSize       u4HashValueSize
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------

EXTERN BOOL _DMX_SHA1_Onece(UPTR *u4BufStart, USIZE u4BufSize, UINT8 *u1HashValue, UINT32 *u4HashValueSize);


//-----------------------------------------------------------------------------
/** _DMX_SHA1_Manytimes
 *  _DMX_SHA1_Manytimes
 *
 *  @param  fgFirstPacket    the flag of first packet
 *  @param  fgLastPacket    the flag of last packet
 *  @param  u4BufStart    input buffer address
 *  @param  u4BufSize      buffer size ,no need 64 byte alignment
 *  @param  u1HashValue       hashvalue output buffer size;
 *  @param  u4HashValueSize       u4HashValueSize
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------

EXTERN BOOL _DMX_SHA1_Manytimes(BOOL fgFirstPacket, BOOL fgLastPacket, UPTR *u4BufStart,
									USIZE u4BufSize, UINT8 *u1HashValue, UINT32 *u4HashValueSize);


//-----------------------------------------------------------------------------
/** _DMX_Encrypt_Snapshot
 *  NAND AES decryption
 *
 *  @param  u1HashValueIn         the encrypt hashvalue address
 *  @param  u4HashValueSize       HashValueSize
 *  @param  u1HashValueOut       the decrypt hashvalue output address
 *  @param  u1AeskeyAddr     Aes key size
 *  @param  u4AeskeySize   Hash value addre
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------

EXTERN BOOL _DMX_Encrypt_Snapshot(UINT8 *u1HashValueIn, UINT32 u4HashValueSize, UINT8 *u1HashValueOut,
									UINT8 *u1AeskeyAddr, UINT32 *u4AeskeySize);

//-----------------------------------------------------------------------------
/** _DMX_Decrypt_Snapshot
 *  NAND AES decryption
 *
 *  @param  u1HashValue_Encrypt    input Encrypt hashvalue address
 *  @param  u4HashValueSize          hashvalue  buffer size
 *  @param  u1HashValue_Clear       input clear hashvalue address
 *  @param  u1AeskeyAddr     Aes key address
 *  @param  u4AeskeySize      aes key size
 *
 *  @retval TRUE            Succeed
 *  @retval FALSE           Fail
 */
//-----------------------------------------------------------------------------

EXTERN BOOL _DMX_Decrypt_Snapshot(UINT8 *u1HashValue_Encrypt, UINT32 u4HashValueSize, UINT8 *u1HashValue_Clear,
									UINT8 *u1AeskeyAddr, UINT32 u4AeskeySize);


//-----------------------------------------------------------------------------
//
// SMS4
//
//-----------------------------------------------------------------------------
extern void SMS4Encrypt_ecb(unsigned long *psrc);
extern void SMS4Encrypt_cbc(unsigned long *psrc, unsigned long *piv);
extern void SMS4Encrypt_ofb(unsigned long *psrc, unsigned long *piv);
extern void SMS4Encrypt_cfb(unsigned long *psrc, unsigned long *piv);
extern void SMS4Encrypt_scte52(unsigned long *psrc, unsigned long *piv);
extern unsigned long *SMS4SetKey(unsigned long *ulkey, unsigned long flag);


#endif	// _DMX_DRM_H_

