|
4 | 4 | // Copyright (c) Microsoft Corporation. Licensed under the MIT license. |
5 | 5 | // |
6 | 6 |
|
7 | | -#include <openssl/evp.h> |
8 | | -#include <openssl/rand.h> |
9 | | -#include <openssl/sha.h> |
10 | 7 | #include <symcrypt.h> |
11 | 8 | #include <stdint.h> |
12 | 9 | #include <vector> |
| 10 | + |
13 | 11 | class ImpOpenssl { |
14 | 12 | public: |
15 | 13 | static constexpr const char * name = "OpenSSL"; |
16 | 14 | }; |
17 | 15 |
|
18 | | -template<> |
19 | | -class XtsImpState<ImpOpenssl, AlgXtsAes> { |
20 | | -public: |
21 | | - EVP_CIPHER_CTX* encCtx; |
22 | | - EVP_CIPHER_CTX* decCtx; |
23 | | -}; |
24 | | - |
25 | | -template<> |
26 | | -class AuthEncImpState<ImpOpenssl, AlgAes, ModeGcm> { |
27 | | -public: |
28 | | - EVP_CIPHER_CTX* encCtx; |
29 | | - EVP_CIPHER_CTX* decCtx; |
30 | | - BOOLEAN inComputation; |
31 | | -}; |
32 | | - |
33 | | -template<> |
34 | | -class RsaSignImpState<ImpOpenssl, AlgRsaSignPss> { |
35 | | -public: |
36 | | - EVP_PKEY *pkey; |
37 | | - EVP_PKEY_CTX *pkey_ctx; |
38 | | -}; |
39 | | - |
40 | | -template<> |
41 | | -class HashImpState<ImpOpenssl, AlgSha256> { |
42 | | -public: |
43 | | - BOOLEAN isReset; |
44 | | - EVP_MD *md; |
45 | | - EVP_MD_CTX *mdCtx; |
46 | | - struct constants_t { |
47 | | - static constexpr SIZE_T inputBlockLen = SYMCRYPT_SHA256_INPUT_BLOCK_SIZE; |
48 | | - static constexpr SIZE_T resultLen = SYMCRYPT_SHA256_RESULT_SIZE; |
49 | | - static constexpr const char *const algorithm = "SHA2-256"; |
50 | | - } constants; |
51 | | -}; |
52 | | - |
53 | | -template<> |
54 | | -class HashImpState<ImpOpenssl, AlgSha384> { |
55 | | -public: |
56 | | - BOOLEAN isReset; |
57 | | - EVP_MD *md; |
58 | | - EVP_MD_CTX *mdCtx; |
59 | | - struct constants_t { |
60 | | - static constexpr SIZE_T inputBlockLen = SYMCRYPT_SHA384_INPUT_BLOCK_SIZE; |
61 | | - static constexpr SIZE_T resultLen = SYMCRYPT_SHA384_RESULT_SIZE; |
62 | | - static constexpr const char *const algorithm = "SHA2-384"; |
63 | | - } constants; |
64 | | -}; |
65 | | - |
66 | | -template<> |
67 | | -class HashImpState<ImpOpenssl, AlgSha512> { |
68 | | -public: |
69 | | - BOOLEAN isReset; |
70 | | - EVP_MD *md; |
71 | | - EVP_MD_CTX *mdCtx; |
72 | | - struct constants_t { |
73 | | - static constexpr SIZE_T inputBlockLen = SYMCRYPT_SHA512_INPUT_BLOCK_SIZE; |
74 | | - static constexpr SIZE_T resultLen = SYMCRYPT_SHA512_RESULT_SIZE; |
75 | | - static constexpr const char *const algorithm = "SHA2-512"; |
76 | | - } constants; |
77 | | -}; |
78 | | - |
79 | | -template<> |
80 | | -class HashImpState<ImpOpenssl, AlgSha3_256> { |
81 | | -public: |
82 | | - BOOLEAN isReset; |
83 | | - EVP_MD *md; |
84 | | - EVP_MD_CTX *mdCtx; |
85 | | - struct constants_t { |
86 | | - static constexpr SIZE_T inputBlockLen = SYMCRYPT_SHA3_256_INPUT_BLOCK_SIZE; |
87 | | - static constexpr SIZE_T resultLen = SYMCRYPT_SHA3_256_RESULT_SIZE; |
88 | | - static constexpr const char *const algorithm = "SHA3-256"; |
89 | | - } constants; |
90 | | -}; |
91 | | - |
92 | | -template<> |
93 | | -class HashImpState<ImpOpenssl, AlgSha3_384> { |
94 | | -public: |
95 | | - BOOLEAN isReset; |
96 | | - EVP_MD *md; |
97 | | - EVP_MD_CTX *mdCtx; |
98 | | - struct constants_t { |
99 | | - static constexpr SIZE_T inputBlockLen = SYMCRYPT_SHA3_384_INPUT_BLOCK_SIZE; |
100 | | - static constexpr SIZE_T resultLen = SYMCRYPT_SHA3_384_RESULT_SIZE; |
101 | | - static constexpr const char *const algorithm = "SHA3-384"; |
102 | | - } constants; |
103 | | -}; |
104 | | - |
105 | | -template<> |
106 | | -class HashImpState<ImpOpenssl, AlgSha3_512> { |
107 | | -public: |
108 | | - BOOLEAN isReset; |
109 | | - EVP_MD *md; |
110 | | - EVP_MD_CTX *mdCtx; |
111 | | - struct constants_t { |
112 | | - static constexpr SIZE_T inputBlockLen = SYMCRYPT_SHA3_512_INPUT_BLOCK_SIZE; |
113 | | - static constexpr SIZE_T resultLen = SYMCRYPT_SHA3_512_RESULT_SIZE; |
114 | | - static constexpr const char *const algorithm = "SHA3-512"; |
115 | | - } constants; |
116 | | -}; |
117 | | - |
118 | | - |
119 | 16 | VOID |
120 | 17 | addOpensslAlgs(); |
0 commit comments