libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
aes_ni.hh
Go to the documentation of this file.
1/*
2 * libkeepass - KeePass key database importer/exporter
3 * Copyright (C) 2014 Christian Kindahl
4 * Copyright (C) 2024 Dominik Krümpelmann
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
22#pragma once
23
24#include <cstdint>
25
26#include "libkeepass/export.hh"
27
28// AES-NI is an x86/x86-64 instruction-set extension. It is only compiled (and
29// declared) on architectures that support it; elsewhere the portable EVP-based
30// AES-KDF fallback in Key::Transform is used instead.
31//
32// MSVC is excluded: aes_ni.cc relies on GCC/Clang-only helpers (<cpuid.h>,
33// __get_cpuid) and the -maes ISA flag, so on MSVC the portable EVP path is
34// used. OpenSSL uses AES-NI internally, so the fallback is still fast.
35#if (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)) && \
36 !defined(_MSC_VER)
37#define LIBKEEPASS_AES_NI 1
38#else
39#define LIBKEEPASS_AES_NI 0
40#endif
41
42namespace keepass {
43
44#if LIBKEEPASS_AES_NI
45
55LIBKEEPASS_API bool aes_ni_supported();
56
69void LIBKEEPASS_API aes_ni_transform_aes_kdf(const uint8_t seed[32], const uint8_t in[32],
70 uint64_t rounds, uint8_t out[32]);
71
72#endif // LIBKEEPASS_AES_NI
73
74} // namespace keepass
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43