#ifndef __TAL_OPERATION_H__
#define __TAL_OPERATION_H__

#include "basedef.h"

#if defined USE_QSEE
#include "qseedep_util.h"
#include "qseedep_crypto.h"
#elif defined USE_MOBICORE
#include "mobidep_util.h"
#include "mobidep_crypto.h"
#elif defined USE_TEEGRIS
#include "teegdep_util.h"
#include "teegdep_crypto.h"
#else
#error "not prepared"
#endif

typedef struct {
    uint8* (*malloc)(uint32 size);
    void (*free)(uint8* input, uint32 size);
    boolean (*rsa_verify)(const TAL_Key* pTalPubKey, const BlobData* pBlobPlainData, const BlobData* pBlobSignature);
    boolean (*rsa_decryption)(const BlobData* pBlobEncryptedData, const TAL_Key* pTalKey, BlobData* pBlobPlainData);
    boolean (*aes_decryption)(const BlobData* pBlobEncryptedData, const TAL_Key* pAesKey, BlobData* pBlobPlainData);
    boolean (*hmac)(const BlobData* pBlobPlain, const BlobData* pBlobKey, const HashType hashType, BlobData* pBlobDigest);
    boolean (*hash)(const BlobData* pBlobPlainData, const HashType hashType, BlobData* pBlobDigest);
    boolean (*getRandomNumber)(const uint32 size, uint8* pOutputBuf);
    boolean (*decapsulateSkpm)(const BlobData* pBlobWrappedData, BlobData* pBlobUnwrappedData);
    boolean (*wrap)(const BlobData* pBlobPlainData, BlobData* pBlobWrappedData);
    boolean (*unwrap)(const BlobData* pBlobWrappedData, BlobData* pBlobUnwrappedData);
} TalOperation;

static TalOperation gTal = {
#if defined (USE_QSEE)
        .malloc = qseedep_malloc,
        .free = qseedep_free,
        .rsa_verify = qseedep_rsa_verify,
        .rsa_decryption = qseedep_rsa_decryption,
        .aes_decryption = qseedep_aes_decryption,
        .hmac = qseedep_hmac,
        .hash = qseedep_hash,
        .getRandomNumber = qseedep_getRandomNumber,
        .decapsulateSkpm = qseedep_decapsulateSkpm,
        .wrap = qseedep_wrap,
        .unwrap = qseedep_unwrap,
#elif defined (USE_MOBICORE)
        .malloc = mobidep_malloc,
        .free = mobidep_free,
        .rsa_verify = mobidep_rsa_verify,
        .rsa_decryption = mobidep_rsa_decryption,
        .aes_decryption = mobidep_aes_decryption,
        .hmac = mobidep_hmac,
        .hash = mobidep_hash,
        .getRandomNumber = mobidep_getRandomNumber,
        .decapsulateSkpm = mobidep_decapsulateSkpm,
        .wrap = mobidep_wrap,
        .unwrap = mobidep_unwrap,
#elif defined (USE_TEEGRIS)
        .malloc = teegdep_malloc,
        .free = teegdep_free,
        .rsa_verify = teegdep_rsa_verify,
        .rsa_decryption = teegdep_rsa_decryption,
        .aes_decryption = teegdep_aes_decryption,
        .hmac = teegdep_hmac,
        .hash = teegdep_hash,
        .getRandomNumber = teegdep_getRandomNumber,
        .decapsulateSkpm = teegdep_decapsulateSkpm,
        .wrap = teegdep_wrap,
        .unwrap = teegdep_unwrap,
#endif
    };

#endif  //end of __TAL_OPERATION_H__
