//1// aes-default-bc.c code for AES implementation2//3// Copyright (c) Microsoft Corporation. Licensed under the MIT license.4//56#include "precomp.h"78//9// The SymCrypt API allows callers to use the generic block cipher mode functions and pass10// a pointer to a structure that describes the block cipher.11// This structure contains pointers to all the optimized implementations of the various modes.12// This pulls in all the mode-specific code, which in some cases we don't want.13//14// We isolate the SymCryptAesBlockCipher structure into this separate C file so that it only gets15// pulled in when the application uses this structure.16//1718//19// The virtual table for the AES block cipher.20//21// All pointers must point to specialized functions. The general22// block cipher mode functions will call these pointers if they are non-NULL23// so if they point back to an implementation that calls the generic24// mode functions we get an infinite recursion.25//26// NOTE: the compile-time conditions in this file should track the actual implementations in27// aes-default.c.28//2930const SYMCRYPT_BLOCKCIPHER SymCryptAesBlockCipher_Fast = {31&SymCryptAesExpandKey,32&SymCryptAesEncrypt,33&SymCryptAesDecrypt,3435#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM6436&SymCryptAesEcbEncrypt,37#else38NULL,39#endif4041#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD6442&SymCryptAesEcbDecrypt,43#else44NULL,45#endif4647#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM6448&SymCryptAesCbcEncrypt,49#else50NULL,51#endif5253#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM6454&SymCryptAesCbcDecrypt,55#else56NULL,57#endif5859#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM6460&SymCryptAesCbcMac,61#else62NULL,63#endif6465#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM6466&SymCryptAesCtrMsb64,67#else68NULL,69#endif7071#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM6472&SymCryptAesGcmEncryptPart,73#else74NULL,75#endif7677#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM6478&SymCryptAesGcmDecryptPart,79#else80NULL,81#endif8283SYMCRYPT_AES_BLOCK_SIZE,84sizeof( SYMCRYPT_AES_EXPANDED_KEY ),85};8687//88// This indirection makes it easier to switch implementations in a binary without89// changing the calling code.90//91const PCSYMCRYPT_BLOCKCIPHER SymCryptAesBlockCipher = &SymCryptAesBlockCipher_Fast;929394