Build botan with ExternalProject and without amalgamation
All checks were successful
/ Build the server (push) Successful in 3m4s

This commit is contained in:
Mutzi 2023-10-23 18:30:35 +02:00
parent 13579acd8f
commit 023ef2ec49
Signed by: root
GPG Key ID: 2437494E09F13876
11 changed files with 52 additions and 16 deletions

View File

@ -9,7 +9,7 @@
#ifndef BOTAN_ASIO_ASYNC_OPS_H_ #ifndef BOTAN_ASIO_ASYNC_OPS_H_
#define BOTAN_ASIO_ASYNC_OPS_H_ #define BOTAN_ASIO_ASYNC_OPS_H_
#include <botan_all.h> #include <botan/types.h>
#include <asio.hpp> #include <asio.hpp>
#include <asio/yield.hpp> #include <asio/yield.hpp>
#include "asio_error.h" #include "asio_error.h"

View File

@ -9,7 +9,13 @@
#ifndef BOTAN_ASIO_TLS_CONTEXT_H_ #ifndef BOTAN_ASIO_TLS_CONTEXT_H_
#define BOTAN_ASIO_TLS_CONTEXT_H_ #define BOTAN_ASIO_TLS_CONTEXT_H_
#include <botan_all.h> #include <botan/credentials_manager.h>
#include <botan/ocsp.h>
#include <botan/rng.h>
#include <botan/tls_callbacks.h>
#include <botan/tls_policy.h>
#include <botan/tls_server_info.h>
#include <botan/tls_session_manager.h>
#include <functional> #include <functional>
namespace Botan::TLS { namespace Botan::TLS {

View File

@ -9,7 +9,9 @@
#ifndef BOTAN_ASIO_ERROR_H_ #ifndef BOTAN_ASIO_ERROR_H_
#define BOTAN_ASIO_ERROR_H_ #define BOTAN_ASIO_ERROR_H_
#include <botan_all.h> #include <botan/exceptn.h>
#include <botan/tls_alert.h>
#include <botan/tls_exceptn.h>
#include <asio/error_code.hpp> #include <asio/error_code.hpp>
namespace boost{ namespace boost{

View File

@ -9,7 +9,11 @@
#ifndef BOTAN_ASIO_STREAM_H_ #ifndef BOTAN_ASIO_STREAM_H_
#define BOTAN_ASIO_STREAM_H_ #define BOTAN_ASIO_STREAM_H_
#include <botan_all.h> #include <botan/tls_callbacks.h>
#include <botan/tls_channel.h>
#include <botan/tls_client.h>
#include <botan/tls_magic.h>
#include <botan/tls_server.h>
#include <asio.hpp> #include <asio.hpp>
#include "asio_async_ops.h" #include "asio_async_ops.h"

View File

@ -1,13 +1,23 @@
# TODO: repo with dependencies, ExternalProject_Add(), FetchContent
add_subdirectory(spdlog-1.12.0) add_subdirectory(spdlog-1.12.0)
add_subdirectory(restbed-4.8) add_subdirectory(restbed-4.8)
add_custom_command( include(ExternalProject)
COMMAND ./configure.py ARGS --amalgamation --disable-shared --minimized-build --enable-modules=argon2fmt,hotp,base32,auto_rng,system_rng,tls13,certstor_system,certstor_flatfile,md5 ExternalProject_Add(project_botan
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0/botan_all.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0/botan_all.h PREFIX ${CMAKE_CURRENT_BINARY_DIR}/botan
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0/configure.py --with-build-dir=<BINARY_DIR> --prefix=<INSTALL_DIR> --disable-shared --minimized-build --build-targets=static --without-sphinx --without-rst2man --enable-modules=argon2fmt,hotp,base32,auto_rng,system_rng,tls13,certstor_system,certstor_flatfile,md5
BUILD_COMMAND make -j libs
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/botan/lib/libbotan-3.a"
INSTALL_COMMAND make install
USES_TERMINAL_BUILD YES
USES_TERMINAL_INSTALL YES
) )
add_library(botan STATIC Botan-3.2.0/botan_all.cpp Botan-3.2.0/botan_all.h) add_library(botan INTERFACE IMPORTED)
target_include_directories(botan PUBLIC Botan-3.2.0) target_link_libraries(botan INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/botan/lib/libbotan-3.a")
target_include_directories(botan INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/botan/include/botan-3")
add_dependencies(botan project_botan)
add_library(miniz STATIC miniz/miniz.c miniz/miniz.h) add_library(miniz STATIC miniz/miniz.c miniz/miniz.h)
target_include_directories(miniz PUBLIC miniz) target_include_directories(miniz PUBLIC miniz)

View File

@ -1,6 +1,7 @@
#include <memory> #include <memory>
#include <csignal> #include <csignal>
#include <botan_all.h> #include <botan/hash.h>
#include <botan/hex.h>
#include <corvusoft/restbed/request.hpp> #include <corvusoft/restbed/request.hpp>
#include <corvusoft/restbed/resource.hpp> #include <corvusoft/restbed/resource.hpp>
#include <corvusoft/restbed/session.hpp> #include <corvusoft/restbed/session.hpp>
@ -32,7 +33,7 @@ int main() {
{ {
auto md5_hash = Botan::HashFunction::create_or_throw("MD5"); auto md5_hash = Botan::HashFunction::create_or_throw("MD5");
md5_hash->update(index_html_bytes); md5_hash->update(index_html_bytes);
index_etag = Botan::hex_encode(md5_hash->final()); index_etag = "\"" + Botan::hex_encode(md5_hash->final()) + "\"";
} }
auto mrpc_resource = std::make_shared<restbed::Resource>(); auto mrpc_resource = std::make_shared<restbed::Resource>();

View File

@ -1,4 +1,7 @@
#include <botan_all.h> #include <botan/argon2fmt.h>
#include <botan/hex.h>
#include <botan/mac.h>
#include <botan/base32.h>
#include "server_internal.hxx" #include "server_internal.hxx"
std::string hash_password(const std::string &password) { std::string hash_password(const std::string &password) {

View File

@ -2,6 +2,7 @@
#include <fstream> #include <fstream>
#include <stack> #include <stack>
#include <unordered_set> #include <unordered_set>
#include <botan/base64.h>
#include "server_internal.hxx" #include "server_internal.hxx"
mrpc::Node node_to_node(const std::shared_ptr<Node>& node) { mrpc::Node node_to_node(const std::shared_ptr<Node>& node) {

View File

@ -1,6 +1,8 @@
#include <asio.hpp> #include <asio.hpp>
#include <botan_all.h>
#include <botan_asio/asio_stream.h> #include <botan_asio/asio_stream.h>
#include <botan/certstor_system.h>
#include <botan/tls_session_manager_noop.h>
#include <botan/base64.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include "server_internal.hxx" #include "server_internal.hxx"
@ -80,7 +82,11 @@ void Server::send_mail(const std::string &email, const std::string &title, const
asio::io_service ctx; asio::io_service ctx;
auto ssl_ctx = std::make_shared<Botan::TLS::Context>( auto ssl_ctx = std::make_shared<Botan::TLS::Context>(
std::make_shared<CredMan>(), std::make_shared<CredMan>(),
std::make_shared<Botan::AutoSeeded_RNG>(), #if defined(BOTAN_HAS_SYSTEM_RNG)
std::make_unique<Botan::System_RNG>(),
#else
std::make_unique<Botan::AutoSeeded_RNG>(),
#endif
std::make_shared<Botan::TLS::Session_Manager_Noop>(), std::make_shared<Botan::TLS::Session_Manager_Noop>(),
std::make_shared<Policy>() std::make_shared<Policy>()
); );

View File

@ -1,3 +1,4 @@
#include <botan/otp.h>
#include "server_internal.hxx" #include "server_internal.hxx"
std::shared_ptr<Token> Server::get_token(const std::string &token) { std::shared_ptr<Token> Server::get_token(const std::string &token) {

View File

@ -1,7 +1,7 @@
#ifndef FILESERVER_SERVER_INTERNAL_HXX #ifndef FILESERVER_SERVER_INTERNAL_HXX
#define FILESERVER_SERVER_INTERNAL_HXX #define FILESERVER_SERVER_INTERNAL_HXX
#include <botan_all.h> #include <botan/rng.h>
#include "server.hxx" #include "server.hxx"
// TODO log user action with __FUNC__ // TODO log user action with __FUNC__
@ -10,8 +10,10 @@
#define check_user_optional() check_user() return "Unauthorized" #define check_user_optional() check_user() return "Unauthorized"
#if defined(BOTAN_HAS_SYSTEM_RNG) #if defined(BOTAN_HAS_SYSTEM_RNG)
#include <botan/system_rng.h>
static std::unique_ptr<Botan::RNG> auth_rng = std::make_unique<Botan::System_RNG>(); static std::unique_ptr<Botan::RNG> auth_rng = std::make_unique<Botan::System_RNG>();
#else #else
#include <botan/auto_rng.h>
static std::unique_ptr<Botan::RNG> auth_rng = std::make_unique<Botan::AutoSeeded_RNG>(); static std::unique_ptr<Botan::RNG> auth_rng = std::make_unique<Botan::AutoSeeded_RNG>();
#endif #endif