/**
 * \file aes_alt.h
 *
 * \brief   This file contains alternate AES definitions and functions.
 *
 *          The Advanced Encryption Standard (AES) specifies a FIPS-approved
 *          cryptographic algorithm that can be used to protect electronic
 *          data.
 *
 *          The AES algorithm is a symmetric block cipher that can
 *          encrypt and decrypt information. For more information, see
 *          <em>FIPS Publication 197: Advanced Encryption Standard</em> and
 *          <em>ISO/IEC 18033-2:2006: Information technology -- Security
 *          techniques -- Encryption algorithms -- Part 2: Asymmetric
 *          ciphers</em>.
 *
 *          The AES-XTS block mode is standardized by NIST SP 800-38E
 *          <https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38e.pdf>
 *          and described in detail by IEEE P1619
 *          <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>.
 */

/*  Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 *  Copyright 2018 NXP. Not a Contribution
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may
 *  not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  This file is part of Mbed TLS (https://tls.mbed.org)
 */
#ifndef MBEDTLS_AES_ALT_H
#define MBEDTLS_AES_ALT_H


#ifdef __cplusplus
extern "C" {
#endif

#if defined(MBEDTLS_AES_ALT)

#if defined(MBEDTLS_FREESCALE_HASHCRYPT_AES)
/**
 * \brief          AES context structure
 */
#define mbedtls_aes_context hashcrypt_handle_t

#else
// Regular implementation
//

/**
 * \brief The AES context-type definition.
 */
typedef struct
{
    int nr;                     /*!< The number of rounds. */
    uint32_t *rk;               /*!< AES round keys. */
    uint32_t buf[68];           /*!< Unaligned data buffer. This buffer can
                                     hold 32 extra Bytes, which can be used for
                                     one of the following purposes:
                                     <ul><li>Alignment if VIA padlock is
                                             used.</li>
                                     <li>Simplifying key expansion in the 256-bit
                                         case by generating an extra round key.
                                         </li></ul> */
}
mbedtls_aes_context;
#endif /* MBEDTLS_FREESCALE_HASHCRYPT_AES */

/* AES SW prototypes for AES192 and AES256 while using DCP HW accelerator */
#if defined(MBEDTLS_AES_SETKEY_ENC_ALT) && (defined(MBEDTLS_AES192_ALT_SW) || defined(MBEDTLS_AES256_ALT_SW))
int mbedtls_aes_setkey_enc_sw( mbedtls_aes_context *ctx, const unsigned char *key,
                    unsigned int keybits );
int mbedtls_aes_setkey_dec_sw( mbedtls_aes_context *ctx, const unsigned char *key,
                    unsigned int keybits );
int mbedtls_internal_aes_encrypt_sw( mbedtls_aes_context *ctx,
                                  const unsigned char input[16],
                                  unsigned char output[16] );
int mbedtls_internal_aes_decrypt_sw( mbedtls_aes_context *ctx,
                                  const unsigned char input[16],
                                  unsigned char output[16] );
#endif /* MBEDTLS_AES_SETKEY_ENC_ALT && (MBEDTLS_AES192_ALT_SW || MBEDTLS_AES256_ALT_SW) */
#if defined(MBEDTLS_AES_CRYPT_CBC_ALT) && defined(MBEDTLS_AES_CBC_ALT_SW)
int mbedtls_aes_crypt_cbc_sw( mbedtls_aes_context *ctx,
                    int mode,
                    size_t length,
                    unsigned char iv[16],
                    const unsigned char *input,
                    unsigned char *output );
#endif /* MBEDTLS_AES_CRYPT_CBC_ALT && MBEDTLS_AES_CBC_ALT_SW */  

#endif /* MBEDTLS_AES_ALT */

#ifdef __cplusplus
}
#endif

#endif /* aes_alt.h */
