Skip to content

Commit

Permalink
hotplace rev.444 thirdparty
Browse files Browse the repository at this point in the history
  • Loading branch information
princeb612 committed Dec 18, 2023
1 parent 38203e8 commit bec432e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 82 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@

## studying

* RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1
* RFC 7540 Hypertext Transfer Protocol Version 2 (HTTP/2)
* RFC 9114 HTTP/3

* RFC 8778 Use of the HSS/LMS Hash-Based Signature Algorithm with CBOR Object Signing and Encryption (COSE)
* RFC 9021 Use of the Walnut Digital Signature Algorithm with CBOR Object Signing and Encryption (COSE)
* RFC 9054 CBOR Object Signing and Encryption (COSE): Hash Algorithms
Expand All @@ -119,7 +123,7 @@
* $ hotplace ./make.sh
* os support
* tested
* RHEL 7 and newer, (including CentOS, Rockey Linux)
* RHEL 7 and newer, (including CentOS, Rocky Linux)
* ubuntu 20.04 and newer
* mingw
* Fedora Core release 4 (Stentz) w/ custom toolchain (GCC 4.8)
Expand All @@ -136,7 +140,7 @@
* openssl 3.0, 3.1
* EVP_CIPHER_fetch/EVP_CIPHER_free, EVP_MD_fetch/EVP_MD_free
* truncated sha ("sha2-512/224", "sha2-512/256")
* failed to load PEM file containing private key
* failed to load PEM file containing HMAC private key
* openssl 3.2
* argon2d, argon2i, argon2id
* custom build required in RHEL (RHEL, centos, rocky) and older version
Expand Down
64 changes: 1 addition & 63 deletions sdk/base/c++14.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,6 @@
#ifndef __HOTPLACE_SDK_BASE_CPP14__
#define __HOTPLACE_SDK_BASE_CPP14__

#include <sdk/base/types.hpp>

namespace hotplace {

#if __cplusplus >= 201402L // c++14
/*
* @brief obfuscate a string at compile time
* @sa obfuscate_string
* @example
* constexpr auto temp1 = constexpr_obf <24>("ninety nine red balloons");
* constexpr auto temp2 = CONSTEXPR_OBF ("wild wild world");
* constexpr auto temp3 = CONSTEXPR_OBF_F (0x31, "wild wild world");
* define_constexpr_obf (temp3, "still a man hears what he wants to hear and disregards the rest");
* std::cout << CONSTEXPR_OBF_CSTR(temp1) << std::endl;
* std::cout << CONSTEXPR_OBF_CSTR(temp2) << std::endl;
* std::cout << CONSTEXPR_OBF_CSTR(temp3) << std::endl;
*/
#define define_constexpr_obf(var, x) constexpr auto var = CONSTEXPR_OBF(x)
#define CONSTEXPR_OBF(x) constexpr_obf<RTL_NUMBER_OF(x)>(x)
#define CONSTEXPR_OBF_F(f, x) constexpr_obf < RTL_NUMBER_OF (x), f) > (x)
#define CONSTEXPR_OBF_STR(x) x.load_string()
#define CONSTEXPR_OBF_CSTR(x) x.load_string().c_str()

template <uint32 N, uint8 F = 0x30>
class constexpr_obf {
public:
constexpr constexpr_obf(const char* source) {
// for more information about constexpr, see ISO/IEC 14882 Programming languages — C++
// (c++11) ‘constexpr’ constructor does not have empty body
// (c++14) possible to implement body at constructor
for (unsigned int i = 0; i < N; i++) {
char c = source[i];
buf[i] = c + factor;
if (0 == c) {
break;
}
}
}
std::string load_string() const {
std::string temp;

temp.resize(N);
char* ptr = &temp[0];
for (unsigned int i = 0; i < N + 1; i++) {
char c = buf[i] - factor;
ptr[i] = c;
if (0 == c) {
break;
}
}
return temp;
}
size_t size() const { return N; }

private:
char buf[N + 1] = {
0,
};
uint8 factor = F;
};
#endif

} // namespace hotplace
#include <sdk/base/basic/constexpr_obfuscate.hpp>

#endif
18 changes: 3 additions & 15 deletions sdk/crypto/jose/json_web_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,7 @@ return_t json_web_key::write(crypto_key* crypto_key, char* buf, size_t* buflen,
crypto_key->for_each(json_writer, &mapper);

std::string buffer;
auto func = [](char* data, std::string& buffer) -> void {
if (data) {
buffer = data;
}
};
auto func = [](char* data, std::string& buffer) -> void { buffer = data; };
jwk_serialize_t<std::string>(mapper, func, buffer);

*buflen = buffer.size() + 1;
Expand Down Expand Up @@ -345,11 +341,7 @@ return_t json_web_key::write(crypto_key* crypto_key, std::string& buf, int flags
mapper.flag = flags;
crypto_key->for_each(json_writer, &mapper);

auto func = [](char* data, std::string& buffer) -> void {
if (data) {
buffer = data;
}
};
auto func = [](char* data, std::string& buffer) -> void { buffer = data; };
jwk_serialize_t<std::string>(mapper, func, buf);
}
__finally2 {
Expand All @@ -374,11 +366,7 @@ return_t json_web_key::write(crypto_key* crypto_key, stream_t* buf, int flags) {
mapper.flag = flags;
crypto_key->for_each(json_writer, &mapper);

auto func = [](char* data, stream_t*& stream) -> void {
if (data) {
stream->printf("%s", data);
}
};
auto func = [](char* data, stream_t*& stream) -> void { stream->printf("%s", data); };
jwk_serialize_t<stream_t*>(mapper, func, buf);
}
__finally2 {
Expand Down
5 changes: 3 additions & 2 deletions thirdparty/dependency
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

declare -A oss1=([name]=openssl [url]=https://www.openssl.org/source/openssl-3.1.4.tar.gz [dir]= [build]=build_openssl [buildscript]=)
declare -A oss2=([name]=jansson [url]=https://github.com/akheron/jansson/archive/refs/tags/v2.14.tar.gz [dir]=jansson-2.14 [build]=build_jansson [buildscript]=)
declare -A oss2=([name]=jansson [url]=https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz [dir]=jansson-2.14 [build]=build_jansson [buildscript]=)
declare -A oss3=([name]=zlib [url]=https://www.zlib.net/zlib-1.3.tar.gz [dir]= [build]=build_zlib [buildscript]=)

declare -a dependency=( oss1 oss2 )
declare -a dependency=( oss1 oss2 oss3 )
11 changes: 11 additions & 0 deletions thirdparty/function
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ function build_jansson ()

touch .complete
}

function build_zlib ()
{
local install_dir=${HOTPLACE_HOME}/thirdparty

./configure --prefix=${install_dir}
make
make install

touch .complete
}

0 comments on commit bec432e

Please sign in to comment.