From 5577826ba0b13f06310136433c3ab8ea17ee3df0 Mon Sep 17 00:00:00 2001 From: utelle Date: Tue, 24 Dec 2024 11:51:58 +0100 Subject: [PATCH] Clean up code (AEGIS cipher, some extensions) - Exclude not necessary AEGIS functions from compilation to reduce code size - Fix amalgamation script to handle including certain headers multiple times - Clean up some extensions to use SQLITE_API --- CHANGELOG.md | 13 + configure.ac | 2 +- scripts/amalgamate.py | 539 +++++++++++--------- scripts/sqlite3mc.c.json | 14 +- scripts/sqlite3mc.h.json | 2 + src/aegis/aegis128l/aegis128l.c | 8 + src/aegis/aegis128l/aegis128l_aesni.c | 2 +- src/aegis/aegis128l/aegis128l_altivec.c | 2 +- src/aegis/aegis128l/aegis128l_armcrypto.c | 2 +- src/aegis/aegis128l/aegis128l_common.h | 8 + src/aegis/aegis128l/aegis128l_soft.c | 2 +- src/aegis/aegis128l/implementations.h | 4 + src/aegis/aegis128x2/aegis128x2.c | 14 +- src/aegis/aegis128x2/aegis128x2_aesni.c | 2 +- src/aegis/aegis128x2/aegis128x2_altivec.c | 2 +- src/aegis/aegis128x2/aegis128x2_armcrypto.c | 2 +- src/aegis/aegis128x2/aegis128x2_avx2.c | 2 +- src/aegis/aegis128x2/aegis128x2_common.h | 8 + src/aegis/aegis128x2/aegis128x2_soft.c | 2 +- src/aegis/aegis128x2/implementations.h | 4 + src/aegis/aegis128x4/aegis128x4.c | 14 +- src/aegis/aegis128x4/aegis128x4_aesni.c | 2 +- src/aegis/aegis128x4/aegis128x4_altivec.c | 2 +- src/aegis/aegis128x4/aegis128x4_armcrypto.c | 2 +- src/aegis/aegis128x4/aegis128x4_avx2.c | 2 +- src/aegis/aegis128x4/aegis128x4_avx512.c | 2 +- src/aegis/aegis128x4/aegis128x4_common.h | 8 + src/aegis/aegis128x4/aegis128x4_soft.c | 4 +- src/aegis/aegis128x4/implementations.h | 4 + src/aegis/aegis256/aegis256.c | 16 +- src/aegis/aegis256/aegis256_aesni.c | 2 +- src/aegis/aegis256/aegis256_altivec.c | 2 +- src/aegis/aegis256/aegis256_armcrypto.c | 2 +- src/aegis/aegis256/aegis256_common.h | 8 + src/aegis/aegis256/aegis256_soft.c | 2 +- src/aegis/aegis256/implementations.h | 4 + src/aegis/aegis256x2/aegis256x2.c | 14 +- src/aegis/aegis256x2/aegis256x2_aesni.c | 2 +- src/aegis/aegis256x2/aegis256x2_altivec.c | 2 +- src/aegis/aegis256x2/aegis256x2_armcrypto.c | 2 +- src/aegis/aegis256x2/aegis256x2_avx2.c | 2 +- src/aegis/aegis256x2/aegis256x2_common.h | 8 + src/aegis/aegis256x2/aegis256x2_soft.c | 2 +- src/aegis/aegis256x2/implementations.h | 4 + src/aegis/aegis256x4/aegis256x4.c | 20 +- src/aegis/aegis256x4/aegis256x4_aesni.c | 2 +- src/aegis/aegis256x4/aegis256x4_altivec.c | 2 +- src/aegis/aegis256x4/aegis256x4_armcrypto.c | 2 +- src/aegis/aegis256x4/aegis256x4_avx2.c | 2 +- src/aegis/aegis256x4/aegis256x4_avx512.c | 2 +- src/aegis/aegis256x4/aegis256x4_common.h | 8 + src/aegis/aegis256x4/aegis256x4_soft.c | 2 +- src/aegis/aegis256x4/implementations.h | 4 + src/aegis/common/common.h | 22 + src/aegis/common/func_table.h | 21 + src/aegis/include/aegis128l.h | 8 + src/aegis/include/aegis128x2.h | 8 + src/aegis/include/aegis128x4.h | 8 + src/aegis/include/aegis256.h | 8 + src/aegis/include/aegis256x2.h | 8 + src/aegis/include/aegis256x4.h | 8 + src/argon2/src/thread.h | 2 +- src/carray.c | 14 +- src/compress.c | 6 +- src/csv.c | 7 +- src/fileio.c | 5 +- src/regexp.c | 6 +- src/series.c | 5 +- src/shathree.c | 7 +- src/sqlar.c | 5 +- src/sqlite3mc.c | 79 +-- src/sqlite3mc.h | 2 +- src/sqlite3mc_version.h | 8 +- src/uuid.c | 7 +- src/vsv.c | 7 +- src/zipfile.c | 5 +- 76 files changed, 634 insertions(+), 412 deletions(-) create mode 100644 src/aegis/common/func_table.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 94be538..3640678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added new cipher scheme AEGIS + +### Changed + +- Removed User Authentication extension +- Cleaned up some extensions to use SQLITE_API + +### Fixed + +- Fixed undefined behavior related to function pointer cast + ## [1.9.2] - 2024-12-08 ### Changed diff --git a/configure.ac b/configure.ac index 217507f..651cd05 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl Copyright (C) 2019-2024 Ulrich Telle dnl dnl This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package. -AC_INIT([sqlite3mc], [1.9.2], [ulrich@telle-online.de]) +AC_INIT([sqlite3mc], [2.0.0], [ulrich@telle-online.de]) dnl This is the version tested with, might work with earlier ones. AC_PREREQ([2.69]) diff --git a/scripts/amalgamate.py b/scripts/amalgamate.py index d27f425..210924c 100644 --- a/scripts/amalgamate.py +++ b/scripts/amalgamate.py @@ -2,21 +2,21 @@ # amalgamate.py - Amalgamate C source and header files. # Copyright (c) 2012, Erik Edlund -# +# # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# +# # * Neither the name of Erik Edlund, nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -40,258 +40,291 @@ import sys class Amalgamation(object): - - # Prepends self.source_path to file_path if needed. - def actual_path(self, file_path): - if not os.path.isabs(file_path): - file_path = os.path.join(self.source_path, file_path) - return file_path - - # Search included file_path in self.include_paths and - # in source_dir if specified. - def find_included_file(self, file_path, source_dir): - search_dirs = self.include_paths[:] - if source_dir: - search_dirs.insert(0, source_dir) - - for search_dir in search_dirs: - search_path = os.path.join(search_dir, file_path) - if os.path.isfile(self.actual_path(search_path)): - return search_path - return None - - def __init__(self, args): - with open(args.config, 'r') as f: - config = json.loads(f.read()) - for key in config: - setattr(self, key, config[key]) - - self.verbose = args.verbose == "yes" - self.prologue = args.prologue - self.source_path = args.source_path - self.included_files = [] - - # Generate the amalgamation and write it to the target file. - def generate(self): - amalgamation = "" - - if self.prologue: - with open(self.prologue, 'r') as f: - amalgamation += datetime.datetime.now().strftime(f.read()) - - if self.verbose: - print("Config:") - print(" target = {0}".format(self.target)) - print(" working_dir = {0}".format(os.getcwd())) - print(" include_paths = {0}".format(self.include_paths)) - print("Creating amalgamation:") - for file_path in self.sources: - # Do not check the include paths while processing the source - # list, all given source paths must be correct. - actual_path = self.actual_path(file_path) - print(" - processing \"{0}\"".format(file_path)) - t = TranslationUnit(file_path, self, True) - amalgamation += t.content - - with open(self.target, 'w') as f: - f.write(amalgamation) - - print("...done!\n") - if self.verbose: - print("Files processed: {0}".format(self.sources)) - print("Files included: {0}".format(self.included_files)) - print("") + + # Prepends self.source_path to file_path if needed. + def actual_path(self, file_path): + if not os.path.isabs(file_path): + file_path = os.path.join(self.source_path, file_path) + return file_path + + # Search included file_path in self.include_paths and + # in source_dir if specified. + def find_included_file(self, file_path, source_dir): + search_dirs = self.include_paths[:] + if source_dir: + search_dirs.insert(0, source_dir) + + for search_dir in search_dirs: + search_path = os.path.join(search_dir, file_path) + actual_path = self.actual_path(search_path) + if os.path.isfile(self.actual_path(search_path)): + #if self.verbose: + # print(" Found include {0} - location {1}".format(file_path,actual_path)) + return search_path + + return None + + def __init__(self, args): + with open(args.config, 'r') as f: + config = json.loads(f.read()) + for key in config: + setattr(self, key, config[key]) + + self.verbose = args.verbose == "yes" + self.prologue = args.prologue + self.source_path = args.source_path + self.included_files = [] + + # Generate the amalgamation and write it to the target file. + def generate(self): + amalgamation = "" + + if self.prologue: + with open(self.prologue, 'r') as f: + amalgamation += datetime.datetime.now().strftime(f.read()) + + if self.verbose: + print("Config:") + print(" target = {0}".format(self.target)) + print(" working_dir = {0}".format(os.getcwd())) + print(" include_paths = {0}".format(self.include_paths)) + print(" force_include = {0}".format(self.force_include)) + print("Creating amalgamation:") + for file_path in self.sources: + # Do not check the include paths while processing the source + # list, all given source paths must be correct. + actual_path = self.actual_path(file_path) + print(" - processing \"{0}\"".format(file_path)) + t = TranslationUnit(file_path, self, True) + amalgamation += t.content + + with open(self.target, 'w') as f: + f.write(amalgamation) + + print("...done!\n") + if self.verbose: + print("Files processed: {0}".format(self.sources)) + print("Files included: {0}".format(self.included_files)) + print("") class TranslationUnit(object): - - # // C++ comment. - cpp_comment_pattern = re.compile(r"//.*?\n") - - # /* C comment. */ - c_comment_pattern = re.compile(r"/\*.*?\*/", re.S) - - # "complex \"stri\\\ng\" value". - string_pattern = re.compile("[^']" r'".*?(?<=[^\\])"', re.S) - - # Handle simple include directives. Support for advanced - # directives where macros and defines needs to expanded is - # not a concern right now. - include_pattern = re.compile( - r'#\s*include\s+(<|")(?P.*?)("|>)', re.S) - - # #pragma once - pragma_once_pattern = re.compile(r'#\s*pragma\s+once', re.S) - - # Search for pattern in self.content, add the match to - # contexts if found and update the index accordingly. - def _search_content(self, index, pattern, contexts): - match = pattern.search(self.content, index) - if match: - contexts.append(match) - return match.end() - return index + 2 - - # Return all the skippable contexts, i.e., comments and strings - def _find_skippable_contexts(self): - # Find contexts in the content in which a found include - # directive should not be processed. - skippable_contexts = [] - - # Walk through the content char by char, and try to grab - # skippable contexts using regular expressions when found. - i = 1 - content_len = len(self.content) - while i < content_len: - j = i - 1 - current = self.content[i] - previous = self.content[j] - - if current == '"': - # String value. - i = self._search_content(j, self.string_pattern, - skippable_contexts) - elif current == '*' and previous == '/': - # C style comment. - i = self._search_content(j, self.c_comment_pattern, - skippable_contexts) - elif current == '/' and previous == '/': - # C++ style comment. - i = self._search_content(j, self.cpp_comment_pattern, - skippable_contexts) - else: - # Skip to the next char. - i += 1 - - return skippable_contexts - - # Returns True if the match is within list of other matches - def _is_within(self, match, matches): - for m in matches: - if match.start() > m.start() and \ - match.end() < m.end(): - return True - return False - - # Removes pragma once from content - def _process_pragma_once(self): - content_len = len(self.content) - if content_len < len("#include "): - return 0 - - # Find contexts in the content in which a found include - # directive should not be processed. - skippable_contexts = self._find_skippable_contexts() - - pragmas = [] - pragma_once_match = self.pragma_once_pattern.search(self.content) - while pragma_once_match: - if not self._is_within(pragma_once_match, skippable_contexts): - pragmas.append(pragma_once_match) - - pragma_once_match = self.pragma_once_pattern.search(self.content, - pragma_once_match.end()) - - # Handle all collected pragma once directives. - prev_end = 0 - tmp_content = '' - for pragma_match in pragmas: - tmp_content += self.content[prev_end:pragma_match.start()] - prev_end = pragma_match.end() - tmp_content += self.content[prev_end:] - self.content = tmp_content - - # Include all trivial #include directives into self.content. - def _process_includes(self): - content_len = len(self.content) - if content_len < len("#include "): - return 0 - - # Find contexts in the content in which a found include - # directive should not be processed. - skippable_contexts = self._find_skippable_contexts() - - # Search for include directives in the content, collect those - # which should be included into the content. - includes = [] - include_match = self.include_pattern.search(self.content) - while include_match: - if not self._is_within(include_match, skippable_contexts): - include_path = include_match.group("path") - search_same_dir = include_match.group(1) == '"' - found_included_path = self.amalgamation.find_included_file( - include_path, self.file_dir if search_same_dir else None) - if found_included_path: - includes.append((include_match, found_included_path)) - - include_match = self.include_pattern.search(self.content, - include_match.end()) - - # Handle all collected include directives. - prev_end = 0 - tmp_content = '' - for include in includes: - include_match, found_included_path = include - tmp_content += self.content[prev_end:include_match.start()] - tmp_content += "/* {0} */\n".format(include_match.group(0)) - if not found_included_path in self.amalgamation.included_files: - tmp_content += "/*** Begin of {0} ***/\n".format(include_match.group(0)) - t = TranslationUnit(found_included_path, self.amalgamation, False) - tmp_content += t.content - tmp_content += "/*** End of {0} ***/\n".format(include_match.group(0)) - prev_end = include_match.end() - tmp_content += self.content[prev_end:] - self.content = tmp_content - - return len(includes) - - # Make all content processing - def _process(self): - if not self.is_root: - self._process_pragma_once() - self._process_includes() - - def __init__(self, file_path, amalgamation, is_root): - self.file_path = file_path - self.file_dir = os.path.dirname(file_path) - self.amalgamation = amalgamation - self.is_root = is_root - - self.amalgamation.included_files.append(self.file_path) - - actual_path = self.amalgamation.actual_path(file_path) - if not os.path.isfile(actual_path): - raise IOError("File not found: \"{0}\"".format(file_path)) - with open(actual_path, 'r') as f: - self.content = f.read() - self._process() + + # // C++ comment. + cpp_comment_pattern = re.compile(r"//.*?\n") + + # /* C comment. */ + c_comment_pattern = re.compile(r"/\*.*?\*/", re.S) + + # "complex \"stri\\\ng\" value". + string_pattern = re.compile("[^']" r'".*?(?<=[^\\])"', re.S) + + # Handle simple include directives. Support for advanced + # directives where macros and defines needs to expanded is + # not a concern right now. + include_pattern = re.compile( + r'#\s*include\s+(<|")(?P.*?)("|>)', re.S) + + # #pragma once + pragma_once_pattern = re.compile(r'#\s*pragma\s+once', re.S) + + # Search for pattern in self.content, add the match to + # contexts if found and update the index accordingly. + def _search_content(self, index, pattern, contexts): + match = pattern.search(self.content, index) + if match: + contexts.append(match) + return match.end() + return index + 2 + + # Return all the skippable contexts, i.e., comments and strings + def _find_skippable_contexts(self): + # Find contexts in the content in which a found include + # directive should not be processed. + skippable_contexts = [] + + # Walk through the content char by char, and try to grab + # skippable contexts using regular expressions when found. + i = 1 + content_len = len(self.content) + while i < content_len: + j = i - 1 + current = self.content[i] + previous = self.content[j] + + if current == '"': + # String value. + i = self._search_content(j, self.string_pattern, + skippable_contexts) + elif current == '*' and previous == '/': + # C style comment. + i = self._search_content(j, self.c_comment_pattern, + skippable_contexts) + elif current == '/' and previous == '/': + # C++ style comment. + i = self._search_content(j, self.cpp_comment_pattern, + skippable_contexts) + else: + # Skip to the next char. + i += 1 + + return skippable_contexts + + # Returns True if the match is within list of other matches + def _is_within(self, match, matches): + for m in matches: + if match.start() > m.start() and \ + match.end() < m.end(): + return True + return False + + # Removes pragma once from content + def _process_pragma_once(self): + content_len = len(self.content) + if content_len < len("#include "): + return 0 + + # Find contexts in the content in which a found include + # directive should not be processed. + skippable_contexts = self._find_skippable_contexts() + + pragmas = [] + pragma_once_match = self.pragma_once_pattern.search(self.content) + while pragma_once_match: + if not self._is_within(pragma_once_match, skippable_contexts): + pragmas.append(pragma_once_match) + + pragma_once_match = self.pragma_once_pattern.search(self.content, + pragma_once_match.end()) + + # Handle all collected pragma once directives. + prev_end = 0 + tmp_content = '' + for pragma_match in pragmas: + tmp_content += self.content[prev_end:pragma_match.start()] + prev_end = pragma_match.end() + tmp_content += self.content[prev_end:] + self.content = tmp_content + + def find_forced_file(self, file_path, source_dir): + search_files = self.amalgamation.force_include[:] + norm_file_path = os.path.normpath(file_path) + for search_file in search_files: + found_forced_path = self.amalgamation.find_included_file(search_file, None) + if found_forced_path: + norm_forced_path = os.path.normpath(found_forced_path) + if norm_file_path == norm_forced_path: + return found_forced_path + return None + + # Include all trivial #include directives into self.content. + def _process_includes(self): + content_len = len(self.content) + if content_len < len("#include "): + return 0 + + # Find contexts in the content in which a found include + # directive should not be processed. + skippable_contexts = self._find_skippable_contexts() + + # Search for include directives in the content, collect those + # which should be included into the content. + #if self.amalgamation.verbose: + # print("Include matches:") + includes = [] + include_match = self.include_pattern.search(self.content) + while include_match: + if not self._is_within(include_match, skippable_contexts): + include_path = include_match.group("path") + search_same_dir = include_match.group(1) == '"' + found_included_path = self.amalgamation.find_included_file( + include_path, self.file_dir if search_same_dir else None) + if found_included_path: + includes.append((include_match, found_included_path)) + #if self.amalgamation.verbose: + # print(" #include = {0}".format(include_path)) + include_match = self.include_pattern.search(self.content, + include_match.end()) + + # Handle all collected include directives. + prev_end = 0 + tmp_content = '' + for include in includes: + include_match, found_included_path = include + tmp_content += self.content[prev_end:include_match.start()] + tmp_content += "/* {0} */\n".format(include_match.group(0)) + if not os.path.normpath(found_included_path) in self.amalgamation.included_files: + tmp_content += "/*** Begin of {0} ***/\n".format(include_match.group(0)) + t = TranslationUnit(found_included_path, self.amalgamation, False) + trimmed_content = []; + for line in t.content.splitlines(): + line = line.rstrip() + "\n" + trimmed_content.append(line) + tmp_content += "".join(trimmed_content) + tmp_content += "/*** End of {0} ***/\n".format(include_match.group(0)) + prev_end = include_match.end() + tmp_content += self.content[prev_end:] + self.content = tmp_content + + return len(includes) + + # Make all content processing + def _process(self): + if not self.is_root: + self._process_pragma_once() + self._process_includes() + + def __init__(self, file_path, amalgamation, is_root): + self.file_path = file_path + self.file_dir = os.path.dirname(file_path) + self.amalgamation = amalgamation + self.is_root = is_root + + found_forced_path = self.find_forced_file(self.file_path, None) + if not found_forced_path: + self.amalgamation.included_files.append(os.path.normpath(self.file_path)) + #if self.amalgamation.verbose: + # print("Add include:") + # print(" include = {0}".format(os.path.normpath(self.file_path))) + #else: + #if self.amalgamation.verbose: + # print("Reinclude:") + # print(" include = {0}".format(os.path.normpath(self.file_path))) + # print(" forced = {0}".format(os.path.normpath(found_forced_path))) + + actual_path = self.amalgamation.actual_path(file_path) + if not os.path.isfile(actual_path): + raise IOError("File not found: \"{0}\"".format(file_path)) + with open(actual_path, 'r') as f: + self.content = f.read() + self._process() def main(): - description = "Amalgamate C source and header files." - usage = " ".join([ - "amalgamate.py", - "[-v]", - "-c path/to/config.json", - "-s path/to/source/dir", - "[-p path/to/prologue.(c|h)]" - ]) - argsparser = argparse.ArgumentParser( - description=description, usage=usage) - - argsparser.add_argument("-v", "--verbose", dest="verbose", - choices=["yes", "no"], metavar="", help="be verbose") - - argsparser.add_argument("-c", "--config", dest="config", - required=True, metavar="", help="path to a JSON config file") - - argsparser.add_argument("-s", "--source", dest="source_path", - required=True, metavar="", help="source code path") - - argsparser.add_argument("-p", "--prologue", dest="prologue", - required=False, metavar="", help="path to a C prologue file") - - amalgamation = Amalgamation(argsparser.parse_args()) - amalgamation.generate() + description = "Amalgamate C source and header files." + usage = " ".join([ + "amalgamate.py", + "[-v]", + "-c path/to/config.json", + "-s path/to/source/dir", + "[-p path/to/prologue.(c|h)]" + ]) + argsparser = argparse.ArgumentParser( + description=description, usage=usage) + + argsparser.add_argument("-v", "--verbose", dest="verbose", + choices=["yes", "no"], metavar="", help="be verbose") + + argsparser.add_argument("-c", "--config", dest="config", + required=True, metavar="", help="path to a JSON config file") + + argsparser.add_argument("-s", "--source", dest="source_path", + required=True, metavar="", help="source code path") + + argsparser.add_argument("-p", "--prologue", dest="prologue", + required=False, metavar="", help="path to a C prologue file") + + amalgamation = Amalgamation(argsparser.parse_args()) + amalgamation.generate() if __name__ == "__main__": - main() + main() diff --git a/scripts/sqlite3mc.c.json b/scripts/sqlite3mc.c.json index d8a1f91..cc7dc5e 100644 --- a/scripts/sqlite3mc.c.json +++ b/scripts/sqlite3mc.c.json @@ -5,7 +5,19 @@ "sqlite3mc.c" ], "include_paths": [ - "src", "." + "aegis/include", "argon2/include", "." + ], + "force_include": [ + "aegis/common/func_names_define.h", + "aegis/common/func_names_undefine.h", + "aegis/common/type_names_undefine.h", + "aegis/common/func_table.h", + "aegis/aegis128l/aegis128l_common.h", + "aegis/aegis128x2/aegis128x2_common.h", + "aegis/aegis128x4/aegis128x4_common.h", + "aegis/aegis256/aegis256_common.h", + "aegis/aegis256x2/aegis256x2_common.h", + "aegis/aegis256x4/aegis256x4_common.h" ] } diff --git a/scripts/sqlite3mc.h.json b/scripts/sqlite3mc.h.json index aa5c8da..570a4d0 100644 --- a/scripts/sqlite3mc.h.json +++ b/scripts/sqlite3mc.h.json @@ -6,6 +6,8 @@ ], "include_paths": [ "src", "." + ], + "force_include": [ ] } diff --git a/src/aegis/aegis128l/aegis128l.c b/src/aegis/aegis128l/aegis128l.c index 9886a62..4a9d75b 100644 --- a/src/aegis/aegis128l/aegis128l.c +++ b/src/aegis/aegis128l/aegis128l.c @@ -115,6 +115,8 @@ aegis128l_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, cons return ret; } +#ifndef AEGIS_OMIT_INCREMENTAL + AEGIS_API void aegis128l_state_init(aegis128l_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, @@ -176,6 +178,8 @@ aegis128l_state_decrypt_detached_final(aegis128l_state *st_, uint8_t *m, size_t return implementation_128l->state_decrypt_detached_final(st_, m, mlen_max, written, mac, maclen); } +#endif /* AEGIS_OMIT_INCREMENTAL */ + AEGIS_API void aegis128l_stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k) @@ -199,6 +203,8 @@ aegis128l_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, con implementation_128l->decrypt_unauthenticated(m, c, clen, npub, k); } +#ifndef AEGIS_OMIT_MAC_API + AEGIS_API void aegis128l_mac_init(aegis128l_mac_state *st_, const uint8_t *k, const uint8_t *npub) @@ -260,6 +266,8 @@ aegis128l_mac_state_clone(aegis128l_mac_state *dst, const aegis128l_mac_state *s implementation_128l->state_mac_clone(dst, src); } +#endif /* AEGIS_OMIT_MAC_API */ + AEGIS_PRIVATE int aegis128l_pick_best_implementation(void) diff --git a/src/aegis/aegis128l/aegis128l_aesni.c b/src/aegis/aegis128l/aegis128l_aesni.c index a6c1b01..650c42a 100644 --- a/src/aegis/aegis128l/aegis128l_aesni.c +++ b/src/aegis/aegis128l/aegis128l_aesni.c @@ -97,7 +97,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128l_common.h" struct aegis128l_implementation aegis128l_aesni_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128l/aegis128l_altivec.c b/src/aegis/aegis128l/aegis128l_altivec.c index bd3fa3c..4beed1f 100644 --- a/src/aegis/aegis128l/aegis128l_altivec.c +++ b/src/aegis/aegis128l/aegis128l_altivec.c @@ -93,7 +93,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128l_common.h" struct aegis128l_implementation aegis128l_altivec_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128l/aegis128l_armcrypto.c b/src/aegis/aegis128l/aegis128l_armcrypto.c index 311fd72..2dde33f 100644 --- a/src/aegis/aegis128l/aegis128l_armcrypto.c +++ b/src/aegis/aegis128l/aegis128l_armcrypto.c @@ -107,7 +107,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128l_common.h" struct aegis128l_implementation aegis128l_armcrypto_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128l/aegis128l_common.h b/src/aegis/aegis128l/aegis128l_common.h index 79ca599..d4af7e9 100644 --- a/src/aegis/aegis128l/aegis128l_common.h +++ b/src/aegis/aegis128l/aegis128l_common.h @@ -325,6 +325,8 @@ typedef struct AEGIS_MAC_STATE { size_t pos; } AEGIS_MAC_STATE; +#ifndef AEGIS_OMIT_INCREMENTAL + static void AEGIS_state_init(aegis128l_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k) @@ -592,6 +594,10 @@ AEGIS_state_decrypt_detached_final(aegis128l_state *st_, uint8_t *m, size_t mlen return ret; } +#endif /* AEGIS_OMIT_INCREMENTAL */ + +#ifndef AEGIS_OMIT_MAC_API + static void AEGIS_state_mac_init(aegis128l_mac_state *st_, const uint8_t *npub, const uint8_t *k) { @@ -707,6 +713,8 @@ AEGIS_state_mac_clone(aegis128l_mac_state *dst, const aegis128l_mac_state *src) *dst_ = *src_; } +#endif /* AEGIS_OMIT_MAC_API */ + #undef AEGIS_RATE #undef AEGIS_ALIGNMENT diff --git a/src/aegis/aegis128l/aegis128l_soft.c b/src/aegis/aegis128l/aegis128l_soft.c index e4d7498..ac31461 100644 --- a/src/aegis/aegis128l/aegis128l_soft.c +++ b/src/aegis/aegis128l/aegis128l_soft.c @@ -89,7 +89,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128l_common.h" struct aegis128l_implementation aegis128l_soft_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128l/implementations.h b/src/aegis/aegis128l/implementations.h index 735face..63c03b7 100644 --- a/src/aegis/aegis128l/implementations.h +++ b/src/aegis/aegis128l/implementations.h @@ -24,6 +24,7 @@ typedef struct aegis128l_implementation { const uint8_t *k); void (*decrypt_unauthenticated)(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_INCREMENTAL void (*state_init)(aegis128l_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k); int (*state_encrypt_update)(aegis128l_state *st_, uint8_t *c, size_t clen_max, size_t *written, @@ -36,11 +37,14 @@ typedef struct aegis128l_implementation { size_t *written, const uint8_t *c, size_t clen); int (*state_decrypt_detached_final)(aegis128l_state *st_, uint8_t *m, size_t mlen_max, size_t *written, const uint8_t *mac, size_t maclen); +#endif /* AEGIS_OMIT_INCREMENTAL */ +#ifndef AEGIS_OMIT_MAC_API void (*state_mac_init)(aegis128l_mac_state *st_, const uint8_t *npub, const uint8_t *k); int (*state_mac_update)(aegis128l_mac_state *st_, const uint8_t *ad, size_t adlen); int (*state_mac_final)(aegis128l_mac_state *st_, uint8_t *mac, size_t maclen); void (*state_mac_reset)(aegis128l_mac_state *st); void (*state_mac_clone)(aegis128l_mac_state *dst, const aegis128l_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ } aegis128l_implementation; #endif /* AEGIS128L_IMPLEMENTATIONS_H */ diff --git a/src/aegis/aegis128x2/aegis128x2.c b/src/aegis/aegis128x2/aegis128x2.c index fdaf2d3..dc2f878 100644 --- a/src/aegis/aegis128x2/aegis128x2.c +++ b/src/aegis/aegis128x2/aegis128x2.c @@ -116,6 +116,8 @@ aegis128x2_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, con return ret; } +#ifndef AEGIS_OMIT_INCREMENTAL + AEGIS_API void aegis128x2_state_init(aegis128x2_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, @@ -177,6 +179,8 @@ aegis128x2_state_decrypt_detached_final(aegis128x2_state *st_, uint8_t *m, size_ return implementation_128x2->state_decrypt_detached_final(st_, m, mlen_max, written, mac, maclen); } +#endif /* AEGIS_OMIT_INCREMENTAL */ + AEGIS_API void aegis128x2_stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k) @@ -200,6 +204,8 @@ aegis128x2_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, co implementation_128x2->decrypt_unauthenticated(m, c, clen, npub, k); } +#ifndef AEGIS_OMIT_MAC_API + AEGIS_API void aegis128x2_mac_init(aegis128x2_mac_state *st_, const uint8_t *k, const uint8_t *npub) @@ -258,20 +264,22 @@ aegis128x2_mac_state_clone(aegis128x2_mac_state *dst, const aegis128x2_mac_state implementation_128x2->state_mac_clone(dst, src); } +#endif /* AEGIS_OMIT_MAC_API */ + AEGIS_PRIVATE int aegis128x2_pick_best_implementation(void) { implementation_128x2 = &aegis128x2_soft_implementation; -#if defined(__aarch64__) || defined(_M_ARM64) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON if (aegis_runtime_has_armcrypto()) { implementation_128x2 = &aegis128x2_armcrypto_implementation; return 0; } #endif -#if defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI # ifdef HAVE_VAESINTRIN_H if (aegis_runtime_has_vaes() && aegis_runtime_has_avx2()) { implementation_128x2 = &aegis128x2_avx2_implementation; @@ -284,7 +292,7 @@ aegis128x2_pick_best_implementation(void) } #endif -#if defined(__ALTIVEC__) && defined(__CRYPTO__) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC if (aegis_runtime_has_altivec()) { implementation_128x2 = &aegis128x2_altivec_implementation; return 0; diff --git a/src/aegis/aegis128x2/aegis128x2_aesni.c b/src/aegis/aegis128x2/aegis128x2_aesni.c index 6877b71..930c8dd 100644 --- a/src/aegis/aegis128x2/aegis128x2_aesni.c +++ b/src/aegis/aegis128x2/aegis128x2_aesni.c @@ -103,7 +103,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x2_common.h" struct aegis128x2_implementation aegis128x2_aesni_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x2/aegis128x2_altivec.c b/src/aegis/aegis128x2/aegis128x2_altivec.c index 0036111..7ed1b21 100644 --- a/src/aegis/aegis128x2/aegis128x2_altivec.c +++ b/src/aegis/aegis128x2/aegis128x2_altivec.c @@ -98,7 +98,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x2_common.h" struct aegis128x2_implementation aegis128x2_altivec_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x2/aegis128x2_armcrypto.c b/src/aegis/aegis128x2/aegis128x2_armcrypto.c index c89a00b..441bbf9 100644 --- a/src/aegis/aegis128x2/aegis128x2_armcrypto.c +++ b/src/aegis/aegis128x2/aegis128x2_armcrypto.c @@ -112,7 +112,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x2_common.h" struct aegis128x2_implementation aegis128x2_armcrypto_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x2/aegis128x2_avx2.c b/src/aegis/aegis128x2/aegis128x2_avx2.c index 5fc42bb..f6652c5 100644 --- a/src/aegis/aegis128x2/aegis128x2_avx2.c +++ b/src/aegis/aegis128x2/aegis128x2_avx2.c @@ -98,7 +98,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x2_common.h" struct aegis128x2_implementation aegis128x2_avx2_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x2/aegis128x2_common.h b/src/aegis/aegis128x2/aegis128x2_common.h index 79bc00f..7be2cba 100644 --- a/src/aegis/aegis128x2/aegis128x2_common.h +++ b/src/aegis/aegis128x2/aegis128x2_common.h @@ -429,6 +429,8 @@ typedef struct AEGIS_MAC_STATE { size_t pos; } AEGIS_MAC_STATE; +#ifndef AEGIS_OMIT_INCREMENTAL + static void AEGIS_state_init(aegis128x2_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k) @@ -697,6 +699,10 @@ AEGIS_state_decrypt_detached_final(aegis128x2_state *st_, uint8_t *m, size_t mle return ret; } +#endif /* AEGIS_OMIT_INCREMENTAL */ + +#ifndef AEGIS_OMIT_MAC_API + static void AEGIS_state_mac_init(aegis128x2_mac_state *st_, const uint8_t *npub, const uint8_t *k) { @@ -813,6 +819,8 @@ AEGIS_state_mac_clone(aegis128x2_mac_state *dst, const aegis128x2_mac_state *src *dst_ = *src_; } +#endif /* AEGIS_OMIT_MAC_API */ + #undef AEGIS_RATE #undef AEGIS_ALIGNMENT diff --git a/src/aegis/aegis128x2/aegis128x2_soft.c b/src/aegis/aegis128x2/aegis128x2_soft.c index 89c5379..c7fb213 100644 --- a/src/aegis/aegis128x2/aegis128x2_soft.c +++ b/src/aegis/aegis128x2/aegis128x2_soft.c @@ -93,7 +93,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x2_common.h" struct aegis128x2_implementation aegis128x2_soft_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x2/implementations.h b/src/aegis/aegis128x2/implementations.h index cd6b459..846394a 100644 --- a/src/aegis/aegis128x2/implementations.h +++ b/src/aegis/aegis128x2/implementations.h @@ -24,6 +24,7 @@ typedef struct aegis128x2_implementation { const uint8_t *k); void (*decrypt_unauthenticated)(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_INCREMENTAL void (*state_init)(aegis128x2_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k); int (*state_encrypt_update)(aegis128x2_state *st_, uint8_t *c, size_t clen_max, size_t *written, @@ -36,11 +37,14 @@ typedef struct aegis128x2_implementation { size_t *written, const uint8_t *c, size_t clen); int (*state_decrypt_detached_final)(aegis128x2_state *st_, uint8_t *m, size_t mlen_max, size_t *written, const uint8_t *mac, size_t maclen); +#endif /* AEGIS_OMIT_INCREMENTAL */ +#ifndef AEGIS_OMIT_MAC_API void (*state_mac_init)(aegis128x2_mac_state *st_, const uint8_t *npub, const uint8_t *k); int (*state_mac_update)(aegis128x2_mac_state *st_, const uint8_t *ad, size_t adlen); int (*state_mac_final)(aegis128x2_mac_state *st_, uint8_t *mac, size_t maclen); void (*state_mac_reset)(aegis128x2_mac_state *st); void (*state_mac_clone)(aegis128x2_mac_state *dst, const aegis128x2_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ } aegis128x2_implementation; #endif /* AEGIS128X2_IMPLEMENTATIONS_H */ diff --git a/src/aegis/aegis128x4/aegis128x4.c b/src/aegis/aegis128x4/aegis128x4.c index 4c7fe96..4407317 100644 --- a/src/aegis/aegis128x4/aegis128x4.c +++ b/src/aegis/aegis128x4/aegis128x4.c @@ -118,6 +118,8 @@ aegis128x4_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, con return ret; } +#ifndef AEGIS_OMIT_INCREMENTAL + AEGIS_API void aegis128x4_state_init(aegis128x4_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, @@ -179,6 +181,8 @@ aegis128x4_state_decrypt_detached_final(aegis128x4_state *st_, uint8_t *m, size_ return implementation_128x4->state_decrypt_detached_final(st_, m, mlen_max, written, mac, maclen); } +#endif /* AEGIS_OMIT_INCREMENTAL */ + AEGIS_API void aegis128x4_stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k) @@ -202,6 +206,8 @@ aegis128x4_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, co implementation_128x4->decrypt_unauthenticated(m, c, clen, npub, k); } +#ifndef AEGIS_OMIT_MAC_API + AEGIS_API void aegis128x4_mac_init(aegis128x4_mac_state *st_, const uint8_t *k, const uint8_t *npub) @@ -260,20 +266,22 @@ aegis128x4_mac_state_clone(aegis128x4_mac_state *dst, const aegis128x4_mac_state implementation_128x4->state_mac_clone(dst, src); } +#endif /* AEGIS_OMIT_MAC_API */ + AEGIS_PRIVATE int aegis128x4_pick_best_implementation(void) { implementation_128x4 = &aegis128x4_soft_implementation; -#if defined(__aarch64__) || defined(_M_ARM64) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON if (aegis_runtime_has_armcrypto()) { implementation_128x4 = &aegis128x4_armcrypto_implementation; return 0; } #endif -#if defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI # ifdef HAVE_VAESINTRIN_H if (aegis_runtime_has_vaes() && aegis_runtime_has_avx512f()) { implementation_128x4 = &aegis128x4_avx512_implementation; @@ -290,7 +298,7 @@ aegis128x4_pick_best_implementation(void) } #endif -#if defined(__ALTIVEC__) && defined(__CRYPTO__) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC if (aegis_runtime_has_altivec()) { implementation_128x4 = &aegis128x4_altivec_implementation; return 0; diff --git a/src/aegis/aegis128x4/aegis128x4_aesni.c b/src/aegis/aegis128x4/aegis128x4_aesni.c index 5a6fbf1..6e32788 100644 --- a/src/aegis/aegis128x4/aegis128x4_aesni.c +++ b/src/aegis/aegis128x4/aegis128x4_aesni.c @@ -112,7 +112,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x4_common.h" struct aegis128x4_implementation aegis128x4_aesni_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x4/aegis128x4_altivec.c b/src/aegis/aegis128x4/aegis128x4_altivec.c index 877961b..08d7a82 100644 --- a/src/aegis/aegis128x4/aegis128x4_altivec.c +++ b/src/aegis/aegis128x4/aegis128x4_altivec.c @@ -106,7 +106,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x4_common.h" struct aegis128x4_implementation aegis128x4_altivec_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x4/aegis128x4_armcrypto.c b/src/aegis/aegis128x4/aegis128x4_armcrypto.c index 86bbb71..ef60de8 100644 --- a/src/aegis/aegis128x4/aegis128x4_armcrypto.c +++ b/src/aegis/aegis128x4/aegis128x4_armcrypto.c @@ -120,7 +120,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x4_common.h" struct aegis128x4_implementation aegis128x4_armcrypto_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x4/aegis128x4_avx2.c b/src/aegis/aegis128x4/aegis128x4_avx2.c index ffc5d1f..13eb3a4 100644 --- a/src/aegis/aegis128x4/aegis128x4_avx2.c +++ b/src/aegis/aegis128x4/aegis128x4_avx2.c @@ -104,7 +104,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x4_common.h" struct aegis128x4_implementation aegis128x4_avx2_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x4/aegis128x4_avx512.c b/src/aegis/aegis128x4/aegis128x4_avx512.c index 69e122d..513dbd3 100644 --- a/src/aegis/aegis128x4/aegis128x4_avx512.c +++ b/src/aegis/aegis128x4/aegis128x4_avx512.c @@ -104,7 +104,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A #include "aegis128x4_common.h" struct aegis128x4_implementation aegis128x4_avx512_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x4/aegis128x4_common.h b/src/aegis/aegis128x4/aegis128x4_common.h index e0500e6..58c5ae2 100644 --- a/src/aegis/aegis128x4/aegis128x4_common.h +++ b/src/aegis/aegis128x4/aegis128x4_common.h @@ -444,6 +444,8 @@ typedef struct AEGIS_MAC_STATE { size_t pos; } AEGIS_MAC_STATE; +#ifndef AEGIS_OMIT_INCREMENTAL + static void AEGIS_state_init(aegis128x4_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k) @@ -712,6 +714,10 @@ AEGIS_state_decrypt_detached_final(aegis128x4_state *st_, uint8_t *m, size_t mle return ret; } +#endif /* AEGIS_OMIT_INCREMENTAL */ + +#ifndef AEGIS_OMIT_MAC_API + static void AEGIS_state_mac_init(aegis128x4_mac_state *st_, const uint8_t *npub, const uint8_t *k) { @@ -827,6 +833,8 @@ AEGIS_state_mac_clone(aegis128x4_mac_state *dst, const aegis128x4_mac_state *src *dst_ = *src_; } +#endif /* AEGIS_OMIT_MAC_API */ + #undef AEGIS_RATE #undef AEGIS_ALIGNMENT diff --git a/src/aegis/aegis128x4/aegis128x4_soft.c b/src/aegis/aegis128x4/aegis128x4_soft.c index 9780bb5..40a3ef1 100644 --- a/src/aegis/aegis128x4/aegis128x4_soft.c +++ b/src/aegis/aegis128x4/aegis128x4_soft.c @@ -98,10 +98,10 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d1, const A state[4] = AEGIS_AES_BLOCK_XOR(state[4], d2); } -# include "aegis128x4_common.h" +#include "aegis128x4_common.h" struct aegis128x4_implementation aegis128x4_soft_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis128x4/implementations.h b/src/aegis/aegis128x4/implementations.h index 4b5da36..2457193 100644 --- a/src/aegis/aegis128x4/implementations.h +++ b/src/aegis/aegis128x4/implementations.h @@ -24,6 +24,7 @@ typedef struct aegis128x4_implementation { const uint8_t *k); void (*decrypt_unauthenticated)(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_INCREMENTAL void (*state_init)(aegis128x4_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k); int (*state_encrypt_update)(aegis128x4_state *st_, uint8_t *c, size_t clen_max, size_t *written, @@ -36,11 +37,14 @@ typedef struct aegis128x4_implementation { size_t *written, const uint8_t *c, size_t clen); int (*state_decrypt_detached_final)(aegis128x4_state *st_, uint8_t *m, size_t mlen_max, size_t *written, const uint8_t *mac, size_t maclen); +#endif /* AEGIS_OMIT_INCREMENTAL */ +#ifndef AEGIS_OMIT_MAC_API void (*state_mac_init)(aegis128x4_mac_state *st_, const uint8_t *npub, const uint8_t *k); int (*state_mac_update)(aegis128x4_mac_state *st_, const uint8_t *ad, size_t adlen); int (*state_mac_final)(aegis128x4_mac_state *st_, uint8_t *mac, size_t maclen); void (*state_mac_reset)(aegis128x4_mac_state *st); void (*state_mac_clone)(aegis128x4_mac_state *dst, const aegis128x4_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ } aegis128x4_implementation; #endif /* AEGIS128X4_IMPLEMENTATIONS_H */ diff --git a/src/aegis/aegis256/aegis256.c b/src/aegis/aegis256/aegis256.c index 749b751..6458bc8 100644 --- a/src/aegis/aegis256/aegis256.c +++ b/src/aegis/aegis256/aegis256.c @@ -21,7 +21,7 @@ #endif #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NONE -# include "aegis256_soft.h" +#include "aegis256_soft.h" static const aegis256_implementation *implementation_256 = &aegis256_soft_implementation; #elif HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON static const aegis256_implementation *implementation_256 = &aegis256_armcrypto_implementation; @@ -115,6 +115,8 @@ aegis256_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, const return ret; } +#ifndef AEGIS_OMIT_INCREMENTAL + AEGIS_API void aegis256_state_init(aegis256_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, @@ -176,6 +178,8 @@ aegis256_state_decrypt_detached_final(aegis256_state *st_, uint8_t *m, size_t ml return implementation_256->state_decrypt_detached_final(st_, m, mlen_max, written, mac, maclen); } +#endif /* AEGIS_OMIT_INCREMENTAL */ + AEGIS_API void aegis256_stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k) @@ -199,6 +203,8 @@ aegis256_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, cons implementation_256->decrypt_unauthenticated(m, c, clen, npub, k); } +#ifndef AEGIS_OMIT_MAC_API + AEGIS_API void aegis256_mac_init(aegis256_mac_state *st_, const uint8_t *k, const uint8_t *npub) @@ -257,27 +263,29 @@ aegis256_mac_state_clone(aegis256_mac_state *dst, const aegis256_mac_state *src) implementation_256->state_mac_clone(dst, src); } +#endif /* AEGIS_OMIT_MAC_API */ + AEGIS_PRIVATE int aegis256_pick_best_implementation(void) { implementation_256 = &aegis256_soft_implementation; -#if defined(__aarch64__) || defined(_M_ARM64) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON if (aegis_runtime_has_armcrypto()) { implementation_256 = &aegis256_armcrypto_implementation; return 0; } #endif -#if defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI if (aegis_runtime_has_aesni() && aegis_runtime_has_avx()) { implementation_256 = &aegis256_aesni_implementation; return 0; } #endif -#if defined(__ALTIVEC__) && defined(__CRYPTO__) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC if (aegis_runtime_has_altivec()) { implementation_256 = &aegis256_altivec_implementation; return 0; diff --git a/src/aegis/aegis256/aegis256_aesni.c b/src/aegis/aegis256/aegis256_aesni.c index bc93de2..bfd9f4f 100644 --- a/src/aegis/aegis256/aegis256_aesni.c +++ b/src/aegis/aegis256/aegis256_aesni.c @@ -93,7 +93,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256_common.h" struct aegis256_implementation aegis256_aesni_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256/aegis256_altivec.c b/src/aegis/aegis256/aegis256_altivec.c index 18200c1..aa20f50 100644 --- a/src/aegis/aegis256/aegis256_altivec.c +++ b/src/aegis/aegis256/aegis256_altivec.c @@ -91,7 +91,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256_common.h" struct aegis256_implementation aegis256_altivec_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256/aegis256_armcrypto.c b/src/aegis/aegis256/aegis256_armcrypto.c index 83d8cc3..33d2d2c 100644 --- a/src/aegis/aegis256/aegis256_armcrypto.c +++ b/src/aegis/aegis256/aegis256_armcrypto.c @@ -105,7 +105,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256_common.h" struct aegis256_implementation aegis256_armcrypto_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256/aegis256_common.h b/src/aegis/aegis256/aegis256_common.h index d6f0cb8..f35538e 100644 --- a/src/aegis/aegis256/aegis256_common.h +++ b/src/aegis/aegis256/aegis256_common.h @@ -310,6 +310,8 @@ typedef struct AEGIS_MAC_STATE { size_t pos; } AEGIS_MAC_STATE; +#ifndef AEGIS_OMIT_INCREMENTAL + static void AEGIS_state_init(aegis256_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k) @@ -580,6 +582,10 @@ AEGIS_state_decrypt_detached_final(aegis256_state *st_, uint8_t *m, size_t mlen_ return ret; } +#endif /* AEGIS_OMIT_INCREMENTAL */ + +#ifndef AEGIS_OMIT_MAC_API + static void AEGIS_state_mac_init(aegis256_mac_state *st_, const uint8_t *npub, const uint8_t *k) { @@ -693,6 +699,8 @@ AEGIS_state_mac_clone(aegis256_mac_state *dst, const aegis256_mac_state *src) *dst_ = *src_; } +#endif /* AEGIS_OMIT_MAC_API */ + #undef AEGIS_RATE #undef AEGIS_ALIGNMENT diff --git a/src/aegis/aegis256/aegis256_soft.c b/src/aegis/aegis256/aegis256_soft.c index 1a35a2e..5572979 100644 --- a/src/aegis/aegis256/aegis256_soft.c +++ b/src/aegis/aegis256/aegis256_soft.c @@ -84,7 +84,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256_common.h" struct aegis256_implementation aegis256_soft_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256/implementations.h b/src/aegis/aegis256/implementations.h index bc5b4c7..5be1388 100644 --- a/src/aegis/aegis256/implementations.h +++ b/src/aegis/aegis256/implementations.h @@ -24,6 +24,7 @@ typedef struct aegis256_implementation { const uint8_t *k); void (*decrypt_unauthenticated)(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_INCREMENTAL void (*state_init)(aegis256_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k); int (*state_encrypt_update)(aegis256_state *st_, uint8_t *c, size_t clen_max, size_t *written, @@ -36,11 +37,14 @@ typedef struct aegis256_implementation { size_t *written, const uint8_t *c, size_t clen); int (*state_decrypt_detached_final)(aegis256_state *st_, uint8_t *m, size_t mlen_max, size_t *written, const uint8_t *mac, size_t maclen); +#endif /* AEGIS_OMIT_INCREMENTAL */ +#ifndef AEGIS_OMIT_MAC_API void (*state_mac_init)(aegis256_mac_state *st_, const uint8_t *npub, const uint8_t *k); int (*state_mac_update)(aegis256_mac_state *st_, const uint8_t *ad, size_t adlen); int (*state_mac_final)(aegis256_mac_state *st_, uint8_t *mac, size_t maclen); void (*state_mac_reset)(aegis256_mac_state *st); void (*state_mac_clone)(aegis256_mac_state *dst, const aegis256_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ } aegis256_implementation; #endif /* AEGIS256_IMPLEMENTATIONS_H */ diff --git a/src/aegis/aegis256x2/aegis256x2.c b/src/aegis/aegis256x2/aegis256x2.c index 699a507..eb2a383 100644 --- a/src/aegis/aegis256x2/aegis256x2.c +++ b/src/aegis/aegis256x2/aegis256x2.c @@ -116,6 +116,8 @@ aegis256x2_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, con return ret; } +#ifndef AEGIS_OMIT_INCREMENTAL + AEGIS_API void aegis256x2_state_init(aegis256x2_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, @@ -177,6 +179,8 @@ aegis256x2_state_decrypt_detached_final(aegis256x2_state *st_, uint8_t *m, size_ return implementation_256x2->state_decrypt_detached_final(st_, m, mlen_max, written, mac, maclen); } +#endif /* AEGIS_OMIT_INCREMENTAL */ + AEGIS_API void aegis256x2_stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k) @@ -200,6 +204,8 @@ aegis256x2_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, co implementation_256x2->decrypt_unauthenticated(m, c, clen, npub, k); } +#ifndef AEGIS_OMIT_MAC_API + AEGIS_API void aegis256x2_mac_init(aegis256x2_mac_state *st_, const uint8_t *k, const uint8_t *npub) @@ -258,20 +264,22 @@ aegis256x2_mac_state_clone(aegis256x2_mac_state *dst, const aegis256x2_mac_state implementation_256x2->state_mac_clone(dst, src); } +#endif /* AEGIS_OMIT_MAC_API */ + AEGIS_PRIVATE int aegis256x2_pick_best_implementation(void) { implementation_256x2 = &aegis256x2_soft_implementation; -#if defined(__aarch64__) || defined(_M_ARM64) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON if (aegis_runtime_has_armcrypto()) { implementation_256x2 = &aegis256x2_armcrypto_implementation; return 0; } #endif -#if defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI # ifdef HAVE_VAESINTRIN_H if (aegis_runtime_has_vaes() && aegis_runtime_has_avx2()) { implementation_256x2 = &aegis256x2_avx2_implementation; @@ -284,7 +292,7 @@ aegis256x2_pick_best_implementation(void) } #endif -#if defined(__ALTIVEC__) && defined(__CRYPTO__) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC if (aegis_runtime_has_altivec()) { implementation_256x2 = &aegis256x2_altivec_implementation; return 0; diff --git a/src/aegis/aegis256x2/aegis256x2_aesni.c b/src/aegis/aegis256x2/aegis256x2_aesni.c index 46e36d9..88b00f3 100644 --- a/src/aegis/aegis256x2/aegis256x2_aesni.c +++ b/src/aegis/aegis256x2/aegis256x2_aesni.c @@ -98,7 +98,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x2_common.h" struct aegis256x2_implementation aegis256x2_aesni_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x2/aegis256x2_altivec.c b/src/aegis/aegis256x2/aegis256x2_altivec.c index cb8093b..1eba181 100644 --- a/src/aegis/aegis256x2/aegis256x2_altivec.c +++ b/src/aegis/aegis256x2/aegis256x2_altivec.c @@ -97,7 +97,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x2_common.h" struct aegis256x2_implementation aegis256x2_altivec_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x2/aegis256x2_armcrypto.c b/src/aegis/aegis256x2/aegis256x2_armcrypto.c index 45e1290..1c03883 100644 --- a/src/aegis/aegis256x2/aegis256x2_armcrypto.c +++ b/src/aegis/aegis256x2/aegis256x2_armcrypto.c @@ -110,7 +110,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x2_common.h" struct aegis256x2_implementation aegis256x2_armcrypto_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x2/aegis256x2_avx2.c b/src/aegis/aegis256x2/aegis256x2_avx2.c index f2d3b82..76003cf 100644 --- a/src/aegis/aegis256x2/aegis256x2_avx2.c +++ b/src/aegis/aegis256x2/aegis256x2_avx2.c @@ -93,7 +93,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x2_common.h" struct aegis256x2_implementation aegis256x2_avx2_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x2/aegis256x2_common.h b/src/aegis/aegis256x2/aegis256x2_common.h index e2de9ce..7f13488 100644 --- a/src/aegis/aegis256x2/aegis256x2_common.h +++ b/src/aegis/aegis256x2/aegis256x2_common.h @@ -428,6 +428,8 @@ typedef struct AEGIS_MAC_STATE { size_t pos; } AEGIS_MAC_STATE; +#ifndef AEGIS_OMIT_INCREMENTAL + static void AEGIS_state_init(aegis256x2_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k) @@ -696,6 +698,10 @@ AEGIS_state_decrypt_detached_final(aegis256x2_state *st_, uint8_t *m, size_t mle return ret; } +#endif /* AEGIS_OMIT_INCREMENTAL */ + +#ifndef AEGIS_OMIT_MAC_API + static void AEGIS_state_mac_init(aegis256x2_mac_state *st_, const uint8_t *npub, const uint8_t *k) { @@ -809,6 +815,8 @@ AEGIS_state_mac_clone(aegis256x2_mac_state *dst, const aegis256x2_mac_state *src *dst_ = *src_; } +#endif /* AEGIS_OMIT_MAC_API */ + #undef AEGIS_RATE #undef AEGIS_ALIGNMENT diff --git a/src/aegis/aegis256x2/aegis256x2_soft.c b/src/aegis/aegis256x2/aegis256x2_soft.c index 48d3acd..70ecea1 100644 --- a/src/aegis/aegis256x2/aegis256x2_soft.c +++ b/src/aegis/aegis256x2/aegis256x2_soft.c @@ -88,7 +88,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x2_common.h" struct aegis256x2_implementation aegis256x2_soft_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x2/implementations.h b/src/aegis/aegis256x2/implementations.h index 9dbc277..963485d 100644 --- a/src/aegis/aegis256x2/implementations.h +++ b/src/aegis/aegis256x2/implementations.h @@ -24,6 +24,7 @@ typedef struct aegis256x2_implementation { const uint8_t *k); void (*decrypt_unauthenticated)(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_INCREMENTAL void (*state_init)(aegis256x2_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k); int (*state_encrypt_update)(aegis256x2_state *st_, uint8_t *c, size_t clen_max, size_t *written, @@ -36,11 +37,14 @@ typedef struct aegis256x2_implementation { size_t *written, const uint8_t *c, size_t clen); int (*state_decrypt_detached_final)(aegis256x2_state *st_, uint8_t *m, size_t mlen_max, size_t *written, const uint8_t *mac, size_t maclen); +#endif /* AEGIS_OMIT_INCREMENTAL */ +#ifndef AEGIS_OMIT_MAC_API void (*state_mac_init)(aegis256x2_mac_state *st_, const uint8_t *npub, const uint8_t *k); int (*state_mac_update)(aegis256x2_mac_state *st_, const uint8_t *ad, size_t adlen); int (*state_mac_final)(aegis256x2_mac_state *st_, uint8_t *mac, size_t maclen); void (*state_mac_reset)(aegis256x2_mac_state *st); void (*state_mac_clone)(aegis256x2_mac_state *dst, const aegis256x2_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ } aegis256x2_implementation; #endif /* AEGIS256X2_IMPLEMENTATIONS_H */ diff --git a/src/aegis/aegis256x4/aegis256x4.c b/src/aegis/aegis256x4/aegis256x4.c index 587a7bb..0a00c92 100644 --- a/src/aegis/aegis256x4/aegis256x4.c +++ b/src/aegis/aegis256x4/aegis256x4.c @@ -23,7 +23,7 @@ #endif #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NONE -# include "aegis256x4_soft.h" +#include "aegis256x4_soft.h" static const aegis256x4_implementation *implementation_256x4 = &aegis256x4_soft_implementation; #elif HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON static const aegis256x4_implementation *implementation_256x4 = &aegis256x4_armcrypto_implementation; @@ -117,6 +117,8 @@ aegis256x4_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, con return ret; } +#ifndef AEGIS_OMIT_INCREMENTAL + AEGIS_API void aegis256x4_state_init(aegis256x4_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, @@ -178,6 +180,8 @@ aegis256x4_state_decrypt_detached_final(aegis256x4_state *st_, uint8_t *m, size_ return implementation_256x4->state_decrypt_detached_final(st_, m, mlen_max, written, mac, maclen); } +#endif /* AEGIS_OMIT_INCREMENTAL */ + AEGIS_API void aegis256x4_stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k) @@ -201,6 +205,8 @@ aegis256x4_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, co implementation_256x4->decrypt_unauthenticated(m, c, clen, npub, k); } +#ifndef AEGIS_OMIT_MAC_API + AEGIS_API void aegis256x4_mac_init(aegis256x4_mac_state *st_, const uint8_t *k, const uint8_t *npub) @@ -259,28 +265,30 @@ aegis256x4_mac_state_clone(aegis256x4_mac_state *dst, const aegis256x4_mac_state implementation_256x4->state_mac_clone(dst, src); } +#endif /* AEGIS_OMIT_MAC_API */ + AEGIS_PRIVATE int aegis256x4_pick_best_implementation(void) { implementation_256x4 = &aegis256x4_soft_implementation; -#if defined(__aarch64__) || defined(_M_ARM64) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON if (aegis_runtime_has_armcrypto()) { implementation_256x4 = &aegis256x4_armcrypto_implementation; return 0; } #endif -#if defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI # ifdef HAVE_VAESINTRIN_H if (aegis_runtime_has_vaes() && aegis_runtime_has_avx512f()) { implementation_256x4 = &aegis256x4_avx512_implementation; - //return 0; + return 0; } if (aegis_runtime_has_vaes() && aegis_runtime_has_avx2()) { implementation_256x4 = &aegis256x4_avx2_implementation; - //return 0; + return 0; } # endif if (aegis_runtime_has_aesni() && aegis_runtime_has_avx()) { @@ -289,7 +297,7 @@ aegis256x4_pick_best_implementation(void) } #endif -#if defined(__ALTIVEC__) && defined(__CRYPTO__) +#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC if (aegis_runtime_has_altivec()) { implementation_256x4 = &aegis256x4_altivec_implementation; return 0; diff --git a/src/aegis/aegis256x4/aegis256x4_aesni.c b/src/aegis/aegis256x4/aegis256x4_aesni.c index 4f6fdf5..8938dc2 100644 --- a/src/aegis/aegis256x4/aegis256x4_aesni.c +++ b/src/aegis/aegis256x4/aegis256x4_aesni.c @@ -107,7 +107,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x4_common.h" struct aegis256x4_implementation aegis256x4_aesni_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x4/aegis256x4_altivec.c b/src/aegis/aegis256x4/aegis256x4_altivec.c index e79785b..9523074 100644 --- a/src/aegis/aegis256x4/aegis256x4_altivec.c +++ b/src/aegis/aegis256x4/aegis256x4_altivec.c @@ -104,7 +104,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x4_common.h" struct aegis256x4_implementation aegis256x4_altivec_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x4/aegis256x4_armcrypto.c b/src/aegis/aegis256x4/aegis256x4_armcrypto.c index 93d29b8..79a0e7f 100644 --- a/src/aegis/aegis256x4/aegis256x4_armcrypto.c +++ b/src/aegis/aegis256x4/aegis256x4_armcrypto.c @@ -118,7 +118,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x4_common.h" struct aegis256x4_implementation aegis256x4_armcrypto_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x4/aegis256x4_avx2.c b/src/aegis/aegis256x4/aegis256x4_avx2.c index e3b3703..ea560b5 100644 --- a/src/aegis/aegis256x4/aegis256x4_avx2.c +++ b/src/aegis/aegis256x4/aegis256x4_avx2.c @@ -99,7 +99,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x4_common.h" struct aegis256x4_implementation aegis256x4_avx2_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x4/aegis256x4_avx512.c b/src/aegis/aegis256x4/aegis256x4_avx512.c index 957df16..5bfa21c 100644 --- a/src/aegis/aegis256x4/aegis256x4_avx512.c +++ b/src/aegis/aegis256x4/aegis256x4_avx512.c @@ -99,7 +99,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x4_common.h" struct aegis256x4_implementation aegis256x4_avx512_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x4/aegis256x4_common.h b/src/aegis/aegis256x4/aegis256x4_common.h index b95b57a..89f2ff5 100644 --- a/src/aegis/aegis256x4/aegis256x4_common.h +++ b/src/aegis/aegis256x4/aegis256x4_common.h @@ -447,6 +447,8 @@ typedef struct AEGIS_MAC_STATE { size_t pos; } AEGIS_MAC_STATE; +#ifndef AEGIS_OMIT_INCREMENTAL + static void AEGIS_state_init(aegis256x4_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k) @@ -715,6 +717,10 @@ AEGIS_state_decrypt_detached_final(aegis256x4_state *st_, uint8_t *m, size_t mle return ret; } +#endif /* AEGIS_OMIT_INCREMENTAL */ + +#ifndef AEGIS_OMIT_MAC_API + static void AEGIS_state_mac_init(aegis256x4_mac_state *st_, const uint8_t *npub, const uint8_t *k) { @@ -828,6 +834,8 @@ AEGIS_state_mac_clone(aegis256x4_mac_state *dst, const aegis256x4_mac_state *src *dst_ = *src_; } +#endif /* AEGIS_OMIT_MAC_API */ + #undef AEGIS_RATE #undef AEGIS_ALIGNMENT diff --git a/src/aegis/aegis256x4/aegis256x4_soft.c b/src/aegis/aegis256x4/aegis256x4_soft.c index d21ab3f..7635665 100644 --- a/src/aegis/aegis256x4/aegis256x4_soft.c +++ b/src/aegis/aegis256x4/aegis256x4_soft.c @@ -97,7 +97,7 @@ AEGIS_update(AEGIS_AES_BLOCK_T *const state, const AEGIS_AES_BLOCK_T d) #include "aegis256x4_common.h" struct aegis256x4_implementation aegis256x4_soft_implementation = { - AEGIS_API_IMPL_LIST +#include "../common/func_table.h" }; #include "../common/type_names_undefine.h" diff --git a/src/aegis/aegis256x4/implementations.h b/src/aegis/aegis256x4/implementations.h index f2d6cc3..b420d29 100644 --- a/src/aegis/aegis256x4/implementations.h +++ b/src/aegis/aegis256x4/implementations.h @@ -24,6 +24,7 @@ typedef struct aegis256x4_implementation { const uint8_t *k); void (*decrypt_unauthenticated)(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_INCREMENTAL void (*state_init)(aegis256x4_state *st_, const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k); int (*state_encrypt_update)(aegis256x4_state *st_, uint8_t *c, size_t clen_max, size_t *written, @@ -36,11 +37,14 @@ typedef struct aegis256x4_implementation { size_t *written, const uint8_t *c, size_t clen); int (*state_decrypt_detached_final)(aegis256x4_state *st_, uint8_t *m, size_t mlen_max, size_t *written, const uint8_t *mac, size_t maclen); +#endif /* AEGIS_OMIT_INCREMENTAL */ +#ifndef AEGIS_OMIT_MAC_API void (*state_mac_init)(aegis256x4_mac_state *st_, const uint8_t *npub, const uint8_t *k); int (*state_mac_update)(aegis256x4_mac_state *st_, const uint8_t *ad, size_t adlen); int (*state_mac_final)(aegis256x4_mac_state *st_, uint8_t *mac, size_t maclen); void (*state_mac_reset)(aegis256x4_mac_state *st); void (*state_mac_clone)(aegis256x4_mac_state *dst, const aegis256x4_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ } aegis256x4_implementation; #endif /* AEGIS256X4_IMPLEMENTATIONS_H */ diff --git a/src/aegis/common/common.h b/src/aegis/common/common.h index 91f4dfb..b63af55 100644 --- a/src/aegis/common/common.h +++ b/src/aegis/common/common.h @@ -114,6 +114,27 @@ aegis_rotl32(const uint32_t x, const int b) #define AEGIS_CONCAT_(A,B) A##B #define AEGIS_FUNC(name) AEGIS_CONCAT(AEGIS_FUNC_PREFIX,AEGIS_CONCAT(_,name)) +#define AEGIS_API_IMPL_LIST_STD \ + .encrypt_detached = AEGIS_encrypt_detached, \ + .decrypt_detached = AEGIS_decrypt_detached, \ + .encrypt_unauthenticated = AEGIS_encrypt_unauthenticated, \ + .decrypt_unauthenticated = AEGIS_decrypt_unauthenticated, \ + .stream = AEGIS_stream, +#define AEGIS_API_IMPL_LIST_INC \ + .state_init = AEGIS_state_init, \ + .state_encrypt_update = AEGIS_state_encrypt_update, \ + .state_encrypt_detached_final = AEGIS_state_encrypt_detached_final, \ + .state_encrypt_final = AEGIS_state_encrypt_final, \ + .state_decrypt_detached_update = AEGIS_state_decrypt_detached_update, \ + .state_decrypt_detached_final = AEGIS_state_decrypt_detached_final, +#define AEGIS_API_IMPL_LIST_MAC \ + .state_mac_init = AEGIS_state_mac_init, \ + .state_mac_update = AEGIS_state_mac_update, \ + .state_mac_final = AEGIS_state_mac_final, \ + .state_mac_reset = AEGIS_state_mac_reset, \ + .state_mac_clone = AEGIS_state_mac_clone, + +#if 0 #define AEGIS_API_IMPL_LIST \ .encrypt_detached = AEGIS_encrypt_detached, \ .decrypt_detached = AEGIS_decrypt_detached, \ @@ -131,5 +152,6 @@ aegis_rotl32(const uint32_t x, const int b) .state_mac_final = AEGIS_state_mac_final, \ .state_mac_reset = AEGIS_state_mac_reset, \ .state_mac_clone = AEGIS_state_mac_clone, +#endif #endif /* AEGIS_COMMON_H */ diff --git a/src/aegis/common/func_table.h b/src/aegis/common/func_table.h new file mode 100644 index 0000000..d4d73b0 --- /dev/null +++ b/src/aegis/common/func_table.h @@ -0,0 +1,21 @@ +/* +** Name: func_table.h +** Purpose: Table of AEGIS API function implementations +** Copyright: (c) 2023-2024 Frank Denis +** SPDX-License-Identifier: MIT +*/ + +/* +** NOTE: +** Do NOT use include guards, because including this header +** multiple times is intended behaviour. +*/ + +AEGIS_API_IMPL_LIST_STD +#ifndef AEGIS_OMIT_INCREMENTAL +AEGIS_API_IMPL_LIST_INC +#endif +#ifndef AEGIS_OMIT_MAC_API +AEGIS_API_IMPL_LIST_MAC +#endif + diff --git a/src/aegis/include/aegis128l.h b/src/aegis/include/aegis128l.h index 39aa88f..155218f 100644 --- a/src/aegis/include/aegis128l.h +++ b/src/aegis/include/aegis128l.h @@ -140,6 +140,8 @@ int aegis128l_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, size_t adlen, const uint8_t *npub, const uint8_t *k) __attribute__((warn_unused_result)); +#ifndef AEGIS_OMIT_INCREMENTAL + /* * Initialize a state for incremental encryption or decryption. * @@ -238,6 +240,8 @@ int aegis128l_state_decrypt_detached_final(aegis128l_state *st_, uint8_t *m, siz size_t *written, const uint8_t *mac, size_t maclen) __attribute__((warn_unused_result)); +#endif /* AEGIS_OMIT_INCREMENTAL */ + /* * Return a deterministic pseudo-random byte sequence. * @@ -282,6 +286,8 @@ AEGIS_API void aegis128l_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_MAC_API + /* * Initialize a state for generating a MAC. * @@ -356,6 +362,8 @@ void aegis128l_mac_reset(aegis128l_mac_state *st_); AEGIS_API void aegis128l_mac_state_clone(aegis128l_mac_state *dst, const aegis128l_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ + #ifdef __cplusplus } #endif diff --git a/src/aegis/include/aegis128x2.h b/src/aegis/include/aegis128x2.h index e2144d3..898af84 100644 --- a/src/aegis/include/aegis128x2.h +++ b/src/aegis/include/aegis128x2.h @@ -139,6 +139,8 @@ int aegis128x2_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, size_t adlen, const uint8_t *npub, const uint8_t *k) __attribute__((warn_unused_result)); +#ifndef AEGIS_OMIT_INCREMENTAL + /* * Initialize a state for incremental encryption or decryption. * @@ -237,6 +239,8 @@ int aegis128x2_state_decrypt_detached_final(aegis128x2_state *st_, uint8_t *m, s size_t *written, const uint8_t *mac, size_t maclen) __attribute__((warn_unused_result)); +#endif /* AEGIS_OMIT_INCREMENTAL */ + /* * Return a deterministic pseudo-random byte sequence. * @@ -281,6 +285,8 @@ AEGIS_API void aegis128x2_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_MAC_API + /* * Initialize a state for generating a MAC. * @@ -355,6 +361,8 @@ void aegis128x2_mac_reset(aegis128x2_mac_state *st_); AEGIS_API void aegis128x2_mac_state_clone(aegis128x2_mac_state *dst, const aegis128x2_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ + #ifdef __cplusplus } #endif diff --git a/src/aegis/include/aegis128x4.h b/src/aegis/include/aegis128x4.h index ee27e1c..779b4a9 100644 --- a/src/aegis/include/aegis128x4.h +++ b/src/aegis/include/aegis128x4.h @@ -140,6 +140,8 @@ int aegis128x4_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, size_t adlen, const uint8_t *npub, const uint8_t *k) __attribute__((warn_unused_result)); +#ifndef AEGIS_OMIT_INCREMENTAL + /* * Initialize a state for incremental encryption or decryption. * @@ -238,6 +240,8 @@ int aegis128x4_state_decrypt_detached_final(aegis128x4_state *st_, uint8_t *m, s size_t *written, const uint8_t *mac, size_t maclen) __attribute__((warn_unused_result)); +#endif /* AEGIS_OMIT_INCREMENTAL */ + /* * Return a deterministic pseudo-random byte sequence. * @@ -282,6 +286,8 @@ AEGIS_API void aegis128x4_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_MAC_API + /* * Initialize a state for generating a MAC. * @@ -356,6 +362,8 @@ void aegis128x4_mac_reset(aegis128x4_mac_state *st_); AEGIS_API void aegis128x4_mac_state_clone(aegis128x4_mac_state *dst, const aegis128x4_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ + #ifdef __cplusplus } #endif diff --git a/src/aegis/include/aegis256.h b/src/aegis/include/aegis256.h index bf2b230..af45512 100644 --- a/src/aegis/include/aegis256.h +++ b/src/aegis/include/aegis256.h @@ -139,6 +139,8 @@ int aegis256_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, c size_t adlen, const uint8_t *npub, const uint8_t *k) __attribute__((warn_unused_result)); +#ifndef AEGIS_OMIT_INCREMENTAL + /* * Initialize a state for incremental encryption or decryption. * @@ -237,6 +239,8 @@ int aegis256_state_decrypt_detached_final(aegis256_state *st_, uint8_t *m, size_ size_t *written, const uint8_t *mac, size_t maclen) __attribute__((warn_unused_result)); +#endif /* AEGIS_OMIT_INCREMENTAL */ + /* * Return a deterministic pseudo-random byte sequence. * @@ -281,6 +285,8 @@ AEGIS_API void aegis256_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_MAC_API + /* * Initialize a state for generating a MAC. * @@ -355,6 +361,8 @@ void aegis256_mac_reset(aegis256_mac_state *st_); AEGIS_API void aegis256_mac_state_clone(aegis256_mac_state *dst, const aegis256_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ + #ifdef __cplusplus } #endif diff --git a/src/aegis/include/aegis256x2.h b/src/aegis/include/aegis256x2.h index c5ba007..38aa108 100644 --- a/src/aegis/include/aegis256x2.h +++ b/src/aegis/include/aegis256x2.h @@ -139,6 +139,8 @@ int aegis256x2_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, size_t adlen, const uint8_t *npub, const uint8_t *k) __attribute__((warn_unused_result)); +#ifndef AEGIS_OMIT_INCREMENTAL + /* * Initialize a state for incremental encryption or decryption. * @@ -237,6 +239,8 @@ int aegis256x2_state_decrypt_detached_final(aegis256x2_state *st_, uint8_t *m, s size_t *written, const uint8_t *mac, size_t maclen) __attribute__((warn_unused_result)); +#endif /* AEGIS_OMIT_INCREMENTAL */ + /* * Return a deterministic pseudo-random byte sequence. * @@ -281,6 +285,8 @@ AEGIS_API void aegis256x2_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_MAC_API + /* * Initialize a state for generating a MAC. * @@ -355,6 +361,8 @@ void aegis256x2_mac_reset(aegis256x2_mac_state *st_); AEGIS_API void aegis256x2_mac_state_clone(aegis256x2_mac_state *dst, const aegis256x2_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ + #ifdef __cplusplus } #endif diff --git a/src/aegis/include/aegis256x4.h b/src/aegis/include/aegis256x4.h index faa857f..1de793c 100644 --- a/src/aegis/include/aegis256x4.h +++ b/src/aegis/include/aegis256x4.h @@ -139,6 +139,8 @@ int aegis256x4_decrypt(uint8_t *m, const uint8_t *c, size_t clen, size_t maclen, size_t adlen, const uint8_t *npub, const uint8_t *k) __attribute__((warn_unused_result)); +#ifndef AEGIS_OMIT_INCREMENTAL + /* * Initialize a state for incremental encryption or decryption. * @@ -237,6 +239,8 @@ int aegis256x4_state_decrypt_detached_final(aegis256x4_state *st_, uint8_t *m, s size_t *written, const uint8_t *mac, size_t maclen) __attribute__((warn_unused_result)); +#endif /* AEGIS_OMIT_INCREMENTAL */ + /* * Return a deterministic pseudo-random byte sequence. * @@ -281,6 +285,8 @@ AEGIS_API void aegis256x4_decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub, const uint8_t *k); +#ifndef AEGIS_OMIT_MAC_API + /* * Initialize a state for generating a MAC. * @@ -355,6 +361,8 @@ void aegis256x4_mac_reset(aegis256x4_mac_state *st_); AEGIS_API void aegis256x4_mac_state_clone(aegis256x4_mac_state *dst, const aegis256x4_mac_state *src); +#endif /* AEGIS_OMIT_MAC_API */ + #ifdef __cplusplus } #endif diff --git a/src/argon2/src/thread.h b/src/argon2/src/thread.h index d56dc98..227f591 100644 --- a/src/argon2/src/thread.h +++ b/src/argon2/src/thread.h @@ -21,7 +21,7 @@ #if !defined(ARGON2_NO_THREADS) /* - Here we implement an abstraction layer for the simpĺe requirements + Here we implement an abstraction layer for the simple requirements of the Argon2 code. We only require 3 primitives---thread creation, joining, and termination---so full emulation of the pthreads API is unwarranted. Currently we wrap pthreads and Win32 threads. diff --git a/src/carray.c b/src/carray.c index 28806d5..df8c6b2 100644 --- a/src/carray.c +++ b/src/carray.c @@ -76,14 +76,6 @@ SQLITE_EXTENSION_INIT1 # define CARRAY_BLOB 4 /* Data is struct iovec* */ #endif -#ifndef SQLITE_API -# ifdef _WIN32 -# define SQLITE_API __declspec(dllexport) -# else -# define SQLITE_API -# endif -#endif - #ifndef SQLITE_OMIT_VIRTUALTABLE /* @@ -541,7 +533,11 @@ static void inttoptrFunc( #endif /* SQLITE_OMIT_VIRTUALTABLE */ -SQLITE_API int sqlite3_carray_init( +#ifndef SQLITE_API +#define SQLITE_API +#endif +SQLITE_API +int sqlite3_carray_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi diff --git a/src/compress.c b/src/compress.c index 302fc7c..3fdf285 100644 --- a/src/compress.c +++ b/src/compress.c @@ -107,10 +107,10 @@ static void uncompressFunc( } } - -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_compress_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/csv.c b/src/csv.c index f9b5dc5..78024a1 100644 --- a/src/csv.c +++ b/src/csv.c @@ -944,16 +944,15 @@ static sqlite3_module CsvModuleFauxWrite = { #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif +#ifndef SQLITE_API +#define SQLITE_API #endif /* ** This routine is called when the extension is loaded. The new ** CSV virtual table module is registered with the calling database ** connection. */ +SQLITE_API int sqlite3_csv_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/fileio.c b/src/fileio.c index 4cc4b9f..d0aa5ee 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1008,9 +1008,10 @@ static int fsdirRegister(sqlite3 *db){ # define fsdirRegister(x) SQLITE_OK #endif -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_fileio_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/regexp.c b/src/regexp.c index 1826649..8e20e6d 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -844,14 +844,14 @@ static void re_bytecode_func( #endif /* SQLITE_DEBUG */ - /* ** Invoke this routine to register the regexp() function with the ** SQLite database connection. */ -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_regexp_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/series.c b/src/series.c index aff9796..694f78e 100644 --- a/src/series.c +++ b/src/series.c @@ -819,9 +819,10 @@ static sqlite3_module seriesModule = { #endif /* SQLITE_OMIT_VIRTUALTABLE */ -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_series_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/shathree.c b/src/shathree.c index b03d107..bd9baa5 100644 --- a/src/shathree.c +++ b/src/shathree.c @@ -809,11 +809,10 @@ static void sha3AggFinal(sqlite3_context *context){ } } - - -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_shathree_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/sqlar.c b/src/sqlar.c index 53a1078..84eff30 100644 --- a/src/sqlar.c +++ b/src/sqlar.c @@ -103,9 +103,10 @@ static void sqlarUncompressFunc( } } -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_sqlar_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/sqlite3mc.c b/src/sqlite3mc.c index 970357a..2ab8a22 100644 --- a/src/sqlite3mc.c +++ b/src/sqlite3mc.c @@ -17,7 +17,6 @@ #ifdef SQLITE_USER_AUTHENTICATION #undef SQLITE_USER_AUTHENTICATION #endif -#define SQLITE_USER_AUTHENTICATION 0 /* Disable AES hardware support */ /* Note: this may be changed in the future depending on available support */ @@ -75,11 +74,9 @@ SQLITE_PRIVATE void sqlite3mc_shutdown(void); ** Disable the user authentication feature by default */ #ifdef SQLITE_USER_AUTHENTICATION -#if !SQLITE_USER_AUTHENTICATION /* Option defined and disabled, therefore undefine option */ #undef SQLITE_USER_AUTHENTICATION #endif -#endif #if defined(_WIN32) || defined(WIN32) @@ -194,10 +191,6 @@ SQLITE_PRIVATE void chacha20_rng(void* out, size_t n); #include "chacha20poly1305.c" #endif -#ifdef SQLITE_USER_AUTHENTICATION -#include "userauth.c" -#endif - /* ** Declare function prototype for registering the codec extension functions */ @@ -212,6 +205,12 @@ mcRegisterCodecExtensions(sqlite3* db, char** pzErrMsg, const sqlite3_api_routin #endif #if HAVE_CIPHER_AEGIS + +/* Incremental encryption/decryption not needed */ +#define AEGIS_OMIT_INCREMENTAL +/* API for generating MAC not needed */ +#define AEGIS_OMIT_MAC_API + #include "aegis/libaegis.c" #include "argon2/libargon2.c" #endif @@ -249,11 +248,7 @@ int RegisterExtensionFunctions(sqlite3* db); */ #ifdef SQLITE_ENABLE_CSV /* Prototype for initialization function of CSV extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_csv_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "csv.c" #endif @@ -263,11 +258,7 @@ int sqlite3_csv_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* p */ #ifdef SQLITE_ENABLE_VSV /* Prototype for initialization function of VSV extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_vsv_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "vsv.c" #endif @@ -277,11 +268,7 @@ int sqlite3_vsv_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* p */ #ifdef SQLITE_ENABLE_SHA3 /* Prototype for initialization function of SHA3 extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_shathree_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "shathree.c" #endif @@ -291,11 +278,7 @@ int sqlite3_shathree_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routin */ #ifdef SQLITE_ENABLE_CARRAY /* Prototype for initialization function of CARRAY extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_carray_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "carray.c" #endif @@ -305,11 +288,7 @@ int sqlite3_carray_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines */ #ifdef SQLITE_ENABLE_FILEIO /* Prototype for initialization function of FILEIO extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_fileio_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); /* MinGW specifics */ @@ -333,11 +312,7 @@ int sqlite3_fileio_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines */ #ifdef SQLITE_ENABLE_SERIES /* Prototype for initialization function of SERIES extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_series_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "series.c" #endif @@ -347,11 +322,7 @@ int sqlite3_series_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines */ #ifdef SQLITE_ENABLE_UUID /* Prototype for initialization function of UUID extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_uuid_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "uuid.c" #endif @@ -361,11 +332,7 @@ int sqlite3_uuid_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* */ #ifdef SQLITE_ENABLE_REGEXP /* Prototype for initialization function of REGEXP extension */ -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_regexp_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi); #include "regexp.c" #endif @@ -380,11 +347,7 @@ int sqlite3_regexp_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines ** COMPRESS */ #ifdef SQLITE_ENABLE_COMPRESS -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_compress_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi); #include "compress.c" #endif @@ -393,11 +356,7 @@ int sqlite3_compress_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routin ** SQLAR */ #ifdef SQLITE_ENABLE_SQLAR -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_sqlar_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi); #include "sqlar.c" #endif @@ -406,11 +365,7 @@ int sqlite3_sqlar_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines ** ZIPFILE */ #ifdef SQLITE_ENABLE_ZIPFILE -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif -#endif +SQLITE_API int sqlite3_zipfile_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi); #include "zipfile.c" #endif diff --git a/src/sqlite3mc.h b/src/sqlite3mc.h index 56d2e9d..f0d3980 100644 --- a/src/sqlite3mc.h +++ b/src/sqlite3mc.h @@ -21,7 +21,7 @@ #include "sqlite3.h" #ifdef SQLITE_USER_AUTHENTICATION -#include "sqlite3userauth.h" +#undef SQLITE_USER_AUTHENTICATION #endif /* diff --git a/src/sqlite3mc_version.h b/src/sqlite3mc_version.h index 2559c05..0c91726 100644 --- a/src/sqlite3mc_version.h +++ b/src/sqlite3mc_version.h @@ -12,10 +12,10 @@ #ifndef SQLITE3MC_VERSION_H_ #define SQLITE3MC_VERSION_H_ -#define SQLITE3MC_VERSION_MAJOR 1 -#define SQLITE3MC_VERSION_MINOR 9 -#define SQLITE3MC_VERSION_RELEASE 2 +#define SQLITE3MC_VERSION_MAJOR 2 +#define SQLITE3MC_VERSION_MINOR 0 +#define SQLITE3MC_VERSION_RELEASE 0 #define SQLITE3MC_VERSION_SUBRELEASE 0 -#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.9.2" +#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 2.0.0" #endif /* SQLITE3MC_VERSION_H_ */ diff --git a/src/uuid.c b/src/uuid.c index 7272672..9cc2b74 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -206,11 +206,10 @@ static void sqlite3UuidBlobFunc( sqlite3_result_blob(context, pBlob, 16, SQLITE_TRANSIENT); } -#if 0 -#ifdef _WIN32 -__declspec(dllexport) -#endif +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_uuid_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/vsv.c b/src/vsv.c index 5de25ec..3af6830 100644 --- a/src/vsv.c +++ b/src/vsv.c @@ -2003,11 +2003,10 @@ static sqlite3_module VsvModuleFauxWrite = { ** VSV virtual table module is registered with the calling database ** connection. */ -#ifndef SQLITE_CORE -#ifdef _WIN32 -__declspec(dllexport) -#endif +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_vsv_init( sqlite3 *db, char **pzErrMsg, diff --git a/src/zipfile.c b/src/zipfile.c index d15277a..18f2e0f 100644 --- a/src/zipfile.c +++ b/src/zipfile.c @@ -2232,9 +2232,10 @@ static int zipfileRegister(sqlite3 *db){ # define zipfileRegister(x) SQLITE_OK #endif -#ifdef _WIN32 -__declspec(dllexport) +#ifndef SQLITE_API +#define SQLITE_API #endif +SQLITE_API int sqlite3_zipfile_init( sqlite3 *db, char **pzErrMsg,