/* AES key schedule (same for encryption or decryption, as hardware handles schedule)  */
int esp_aes_setkey(esp_aes_context *ctx, const unsigned char *key, unsigned int keybits)
/* AES key schedule (same for encryption or decryption, as hardware handles schedule)  */
int esp_aes_setkey(esp_aes_context *ctx, const unsigned char *key, unsigned int keybits)
{
    if (keybits != 128 && keybits != 192 && keybits != 256) {
        return MBEDTLS_ERR_AES_INVALID_KEY_LENGTH;
    }
    ctx->key_bytes = keybits / 8;
    memcpy(ctx->key, key, ctx->key_bytes);
    return 0;
}