#ifndef __CMD_CRYPTO_H__
#define __CMD_CRYPTO_H__

#include "basedef.h"

typedef enum {
    SIGNATURE_TYPE_NONE = 0,
    SIGNATURE_TYPE_RSA_SHA256_PSS,
    SIGNATURE_TYPE_RSA_SHA256_PKCS1,
    SIGNATURE_TYPE_RSA_SHA384_PKCS1,
    CIPHER_TYPE_NONE = 100,
    CIPHER_TYPE_RSA_SHA256_OAEP,
    CIPHER_TYPE_AES_CBC_PKCS5,
} CryptoType;

typedef enum {
    HASH_TYPE_NONE,
    HASH_TYPE_SHA256,
    HASH_TYPE_SHA384
} HashType;

typedef struct {
  uint8* value;    //value. little endian
  uint32 length;    //length
} TAL_LongInt;

// RSA privKey exponent
static const uint8 g_rsaExponent[] = {0x01, 0x00, 0x01};

typedef struct {
    TAL_LongInt exponent;           /**< Pointer to public exponent . */
    TAL_LongInt modulus;            /**< Modulus (if public key present) . */
    TAL_LongInt privateExponent;    /**< Private exponent (if private key present) . */
} TAL_RsaKey;

typedef struct {
    TAL_LongInt key;
    TAL_LongInt iv;
} TAL_AesKey;

typedef struct {
    CryptoType cryptoType;
    union {
        TAL_RsaKey rsa;
        TAL_AesKey aes;
    } key;
} TAL_Key;

boolean allocKey(const uint32 size, TAL_Key* pTalKey);
void freeKey(TAL_Key* pTalKey);
AuthnrResult processDecryption(const BlobData* pBlobInput, BlobData* pBlobOutput);


#endif  //end of __CMD_CRYPTO_H__
