diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..897542b9
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,4 @@
+---
+BasedOnStyle: Microsoft
+
+...
diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml
index 43d54318..3570e62b 100644
--- a/.github/workflows/build-native.yml
+++ b/.github/workflows/build-native.yml
@@ -9,7 +9,7 @@ jobs:
- name: Install build Dependencies
run: |
sudo apt update
- sudo apt install -y libjsoncpp-dev fakeroot libarchive-tools python3-apt zstd gettext
+ sudo apt install -y libpoco-dev libjsoncpp-dev fakeroot libarchive-tools python3-apt zstd gettext
curl "https://cdn.anotherfoxguy.com/makedeb/install-makedeb.sh" | sudo bash
- name: Install angelscript
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9464c6ee..4881505b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,16 +7,19 @@ include(FeatureSummary)
project(rorserver VERSION "2021.10")
+set(CMAKE_CXX_STANDARD 17)
+
# Options
set(ROR_DEPENDENCY_DIR "${CMAKE_SOURCE_DIR}/dependencies/build" CACHE PATH "Path to the dependencies")
set(CMAKE_PREFIX_PATH ${ROR_DEPENDENCY_DIR} ${CMAKE_PREFIX_PATH})
set(CMAKE_THREAD_PREFER_PTHREAD YES)
find_package(Threads REQUIRED)
-find_package(Angelscript)
+find_package(Poco REQUIRED COMPONENTS Foundation)
find_package(jsoncpp REQUIRED)
find_package(SocketW REQUIRED)
find_package(CURL)
+find_package(Angelscript)
cmake_dependent_option(RORSERVER_WITH_ANGELSCRIPT "Adds scripting support" ON "TARGET Angelscript::angelscript" OFF)
cmake_dependent_option(RORSERVER_WITH_CURL "Adds CURL request support (needs AngelScript)" ON "TARGET CURL::libcurl" OFF)
diff --git a/conanfile.py b/conanfile.py
index 2865c957..17a9983a 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -7,6 +7,10 @@ class RoRServer(ConanFile):
name = "RoRServer"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
+ default_options = {
+ "poco*:enable_pagecompiler": True,
+ "poco*:enable_data_mysql": False,
+ }
def layout(self):
self.folders.generators = os.path.join(self.folders.build, "generators")
@@ -14,6 +18,7 @@ def layout(self):
def requirements(self):
self.requires("angelscript/2.37.0")
self.requires("jsoncpp/1.9.5")
+ self.requires("poco/1.13.3")
self.requires("openssl/3.3.2", override=True)
self.requires("socketw/3.11.0@anotherfoxguy/stable")
self.requires("libcurl/8.10.1")
\ No newline at end of file
diff --git a/source/server/CMakeLists.txt b/source/server/CMakeLists.txt
index f4e8348d..4607fe4b 100644
--- a/source/server/CMakeLists.txt
+++ b/source/server/CMakeLists.txt
@@ -20,7 +20,13 @@ if (RORSERVER_WITH_CURL)
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
endif ()
-target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads SocketW::SocketW jsoncpp_lib)
+target_link_libraries(${PROJECT_NAME} PRIVATE
+ Poco::Poco
+ Poco::Foundation
+ Threads::Threads
+ SocketW::SocketW
+ jsoncpp_lib
+)
IF (WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
diff --git a/source/server/config.cpp b/source/server/config.cpp
index e713aeb9..049b9973 100644
--- a/source/server/config.cpp
+++ b/source/server/config.cpp
@@ -22,12 +22,12 @@ along with Foobar. If not, see .
#include "logger.h"
#include "sequencer.h"
-#include "sha1_util.h"
#include "spamfilter.h"
#include "utils.h"
#include
#include
+#include "Poco/SHA1Engine.h"
#ifdef __GNUC__
@@ -385,15 +385,20 @@ namespace Config {
}
bool setPublicPass(const std::string &pub_pass) {
- if (pub_pass.length() > 0 && pub_pass.size() < 250 &&
- !SHA1FromString(s_public_password, pub_pass)) {
+ try
+ {
+ Poco::SHA1Engine engine;
+ engine.update(pub_pass);
+ s_public_password = Poco::DigestEngine::digestToHex(engine.digest());
+ Logger::Log(LOG_DEBUG, "sha1(%s) = %s", pub_pass.c_str(), s_public_password.c_str());
+ return true;
+ }
+ catch (...)
+ {
Logger::Log(LOG_ERROR, "could not generate server SHA1 password hash!");
s_public_password = "";
return false;
}
- Logger::Log(LOG_DEBUG, "sha1(%s) = %s", pub_pass.c_str(),
- s_public_password.c_str());
- return true;
}
bool setIPAddr(const std::string &ip) {
diff --git a/source/server/rorserver.cpp b/source/server/rorserver.cpp
index 62de763f..12c4898c 100644
--- a/source/server/rorserver.cpp
+++ b/source/server/rorserver.cpp
@@ -29,9 +29,6 @@ along with Foobar. If not, see .
#include "master-server.h"
#include "utils.h"
-#include "sha1_util.h"
-#include "sha1.h"
-
#include
#include
#include
@@ -286,11 +283,6 @@ int main(int argc, char *argv[]) {
return 1;
}
- if (!sha1check()) {
- Logger::Log(LOG_ERROR, "sha1 malfunction!");
- return -1;
- }
-
#ifndef _WIN32
if (!Config::getForeground()) {
// no output because of background mode
diff --git a/source/server/sequencer.cpp b/source/server/sequencer.cpp
index 2345e01a..1a0c41c6 100644
--- a/source/server/sequencer.cpp
+++ b/source/server/sequencer.cpp
@@ -21,7 +21,6 @@ along with Foobar. If not, see .
#include "sequencer.h"
#include "messaging.h"
-#include "sha1_util.h"
#include "receiver.h"
#include "broadcaster.h"
#include "userauth.h"
diff --git a/source/server/sha1.c b/source/server/sha1.c
deleted file mode 100644
index 0d4182f3..00000000
--- a/source/server/sha1.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * FIPS-180-1 compliant SHA-1 implementation
- *
- * Copyright (C) 2006-2007 Christophe Devine
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License, version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-/*
- * The SHA-1 standard was published by NIST in 1993.
- *
- * http://www.itl.nist.gov/fipspubs/fip180-1.htm
- */
-
-#include "sha1config.h"
-
-#if defined(XYSSL_SHA1_C)
-
-#include "sha1.h"
-
-#include
-#include
-
-/*
- * 32-bit integer manipulation macros (big endian)
- */
-#ifndef GET_ULONG_BE
-#define GET_ULONG_BE(n, b, i) \
-{ \
- (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
- | ( (unsigned long) (b)[(i) + 1] << 16 ) \
- | ( (unsigned long) (b)[(i) + 2] << 8 ) \
- | ( (unsigned long) (b)[(i) + 3] ); \
-}
-#endif
-
-#ifndef PUT_ULONG_BE
-#define PUT_ULONG_BE(n, b, i) \
-{ \
- (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
- (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
- (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
- (b)[(i) + 3] = (unsigned char) ( (n) ); \
-}
-#endif
-
-/*
- * SHA-1 context setup
- */
-void sha1_starts(sha1_context *ctx) {
- ctx->total[0] = 0;
- ctx->total[1] = 0;
-
- ctx->state[0] = 0x67452301;
- ctx->state[1] = 0xEFCDAB89;
- ctx->state[2] = 0x98BADCFE;
- ctx->state[3] = 0x10325476;
- ctx->state[4] = 0xC3D2E1F0;
-}
-
-static void sha1_process(sha1_context *ctx, unsigned char data[64]) {
- unsigned long temp, W[16], A, B, C, D, E;
-
- GET_ULONG_BE(W[0], data, 0);
- GET_ULONG_BE(W[1], data, 4);
- GET_ULONG_BE(W[2], data, 8);
- GET_ULONG_BE(W[3], data, 12);
- GET_ULONG_BE(W[4], data, 16);
- GET_ULONG_BE(W[5], data, 20);
- GET_ULONG_BE(W[6], data, 24);
- GET_ULONG_BE(W[7], data, 28);
- GET_ULONG_BE(W[8], data, 32);
- GET_ULONG_BE(W[9], data, 36);
- GET_ULONG_BE(W[10], data, 40);
- GET_ULONG_BE(W[11], data, 44);
- GET_ULONG_BE(W[12], data, 48);
- GET_ULONG_BE(W[13], data, 52);
- GET_ULONG_BE(W[14], data, 56);
- GET_ULONG_BE(W[15], data, 60);
-
-#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
-
-#define R(t) \
-( \
- temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
- W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
- ( W[t & 0x0F] = S(temp,1) ) \
-)
-
-#define P(a, b, c, d, e, x) \
-{ \
- e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
-}
-
- A = ctx->state[0];
- B = ctx->state[1];
- C = ctx->state[2];
- D = ctx->state[3];
- E = ctx->state[4];
-
-#define F(x, y, z) (z ^ (x & (y ^ z)))
-#define K 0x5A827999
-
- P(A, B, C, D, E, W[0]);
- P(E, A, B, C, D, W[1]);
- P(D, E, A, B, C, W[2]);
- P(C, D, E, A, B, W[3]);
- P(B, C, D, E, A, W[4]);
- P(A, B, C, D, E, W[5]);
- P(E, A, B, C, D, W[6]);
- P(D, E, A, B, C, W[7]);
- P(C, D, E, A, B, W[8]);
- P(B, C, D, E, A, W[9]);
- P(A, B, C, D, E, W[10]);
- P(E, A, B, C, D, W[11]);
- P(D, E, A, B, C, W[12]);
- P(C, D, E, A, B, W[13]);
- P(B, C, D, E, A, W[14]);
- P(A, B, C, D, E, W[15]);
- P(E, A, B, C, D, R(16));
- P(D, E, A, B, C, R(17));
- P(C, D, E, A, B, R(18));
- P(B, C, D, E, A, R(19));
-
-#undef K
-#undef F
-
-#define F(x, y, z) (x ^ y ^ z)
-#define K 0x6ED9EBA1
-
- P(A, B, C, D, E, R(20));
- P(E, A, B, C, D, R(21));
- P(D, E, A, B, C, R(22));
- P(C, D, E, A, B, R(23));
- P(B, C, D, E, A, R(24));
- P(A, B, C, D, E, R(25));
- P(E, A, B, C, D, R(26));
- P(D, E, A, B, C, R(27));
- P(C, D, E, A, B, R(28));
- P(B, C, D, E, A, R(29));
- P(A, B, C, D, E, R(30));
- P(E, A, B, C, D, R(31));
- P(D, E, A, B, C, R(32));
- P(C, D, E, A, B, R(33));
- P(B, C, D, E, A, R(34));
- P(A, B, C, D, E, R(35));
- P(E, A, B, C, D, R(36));
- P(D, E, A, B, C, R(37));
- P(C, D, E, A, B, R(38));
- P(B, C, D, E, A, R(39));
-
-#undef K
-#undef F
-
-#define F(x, y, z) ((x & y) | (z & (x | y)))
-#define K 0x8F1BBCDC
-
- P(A, B, C, D, E, R(40));
- P(E, A, B, C, D, R(41));
- P(D, E, A, B, C, R(42));
- P(C, D, E, A, B, R(43));
- P(B, C, D, E, A, R(44));
- P(A, B, C, D, E, R(45));
- P(E, A, B, C, D, R(46));
- P(D, E, A, B, C, R(47));
- P(C, D, E, A, B, R(48));
- P(B, C, D, E, A, R(49));
- P(A, B, C, D, E, R(50));
- P(E, A, B, C, D, R(51));
- P(D, E, A, B, C, R(52));
- P(C, D, E, A, B, R(53));
- P(B, C, D, E, A, R(54));
- P(A, B, C, D, E, R(55));
- P(E, A, B, C, D, R(56));
- P(D, E, A, B, C, R(57));
- P(C, D, E, A, B, R(58));
- P(B, C, D, E, A, R(59));
-
-#undef K
-#undef F
-
-#define F(x, y, z) (x ^ y ^ z)
-#define K 0xCA62C1D6
-
- P(A, B, C, D, E, R(60));
- P(E, A, B, C, D, R(61));
- P(D, E, A, B, C, R(62));
- P(C, D, E, A, B, R(63));
- P(B, C, D, E, A, R(64));
- P(A, B, C, D, E, R(65));
- P(E, A, B, C, D, R(66));
- P(D, E, A, B, C, R(67));
- P(C, D, E, A, B, R(68));
- P(B, C, D, E, A, R(69));
- P(A, B, C, D, E, R(70));
- P(E, A, B, C, D, R(71));
- P(D, E, A, B, C, R(72));
- P(C, D, E, A, B, R(73));
- P(B, C, D, E, A, R(74));
- P(A, B, C, D, E, R(75));
- P(E, A, B, C, D, R(76));
- P(D, E, A, B, C, R(77));
- P(C, D, E, A, B, R(78));
- P(B, C, D, E, A, R(79));
-
-#undef K
-#undef F
-
- ctx->state[0] += A;
- ctx->state[1] += B;
- ctx->state[2] += C;
- ctx->state[3] += D;
- ctx->state[4] += E;
-}
-
-/*
- * SHA-1 process buffer
- */
-void sha1_update(sha1_context *ctx, unsigned char *input, int ilen) {
- int fill;
- unsigned long left;
-
- if (ilen <= 0)
- return;
-
- left = ctx->total[0] & 0x3F;
- fill = 64 - left;
-
- ctx->total[0] += ilen;
- ctx->total[0] &= 0xFFFFFFFF;
-
- if (ctx->total[0] < (unsigned long) ilen)
- ctx->total[1]++;
-
- if (left && ilen >= fill) {
- memcpy((void *) (ctx->buffer + left),
- (void *) input, fill);
- sha1_process(ctx, ctx->buffer);
- input += fill;
- ilen -= fill;
- left = 0;
- }
-
- while (ilen >= 64) {
- sha1_process(ctx, input);
- input += 64;
- ilen -= 64;
- }
-
- if (ilen > 0) {
- memcpy((void *) (ctx->buffer + left),
- (void *) input, ilen);
- }
-}
-
-static const unsigned char sha1_padding[64] =
- {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
-/*
- * SHA-1 final digest
- */
-void sha1_finish(sha1_context *ctx, unsigned char output[20]) {
- unsigned long last, padn;
- unsigned long high, low;
- unsigned char msglen[8];
-
- high = (ctx->total[0] >> 29)
- | (ctx->total[1] << 3);
- low = (ctx->total[0] << 3);
-
- PUT_ULONG_BE(high, msglen, 0);
- PUT_ULONG_BE(low, msglen, 4);
-
- last = ctx->total[0] & 0x3F;
- padn = (last < 56) ? (56 - last) : (120 - last);
-
- sha1_update(ctx, (unsigned char *) sha1_padding, padn);
- sha1_update(ctx, msglen, 8);
-
- PUT_ULONG_BE(ctx->state[0], output, 0);
- PUT_ULONG_BE(ctx->state[1], output, 4);
- PUT_ULONG_BE(ctx->state[2], output, 8);
- PUT_ULONG_BE(ctx->state[3], output, 12);
- PUT_ULONG_BE(ctx->state[4], output, 16);
-}
-
-/*
- * output = SHA-1( input buffer )
- */
-void sha1(unsigned char *input, int ilen, unsigned char output[20]) {
- sha1_context ctx;
-
- sha1_starts(&ctx);
- sha1_update(&ctx, input, ilen);
- sha1_finish(&ctx, output);
-
- memset(&ctx, 0, sizeof(sha1_context));
-}
-
-/*
- * output = SHA-1( file contents )
- */
-int sha1_file(char *path, unsigned char output[20]) {
- FILE *f;
- size_t n;
- sha1_context ctx;
- unsigned char buf[1024];
-
- if ((f = fopen(path, "rb")) == NULL)
- return (1);
-
- sha1_starts(&ctx);
-
- while ((n = fread(buf, 1, sizeof(buf), f)) > 0)
- sha1_update(&ctx, buf, (int) n);
-
- sha1_finish(&ctx, output);
-
- memset(&ctx, 0, sizeof(sha1_context));
-
- if (ferror(f) != 0) {
- fclose(f);
- return (2);
- }
-
- fclose(f);
- return (0);
-}
-
-/*
- * SHA-1 HMAC context setup
- */
-void sha1_hmac_starts(sha1_context *ctx, unsigned char *key, int keylen) {
- int i;
- unsigned char sum[20];
-
- if (keylen > 64) {
- sha1(key, keylen, sum);
- keylen = 20;
- key = sum;
- }
-
- memset(ctx->ipad, 0x36, 64);
- memset(ctx->opad, 0x5C, 64);
-
- for (i = 0; i < keylen; i++) {
- ctx->ipad[i] = (unsigned char) (ctx->ipad[i] ^ key[i]);
- ctx->opad[i] = (unsigned char) (ctx->opad[i] ^ key[i]);
- }
-
- sha1_starts(ctx);
- sha1_update(ctx, ctx->ipad, 64);
-
- memset(sum, 0, sizeof(sum));
-}
-
-/*
- * SHA-1 HMAC process buffer
- */
-void sha1_hmac_update(sha1_context *ctx, unsigned char *input, int ilen) {
- sha1_update(ctx, input, ilen);
-}
-
-/*
- * SHA-1 HMAC final digest
- */
-void sha1_hmac_finish(sha1_context *ctx, unsigned char output[20]) {
- unsigned char tmpbuf[20];
-
- sha1_finish(ctx, tmpbuf);
- sha1_starts(ctx);
- sha1_update(ctx, ctx->opad, 64);
- sha1_update(ctx, tmpbuf, 20);
- sha1_finish(ctx, output);
-
- memset(tmpbuf, 0, sizeof(tmpbuf));
-}
-
-/*
- * output = HMAC-SHA-1( hmac key, input buffer )
- */
-void sha1_hmac(unsigned char *key, int keylen, unsigned char *input, int ilen,
- unsigned char output[20]) {
- sha1_context ctx;
-
- sha1_hmac_starts(&ctx, key, keylen);
- sha1_hmac_update(&ctx, input, ilen);
- sha1_hmac_finish(&ctx, output);
-
- memset(&ctx, 0, sizeof(sha1_context));
-}
-
-#if defined(XYSSL_SELF_TEST)
-
-/*
- * FIPS-180-1 test vectors
- */
-static const char sha1_test_str[3][57] =
- {
- {"abc"},
- {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"},
- {""}
- };
-
-static const unsigned char sha1_test_sum[3][20] =
- {
- {0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E,
- 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D},
- {0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
- 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1},
- {0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E,
- 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F}
- };
-
-/*
- * Checkup routine
- */
-int sha1_self_test(int verbose) {
- int i, j;
- unsigned char buf[1000];
- unsigned char sha1sum[20];
- sha1_context ctx;
-
- for (i = 0; i < 3; i++) {
- if (verbose != 0)
- printf(" SHA-1 test #%d: ", i + 1);
-
- sha1_starts(&ctx);
-
- if (i < 2)
- sha1_update(&ctx, (unsigned char *) sha1_test_str[i],
- (int) strlen(sha1_test_str[i]));
- else {
- memset(buf, 'a', 1000);
- for (j = 0; j < 1000; j++)
- sha1_update(&ctx, buf, 1000);
- }
-
- sha1_finish(&ctx, sha1sum);
-
- if (memcmp(sha1sum, sha1_test_sum[i], 20) != 0) {
- if (verbose != 0)
- printf("failed\n");
-
- return (1);
- }
-
- if (verbose != 0)
- printf("passed\n");
- }
-
- if (verbose != 0)
- printf("\n");
-
- return (0);
-}
-
-#endif
-
-#endif
diff --git a/source/server/sha1.h b/source/server/sha1.h
deleted file mode 100644
index dbcc6038..00000000
--- a/source/server/sha1.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * \file sha1.h
- */
-#pragma once
-#ifndef XYSSL_SHA1_H
-#define XYSSL_SHA1_H
-
-/**
- * \brief SHA-1 context structure
- */
-typedef struct {
- unsigned long total[2]; /*!< number of bytes processed */
- unsigned long state[5]; /*!< intermediate digest state */
- unsigned char buffer[64]; /*!< data block being processed */
-
- unsigned char ipad[64]; /*!< HMAC: inner padding */
- unsigned char opad[64]; /*!< HMAC: outer padding */
-}
- sha1_context;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief SHA-1 context setup
- *
- * \param ctx context to be initialized
- */
-void sha1_starts(sha1_context *ctx);
-
-/**
- * \brief SHA-1 process buffer
- *
- * \param ctx SHA-1 context
- * \param input buffer holding the data
- * \param ilen length of the input data
- */
-void sha1_update(sha1_context *ctx, unsigned char *input, int ilen);
-
-/**
- * \brief SHA-1 final digest
- *
- * \param ctx SHA-1 context
- * \param output SHA-1 checksum result
- */
-void sha1_finish(sha1_context *ctx, unsigned char output[20]);
-
-/**
- * \brief Output = SHA-1( input buffer )
- *
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-1 checksum result
- */
-void sha1(unsigned char *input, int ilen, unsigned char output[20]);
-
-/**
- * \brief Output = SHA-1( file contents )
- *
- * \param path input file name
- * \param output SHA-1 checksum result
- *
- * \return 0 if successful, 1 if fopen failed,
- * or 2 if fread failed
- */
-int sha1_file(char *path, unsigned char output[20]);
-
-/**
- * \brief SHA-1 HMAC context setup
- *
- * \param ctx HMAC context to be initialized
- * \param key HMAC secret key
- * \param keylen length of the HMAC key
- */
-void sha1_hmac_starts(sha1_context *ctx, unsigned char *key, int keylen);
-
-/**
- * \brief SHA-1 HMAC process buffer
- *
- * \param ctx HMAC context
- * \param input buffer holding the data
- * \param ilen length of the input data
- */
-void sha1_hmac_update(sha1_context *ctx, unsigned char *input, int ilen);
-
-/**
- * \brief SHA-1 HMAC final digest
- *
- * \param ctx HMAC context
- * \param output SHA-1 HMAC checksum result
- */
-void sha1_hmac_finish(sha1_context *ctx, unsigned char output[20]);
-
-/**
- * \brief Output = HMAC-SHA-1( hmac key, input buffer )
- *
- * \param key HMAC secret key
- * \param keylen length of the HMAC key
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output HMAC-SHA-1 result
- */
-void sha1_hmac(unsigned char *key, int keylen,
- unsigned char *input, int ilen,
- unsigned char output[20]);
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int sha1_self_test(int verbose);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* sha1.h */
diff --git a/source/server/sha1_util.cpp b/source/server/sha1_util.cpp
deleted file mode 100644
index 29ca8d7a..00000000
--- a/source/server/sha1_util.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
-This file is part of "Rigs of Rods Server" (Relay mode)
-
-Copyright 2007 Pierre-Michel Ricordel
-Copyright 2014+ Rigs of Rods Community
-
-"Rigs of Rods Server" is free software: you can redistribute it
-and/or modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation, either version 3
-of the License, or (at your option) any later version.
-
-"Rigs of Rods Server" is distributed in the hope that it will
-be useful, but WITHOUT ANY WARRANTY; without even the implied
-warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar. If not, see .
-*/
-
-#include "sha1_util.h"
-
-#include "sha1.h"
-#include
-#include
-#include
-
-#ifdef __GNUC__
-
-#include
-#include
-#include
-
-#endif
-
-#include
-
-bool toHex(char *result, unsigned char *data, unsigned int len) {
- char tmp[20];
- unsigned int i = 0;
- while (i < len) {
- memset(tmp, 0, 20);
- unsigned char d = (unsigned char) *data;
- sprintf(tmp, "%02X", d);
- strcat(result, tmp);
- data++;
- i++;
- }
- return true;
-}
-
-bool SHA1FromString(char *result, const char *source) {
- // init variables
- char sha1result_bin[20];
- memset(sha1result_bin, 0, 20);
- char sha1result_hex[41];
- memset(sha1result_hex, 0, 41);
-
- // calculate hash of the filenames
- sha1((unsigned char *) source, (int) strlen(source), (unsigned char *) sha1result_bin);
- bool res = toHex(sha1result_hex, (unsigned char *) sha1result_bin, 20);
- memcpy(result, sha1result_hex, 40);
- result[40] = 0;
- return res;
-}
-
-bool SHA1FromBuffer(char *result, const char *source, int len) {
- // init variables
- char sha1result_bin[20];
- memset(sha1result_bin, 0, 20);
- char sha1result_hex[2048];
- memset(sha1result_hex, 0, 2048);
-
- // calculate hash of the filenames
- sha1((unsigned char *) source, len, (unsigned char *) sha1result_bin);
- bool res = toHex(sha1result_hex, (unsigned char *) sha1result_bin, 20);
- memcpy(result, sha1result_hex, 40);
- result[40] = 0;
- return res;
-}
-
-bool SHA1FromString(std::string &result, const std::string &sourceStr) {
- // init variables
- char sha1result_bin[20];
- memset(sha1result_bin, 0, 20);
- char sha1result_hex[41];
- memset(sha1result_hex, 0, 41);
-
- // calculate hash of the filenames
- char *source = const_cast(sourceStr.c_str());
- sha1((unsigned char *) source, (int) strlen(source), (unsigned char *) sha1result_bin);
- bool res = toHex(sha1result_hex, (unsigned char *) sha1result_bin, 20);
- if (res) {
- sha1result_hex[40] = 0;
- result = std::string(sha1result_hex);
- }
- return res;
-}
-
-int getFileHash(char *filename, char *hash) {
- FILE *cfd = fopen(filename, "rb");
- // anti-hacker :|
- if (cfd) {
- // obtain file size:
- fseek(cfd, 0, SEEK_END);
- unsigned long lSize = ftell(cfd);
- if (lSize <= 0) {
- fclose(cfd);
- return 1;
- }
- rewind(cfd);
-
- // allocate memory to contain the whole file:
- char *buffer = (char *) malloc(sizeof(char) * (lSize + 1));
- if (buffer == NULL) {
- fclose(cfd);
- return -3;
- }
- memset(buffer, 0, lSize);
- // copy the file into the buffer:
- size_t result = fread(buffer, 1, lSize, cfd);
- if (result != lSize) {
- free(buffer);
- fclose(cfd);
- return -2;
- }
- // terminate
- fclose(cfd);
- buffer[lSize] = 0;
-
- char sha1result[250];
- memset(sha1result, 0, 250);
-
- if (lSize < 300) {
- free(buffer);
- return -4;
- }
-
- if (!SHA1FromString(sha1result, buffer)) {
- free(buffer);
- return -1;
- }
-
- free(buffer);
- memcpy(hash, sha1result, 40);
- hash[41] = 0;
- return 0;
- }
- return 1;
-}
-
-bool sha1check() {
- char testStr[255] = "The quick brown fox jumps over the lazy dog";
- char result[255] = "";
- char testvalue[255] = "2FD4E1C67A2D28FCED849EE1BB76E7391B93EB12";
- SHA1FromString(result, testStr);
- return !strcmp(result, testvalue);
-}
diff --git a/source/server/sha1_util.h b/source/server/sha1_util.h
deleted file mode 100644
index 72dd1846..00000000
--- a/source/server/sha1_util.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-#ifndef SHA1UTIL_H_
-#define SHA1UTIL_H_
-
-#include
-
-bool toHex(char *result, unsigned char *data, unsigned int len);
-
-bool SHA1FromString(char *result, const char *source);
-
-bool SHA1FromBuffer(char *result, const char *source, int len);
-
-bool SHA1FromString(std::string &result, const std::string &sourceStr);
-
-int getFileHash(char *filename, char *hash);
-
-bool sha1check();
-
-#endif
diff --git a/source/server/sha1config.h b/source/server/sha1config.h
deleted file mode 100644
index b284a46a..00000000
--- a/source/server/sha1config.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * \file config.h
- *
- * This set of compile-time options may be used to enable
- * or disable features selectively, and reduce the global
- * memory footprint.
- */
-#pragma once
-#ifndef XYSSL_CONFIG_H
-#define XYSSL_CONFIG_H
-
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-/*
- * Uncomment if native integers are 8-bit wide.
- *
-#define XYSSL_HAVE_INT8
- */
-
-/*
- * Uncomment if native integers are 16-bit wide.
- *
-#define XYSSL_HAVE_INT16
- */
-
-/*
- * Uncomment if the compiler supports long long.
- *
-#define XYSSL_HAVE_LONGLONG
- */
-
-/*
- * Uncomment if the CPU supports SSE2 (IA-32 specific).
- *
-#define XYSSL_HAVE_SSE2
- */
-
-/*
- * Enable all SSL/TLS debugging messages.
- */
-#define XYSSL_DEBUG_MSG
-
-/*
- * Enable the checkup functions (*_self_test).
- */
-#define XYSSL_SELF_TEST
-
-/*
- * Enable the prime-number generation code.
- */
-#define XYSSL_GENPRIME
-
-/*
- * Uncomment this macro to store the AES tables in ROM.
- *
-#define XYSSL_AES_ROM_TABLES
- */
-
-/*
- * Module: library/aes.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- * SSL_RSA_AES_256_SHA
- * SSL_EDH_RSA_AES_256_SHA
- */
-#define XYSSL_AES_C
-
-/*
- * Module: library/arc4.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- * SSL_RSA_RC4_128_MD5
- * SSL_RSA_RC4_128_SHA
- */
-#define XYSSL_ARC4_C
-
-/*
- * Module: library/base64.c
- * Caller: library/x509parse.c
- *
- * This module is required for X.509 support.
- */
-#define XYSSL_BASE64_C
-
-/*
- * Module: library/bignum.c
- * Caller: library/dhm.c
- * library/rsa.c
- * library/ssl_tls.c
- * library/x509parse.c
- *
- * This module is required for RSA and DHM support.
- */
-#define XYSSL_BIGNUM_C
-
-/*
- * Module: library/certs.c
- * Caller:
- *
- * This module is used for testing (ssl_client/server).
- */
-#define XYSSL_CERTS_C
-
-/*
- * Module: library/debug.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * This module provides debugging functions.
- */
-#define XYSSL_DEBUG_C
-
-/*
- * Module: library/des.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- * SSL_RSA_DES_168_SHA
- * SSL_EDH_RSA_DES_168_SHA
- */
-#define XYSSL_DES_C
-
-/*
- * Module: library/dhm.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module enables the following ciphersuites:
- * SSL_EDH_RSA_DES_168_SHA
- * SSL_EDH_RSA_AES_256_SHA
- */
-#define XYSSL_DHM_C
-
-/*
- * Module: library/havege.c
- * Caller:
- *
- * This module enables the HAVEGE random number generator.
- */
-#define XYSSL_HAVEGE_C
-
-/*
- * Module: library/md2.c
- * Caller: library/x509parse.c
- *
- * This module enables support for MD2-signed X.509 certificates.
- */
-#define XYSSL_MD2_C
-
-/*
- * Module: library/md4.c
- * Caller: library/x509parse.c
- *
- * This module enables support for MD4-signed X.509 certificates.
- */
-#define XYSSL_MD4_C
-
-/*
- * Module: library/md5.c
- * Caller: library/ssl_tls.c
- * library/x509parse.c
- *
- * This module is required for SSL/TLS and X.509.
- */
-#define XYSSL_MD5_C
-
-/*
- * Module: library/net.c
- * Caller:
- *
- * This module provides TCP/IP networking routines.
- */
-#define XYSSL_NET_C
-
-/*
- * Module: library/padlock.c
- * Caller: library/aes.c
- *
- * This modules adds support for the VIA PadLock on x86.
- */
-#define XYSSL_PADLOCK_C
-
-/*
- * Module: library/rsa.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- * library/x509.c
- *
- * This module is required for SSL/TLS and X.509.
- */
-#define XYSSL_RSA_C
-
-/*
- * Module: library/sha1.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- * library/x509parse.c
- *
- * This module is required for SSL/TLS and X.509.
- */
-#define XYSSL_SHA1_C
-
-/*
- * Module: library/sha2.c
- * Caller:
- *
- * This module adds support for SHA-224 and SHA-256.
- */
-#define XYSSL_SHA2_C
-
-/*
- * Module: library/sha4.c
- * Caller:
- *
- * This module adds support for SHA-384 and SHA-512.
- */
-#define XYSSL_SHA4_C
-
-/*
- * Module: library/ssl_cli.c
- * Caller:
- *
- * This module is required for SSL/TLS client support.
- */
-#define XYSSL_SSL_CLI_C
-
-/*
- * Module: library/ssl_srv.c
- * Caller:
- *
- * This module is required for SSL/TLS server support.
- */
-#define XYSSL_SSL_SRV_C
-
-/*
- * Module: library/ssl_tls.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module is required for SSL/TLS.
- */
-#define XYSSL_SSL_TLS_C
-
-/*
- * Module: library/timing.c
- * Caller: library/havege.c
- *
- * This module is used by the HAVEGE random number generator.
- */
-#define XYSSL_TIMING_C
-
-/*
- * Module: library/x509parse.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * This module is required for X.509 certificate parsing.
- */
-#define XYSSL_X509_PARSE_C
-
-/*
- * Module: library/x509_write.c
- * Caller:
- *
- * This module is required for X.509 certificate writing.
- */
-#define XYSSL_X509_WRITE_C
-
-#endif /* config.h */