Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/symcrypt/lib/aes-default-bc.c
15010 views
1
//
2
// aes-default-bc.c code for AES implementation
3
//
4
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5
//
6
7
#include "precomp.h"
8
9
//
10
// The SymCrypt API allows callers to use the generic block cipher mode functions and pass
11
// a pointer to a structure that describes the block cipher.
12
// This structure contains pointers to all the optimized implementations of the various modes.
13
// This pulls in all the mode-specific code, which in some cases we don't want.
14
//
15
// We isolate the SymCryptAesBlockCipher structure into this separate C file so that it only gets
16
// pulled in when the application uses this structure.
17
//
18
19
//
20
// The virtual table for the AES block cipher.
21
//
22
// All pointers must point to specialized functions. The general
23
// block cipher mode functions will call these pointers if they are non-NULL
24
// so if they point back to an implementation that calls the generic
25
// mode functions we get an infinite recursion.
26
//
27
// NOTE: the compile-time conditions in this file should track the actual implementations in
28
// aes-default.c.
29
//
30
31
const SYMCRYPT_BLOCKCIPHER SymCryptAesBlockCipher_Fast = {
32
&SymCryptAesExpandKey,
33
&SymCryptAesEncrypt,
34
&SymCryptAesDecrypt,
35
36
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
37
&SymCryptAesEcbEncrypt,
38
#else
39
NULL,
40
#endif
41
42
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64
43
&SymCryptAesEcbDecrypt,
44
#else
45
NULL,
46
#endif
47
48
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
49
&SymCryptAesCbcEncrypt,
50
#else
51
NULL,
52
#endif
53
54
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
55
&SymCryptAesCbcDecrypt,
56
#else
57
NULL,
58
#endif
59
60
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM64
61
&SymCryptAesCbcMac,
62
#else
63
NULL,
64
#endif
65
66
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
67
&SymCryptAesCtrMsb64,
68
#else
69
NULL,
70
#endif
71
72
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
73
&SymCryptAesGcmEncryptPart,
74
#else
75
NULL,
76
#endif
77
78
#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
79
&SymCryptAesGcmDecryptPart,
80
#else
81
NULL,
82
#endif
83
84
SYMCRYPT_AES_BLOCK_SIZE,
85
sizeof( SYMCRYPT_AES_EXPANDED_KEY ),
86
};
87
88
//
89
// This indirection makes it easier to switch implementations in a binary without
90
// changing the calling code.
91
//
92
const PCSYMCRYPT_BLOCKCIPHER SymCryptAesBlockCipher = &SymCryptAesBlockCipher_Fast;
93
94