From 5eb8ca60d5d9d3270231bf6a3607c7433b78e3d8 Mon Sep 17 00:00:00 2001 From: princeb612 Date: Fri, 3 May 2024 22:40:53 +0900 Subject: [PATCH] hotplace rev.520 grooming --- sdk/base/basic/base16.cpp | 20 +-- sdk/base/basic/base16.hpp | 36 ++--- sdk/base/basic/base64.cpp | 12 +- sdk/base/basic/base64.hpp | 12 +- sdk/base/basic/dump_memory.hpp | 2 +- sdk/base/basic/obfuscate_string.cpp | 6 +- sdk/base/basic/obfuscate_string.hpp | 12 +- sdk/base/basic/valist.cpp | 6 +- sdk/base/basic/valist.hpp | 6 +- sdk/base/basic/variant.cpp | 4 +- sdk/base/basic/variant.hpp | 6 +- sdk/base/inline.hpp | 28 ++-- sdk/base/stream.hpp | 2 +- sdk/base/stream/basic_stream.cpp | 27 +++- sdk/base/stream/basic_stream.hpp | 17 ++- sdk/base/stream/printf.hpp | 2 +- sdk/base/string/string.hpp | 4 +- sdk/base/string/string_charset.cpp | 4 +- sdk/base/system/linux/debug_trace.cpp | 2 +- sdk/base/system/types.cpp | 2 +- sdk/base/system/types.hpp | 2 +- sdk/base/system/windows/debug_trace.cpp | 2 +- sdk/base/unittest/testcase.cpp | 6 +- sdk/crypto/basic/crypto_key.hpp | 2 +- sdk/crypto/basic/crypto_keychain.cpp | 46 +++--- sdk/crypto/basic/crypto_keychain.hpp | 134 +++++++++--------- sdk/crypto/basic/debug_trace.cpp | 2 +- sdk/crypto/basic/dump_key.cpp | 2 +- sdk/crypto/basic/openssl_aead.cpp | 34 ++--- sdk/crypto/basic/openssl_crypt.cpp | 56 ++++---- sdk/crypto/basic/openssl_crypt.hpp | 122 ++++++++-------- sdk/crypto/basic/openssl_hash.cpp | 20 +-- sdk/crypto/basic/openssl_hash.hpp | 34 ++--- sdk/crypto/basic/openssl_kdf.cpp | 36 ++--- sdk/crypto/basic/openssl_kdf.hpp | 88 ++++++------ sdk/crypto/basic/openssl_mac.cpp | 12 +- sdk/crypto/basic/openssl_sign.cpp | 28 ++-- sdk/crypto/basic/openssl_sign.hpp | 82 +++++------ sdk/crypto/cose/cbor_object_encryption.cpp | 8 +- sdk/crypto/cose/cbor_object_encryption.hpp | 16 +-- sdk/crypto/cose/cbor_object_signing.cpp | 8 +- sdk/crypto/cose/cbor_object_signing.hpp | 16 +-- .../cose/cbor_object_signing_encryption.cpp | 30 ++-- .../cose/cbor_object_signing_encryption.hpp | 50 +++---- sdk/crypto/cose/cbor_web_key.cpp | 4 +- sdk/crypto/cose/cbor_web_key.hpp | 10 +- sdk/crypto/cose/cose_composer.cpp | 48 +++---- sdk/crypto/cose/cose_composer.hpp | 52 +++---- sdk/crypto/crypto.hpp | 28 ++-- sdk/crypto/jose/json_object_encryption.cpp | 18 +-- sdk/crypto/jose/json_object_encryption.hpp | 38 ++--- sdk/crypto/jose/json_object_signing.cpp | 22 +-- sdk/crypto/jose/json_object_signing.hpp | 42 +++--- .../jose/json_object_signing_encryption.cpp | 16 +-- .../jose/json_object_signing_encryption.hpp | 34 ++--- sdk/crypto/jose/json_web_signature.cpp | 10 +- sdk/crypto/jose/json_web_signature.hpp | 22 +-- sdk/io/basic/keyvalue.cpp | 10 +- sdk/io/basic/keyvalue.hpp | 12 +- sdk/io/basic/payload.cpp | 12 +- sdk/io/basic/payload.hpp | 12 +- sdk/io/basic/zlib.cpp | 8 +- sdk/io/basic/zlib.hpp | 8 +- sdk/io/cbor/cbor_data.cpp | 6 +- sdk/io/cbor/cbor_data.hpp | 6 +- sdk/io/cbor/cbor_encode.cpp | 2 +- sdk/io/cbor/cbor_encode.hpp | 2 +- sdk/io/cbor/cbor_reader.cpp | 4 +- sdk/io/cbor/cbor_reader.hpp | 8 +- sdk/io/stream/ansi_string.cpp | 25 +++- sdk/io/stream/dump_memory.cpp | 6 +- sdk/io/stream/printf.cpp | 2 +- sdk/io/stream/stream.hpp | 10 +- sdk/io/stream/string.hpp | 29 ++-- sdk/io/stream/unicode/wide_string.cpp | 28 +++- sdk/io/string/regex.cpp | 2 +- sdk/io/string/string.hpp | 16 +-- sdk/io/string/string_charset.cpp | 8 +- sdk/io/system/types.cpp | 4 +- sdk/io/system/types.hpp | 6 +- .../auth/basic_authentication_provider.cpp | 2 +- .../auth/basic_authentication_provider.hpp | 2 +- sdk/net/http/auth/basic_credentials.cpp | 6 +- sdk/net/http/auth/basic_credentials.hpp | 6 +- .../auth/bearer_authentication_provider.cpp | 2 +- .../auth/bearer_authentication_provider.hpp | 2 +- sdk/net/http/auth/bearer_credentials.cpp | 4 +- sdk/net/http/auth/bearer_credentials.hpp | 4 +- sdk/net/http/auth/custom_credentials.cpp | 4 +- sdk/net/http/auth/custom_credentials.hpp | 4 +- .../digest_access_authentication_provider.cpp | 6 +- .../digest_access_authentication_provider.hpp | 6 +- sdk/net/http/auth/digest_credentials.cpp | 4 +- sdk/net/http/auth/digest_credentials.hpp | 4 +- sdk/net/http/auth/oauth2.cpp | 4 +- sdk/net/http/auth/oauth2.hpp | 4 +- sdk/net/http/auth/oauth2_credentials.cpp | 26 ++-- sdk/net/http/auth/oauth2_credentials.hpp | 50 +++---- sdk/net/http/auth/rfc2617_digest.cpp | 10 +- sdk/net/http/auth/rfc2617_digest.hpp | 10 +- sdk/net/http/html_documents.cpp | 22 +-- sdk/net/http/html_documents.hpp | 22 +-- sdk/net/http/http2/hpack.cpp | 18 +-- sdk/net/http/http2/hpack.hpp | 18 +-- sdk/net/http/http2/http2_frame.cpp | 4 +- sdk/net/http/http2/http2_frame.hpp | 129 +++++++++++------ sdk/net/http/http2/http2_protocol.cpp | 2 +- sdk/net/http/http_authentication_provider.cpp | 2 +- sdk/net/http/http_authentication_provider.hpp | 2 +- sdk/net/http/http_authentication_resolver.cpp | 6 +- sdk/net/http/http_authentication_resolver.hpp | 6 +- sdk/net/http/http_client.cpp | 8 +- sdk/net/http/http_client.hpp | 8 +- sdk/net/http/http_header.cpp | 6 +- sdk/net/http/http_header.hpp | 8 +- sdk/net/http/http_request.cpp | 6 +- sdk/net/http/http_request.hpp | 10 +- sdk/net/http/http_resource.cpp | 2 +- sdk/net/http/http_resource.hpp | 2 +- sdk/net/http/http_response.cpp | 8 +- sdk/net/http/http_response.hpp | 8 +- sdk/net/http/http_router.cpp | 4 +- sdk/net/http/http_router.hpp | 4 +- sdk/net/http/http_server.cpp | 2 +- sdk/net/http/http_server.hpp | 2 +- sdk/net/http/http_server_builder.cpp | 4 +- sdk/net/http/http_server_builder.hpp | 4 +- sdk/net/http/http_uri.cpp | 8 +- sdk/net/http/http_uri.hpp | 16 +-- sdk/net/server/network_protocol.hpp | 2 +- sdk/odbc/basic/odbc_query.hpp | 2 +- test/base/sample.cpp | 16 +-- test/cbor/sample.cpp | 16 +-- test/cmdline/sample.cpp | 8 +- test/cose/sample.cpp | 26 ++-- test/crypto/sample.cpp | 24 ++-- test/encode/sample.cpp | 10 +- test/hash/sample.cpp | 34 +++-- test/httpserver2/sample.cpp | 16 ++- test/httptest/sample.cpp | 22 +-- test/jose/sample.cpp | 42 +++--- test/kdf/sample.cpp | 10 +- test/linux/sample.cpp | 2 +- test/odbc/sample.cpp | 2 +- test/stream/sample.cpp | 44 +++--- test/string/sample.cpp | 23 ++- test/tcpserver2/sample.cpp | 2 +- test/tlsserver/sample.cpp | 2 +- test/windows/sample.cpp | 2 +- 149 files changed, 1268 insertions(+), 1154 deletions(-) diff --git a/sdk/base/basic/base16.cpp b/sdk/base/basic/base16.cpp index f9bba43b..739df742 100644 --- a/sdk/base/basic/base16.cpp +++ b/sdk/base/basic/base16.cpp @@ -116,18 +116,18 @@ return_t base16_encode(const byte_t* source, size_t size, stream_t* stream, uint return ret; } -return_t base16_encode(binary_t const& source, char* buf, size_t* buflen) { return base16_encode(&source[0], source.size(), buf, buflen); } +return_t base16_encode(const binary_t& source, char* buf, size_t* buflen) { return base16_encode(&source[0], source.size(), buf, buflen); } -return_t base16_encode(binary_t const& source, std::string& outpart, uint32 flags) { return base16_encode(&source[0], source.size(), outpart, flags); } +return_t base16_encode(const binary_t& source, std::string& outpart, uint32 flags) { return base16_encode(&source[0], source.size(), outpart, flags); } -std::string base16_encode(binary_t const& source) { +std::string base16_encode(const binary_t& source) { std::string outpart; base16_encode(source, outpart); return outpart; } -return_t base16_encode(binary_t const& source, stream_t* stream) { return base16_encode(&source[0], source.size(), stream); } +return_t base16_encode(const binary_t& source, stream_t* stream) { return base16_encode(&source[0], source.size(), stream); } std::string base16_encode(const char* source) { std::string outpart; @@ -165,7 +165,7 @@ return_t base16_encode(const char* source, binary_t& outpart) { return ret; } -return_t base16_encode(std::string const& source, binary_t& outpart) { return base16_encode(source.c_str(), outpart); } +return_t base16_encode(const std::string& source, binary_t& outpart) { return base16_encode(source.c_str(), outpart); } static byte_t conv(char c) { byte_t ret = 0; @@ -256,9 +256,9 @@ return_t base16_decode(const char* source, size_t size, stream_t* stream, uint32 return ret; } -return_t base16_decode(std::string const& source, binary_t& outpart, uint32 flags) { return base16_decode(source.c_str(), source.size(), outpart, flags); } +return_t base16_decode(const std::string& source, binary_t& outpart, uint32 flags) { return base16_decode(source.c_str(), source.size(), outpart, flags); } -return_t base16_decode(std::string const& source, stream_t* stream, uint32 flags) { return base16_decode(source.c_str(), source.size(), stream, flags); } +return_t base16_decode(const std::string& source, stream_t* stream, uint32 flags) { return base16_decode(source.c_str(), source.size(), stream, flags); } binary_t base16_decode(const char* source) { binary_t outpart; @@ -275,14 +275,14 @@ binary_t base16_decode(const char* source, size_t size) { return outpart; } -binary_t base16_decode(std::string const& source) { +binary_t base16_decode(const std::string& source) { binary_t outpart; base16_decode(source, outpart); return outpart; } -std::string base16_encode_rfc(std::string const& source) { +std::string base16_encode_rfc(const std::string& source) { std::string inpart = source; std::string outpart; @@ -328,7 +328,7 @@ std::string base16_encode_rfc(std::string const& source) { return outpart; } -binary_t base16_decode_rfc(std::string const& source) { +binary_t base16_decode_rfc(const std::string& source) { std::string inpart = source; binary_t outpart; diff --git a/sdk/base/basic/base16.hpp b/sdk/base/basic/base16.hpp index f641c917..a32ff1ff 100644 --- a/sdk/base/basic/base16.hpp +++ b/sdk/base/basic/base16.hpp @@ -13,7 +13,7 @@ * std::string hex; * binary_t bin; * base16_encode (message, 6, hex); - * std::cout << hex.c_str () << std::endl; + * std::cout << hex << std::endl; * base16_decode (hex, bin); * basic_stream bs; * dump_memory (&bin[0], bin.size (), &bs); @@ -79,7 +79,7 @@ return_t base16_encode(const byte_t* source, size_t size, std::string& outpart, return_t base16_encode(const byte_t* source, size_t size, stream_t* stream, uint32 flags = 0); /* * @brief encode - * @param binary_t const& source [in] + * @param const binary_t& source [in] * @param char* buf [out] * @param size_t* buflen [out] * @example @@ -90,10 +90,10 @@ return_t base16_encode(const byte_t* source, size_t size, stream_t* stream, uint * base16_decode (source, buf, &size); * free (buf); */ -return_t base16_encode(binary_t const& source, char* buf, size_t* buflen); +return_t base16_encode(const binary_t& source, char* buf, size_t* buflen); /* * @brief encode - * @param binary_t const& source [in] + * @param const binary_t& source [in] * @param std::string& outpart [out] * @param uint32 flags [inopt] default 0, possible flags base16_notrunc | base16_capital * @example @@ -101,30 +101,30 @@ return_t base16_encode(binary_t const& source, char* buf, size_t* buflen); * std::string encoded; * base16_decode (source, encoded); */ -return_t base16_encode(binary_t const& source, std::string& outpart, uint32 flags = 0); +return_t base16_encode(const binary_t& source, std::string& outpart, uint32 flags = 0); /* * @brief encode - * @param binary_t const& source [in] + * @param const binary_t& source [in] * @param stream_t* stream [out] * @example * binary_t source = convert ("wild wild world"); * basic_stream encoded; * base16_decode (source, &encoded); */ -return_t base16_encode(binary_t const& source, stream_t* stream); +return_t base16_encode(const binary_t& source, stream_t* stream); /* * @brief encode - * @param binary_t const& source [in] + * @param const binary_t& source [in] * @example * binary_t source = convert ("wild wild world"); * std::string encoded = base16_decode (source);; */ -std::string base16_encode(binary_t const& source); +std::string base16_encode(const binary_t& source); std::string base16_encode(const char* source); return_t base16_encode(const char* source, std::string& outpart); return_t base16_encode(const char* source, binary_t& outpart); -return_t base16_encode(std::string const& source, binary_t& outpart); +return_t base16_encode(const std::string& source, binary_t& outpart); /** * @brief decode @@ -144,18 +144,18 @@ return_t base16_decode(const char* source, size_t size, binary_t& outpart, uint3 return_t base16_decode(const char* source, size_t size, stream_t* stream, uint32 flags = 0); /** * @brief decode - * @param std::string const& source [in] + * @param const std::string& source [in] * @param binary_t& outpart [out] * @param uint32 flags [inopt] default 0, possible flags base16_notrunc */ -return_t base16_decode(std::string const& source, binary_t& outpart, uint32 flags = 0); +return_t base16_decode(const std::string& source, binary_t& outpart, uint32 flags = 0); /** * @brief decode - * @param std::string const& source [in] + * @param const std::string& source [in] * @param stream_t* stream [out] * @param uint32 flags [inopt] default 0, possible flags base16_notrunc */ -return_t base16_decode(std::string const& source, stream_t* stream, uint32 flags = 0); +return_t base16_decode(const std::string& source, stream_t* stream, uint32 flags = 0); /** * @brief decode * @param const char* source [in] @@ -171,10 +171,10 @@ binary_t base16_decode(const char* source); binary_t base16_decode(const char* source, size_t size); /** * @brief decode - * @param std::string const& source [in] + * @param const std::string& source [in] * @return binary_t */ -binary_t base16_decode(std::string const& source); +binary_t base16_decode(const std::string& source); /** * @brief encode (support various rfc-style) @@ -190,8 +190,8 @@ binary_t base16_decode(std::string const& source); * binary_t key = base16_encode_rfc("80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f" * "90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f"); */ -std::string base16_encode_rfc(std::string const& source); -binary_t base16_decode_rfc(std::string const& source); +std::string base16_encode_rfc(const std::string& source); +binary_t base16_decode_rfc(const std::string& source); } // namespace hotplace diff --git a/sdk/base/basic/base64.cpp b/sdk/base/basic/base64.cpp index a3c8d5ab..082a21f5 100644 --- a/sdk/base/basic/base64.cpp +++ b/sdk/base/basic/base64.cpp @@ -287,9 +287,9 @@ std::string base64_encode(const byte_t* source, size_t source_size, int encoding return encoded; } -std::string base64_encode(binary_t const& source, int encoding) { return base64_encode(&source[0], source.size(), encoding); } +std::string base64_encode(const binary_t& source, int encoding) { return base64_encode(&source[0], source.size(), encoding); } -std::string base64_encode(std::string const& source, int encoding) { return base64_encode((byte_t*)source.c_str(), source.size(), encoding); } +std::string base64_encode(const std::string& source, int encoding) { return base64_encode((byte_t*)source.c_str(), source.size(), encoding); } return_t base64_decode(const char* source, size_t source_size, binary_t& decoded, int encoding) { return_t ret = errorcode_t::success; @@ -304,7 +304,7 @@ return_t base64_decode(const char* source, size_t source_size, binary_t& decoded return ret; } -return_t base64_decode(std::string const& source, binary_t& decoded, int encoding) { +return_t base64_decode(const std::string& source, binary_t& decoded, int encoding) { return_t ret = errorcode_t::success; size_t size = 0; @@ -324,11 +324,11 @@ binary_t base64_decode(const char* source, size_t source_size, int encoding) { return decoded; } -binary_t base64_decode(binary_t const& source, int encoding) { return base64_decode((char*)&source[0], source.size(), encoding); } +binary_t base64_decode(const binary_t& source, int encoding) { return base64_decode((char*)&source[0], source.size(), encoding); } -binary_t base64_decode(std::string const& source, int encoding) { return base64_decode(source.c_str(), source.size(), encoding); } +binary_t base64_decode(const std::string& source, int encoding) { return base64_decode(source.c_str(), source.size(), encoding); } -std::string base64_decode_careful(std::string const& source, int encoding) { return base64_decode_careful(source.c_str(), source.size(), encoding); } +std::string base64_decode_careful(const std::string& source, int encoding) { return base64_decode_careful(source.c_str(), source.size(), encoding); } std::string base64_decode_careful(const char* source, size_t source_size, int encoding) { std::string decoded; diff --git a/sdk/base/basic/base64.hpp b/sdk/base/basic/base64.hpp index dcc48d97..789f65af 100644 --- a/sdk/base/basic/base64.hpp +++ b/sdk/base/basic/base64.hpp @@ -50,8 +50,8 @@ return_t base64_encode(const byte_t* source, size_t source_size, byte_t* buffer, return_t base64_encode(const byte_t* source, size_t source_size, binary_t& encoded, int encoding = base64_encoding_t::base64_encoding); return_t base64_encode(const byte_t* source, size_t source_size, std::string& encoded, int encoding = base64_encoding_t::base64_encoding); std::string base64_encode(const byte_t* source, size_t source_size, int encoding = base64_encoding_t::base64_encoding); -std::string base64_encode(binary_t const& source, int encoding = base64_encoding_t::base64_encoding); -std::string base64_encode(std::string const& source, int encoding = base64_encoding_t::base64_encoding); +std::string base64_encode(const binary_t& source, int encoding = base64_encoding_t::base64_encoding); +std::string base64_encode(const std::string& source, int encoding = base64_encoding_t::base64_encoding); /** * decode base64 and base64url @@ -72,11 +72,11 @@ std::string base64_encode(std::string const& source, int encoding = base64_encod return_t base64_decode(const byte_t* source, size_t source_size, byte_t* buffer, size_t* buffer_size, int encoding = base64_encoding_t::base64_encoding); return_t base64_decode(const char* source, size_t source_size, binary_t& decoded, int encoding = base64_encoding_t::base64_encoding); -return_t base64_decode(std::string const& source, binary_t& decoded, int encoding = base64_encoding_t::base64_encoding); +return_t base64_decode(const std::string& source, binary_t& decoded, int encoding = base64_encoding_t::base64_encoding); binary_t base64_decode(const char* source, size_t source_size, int encoding = base64_encoding_t::base64_encoding); -binary_t base64_decode(binary_t const& source, int encoding = base64_encoding_t::base64_encoding); -binary_t base64_decode(std::string const& source, int encoding = base64_encoding_t::base64_encoding); -std::string base64_decode_careful(std::string const& source, int encoding = base64_encoding_t::base64_encoding); +binary_t base64_decode(const binary_t& source, int encoding = base64_encoding_t::base64_encoding); +binary_t base64_decode(const std::string& source, int encoding = base64_encoding_t::base64_encoding); +std::string base64_decode_careful(const std::string& source, int encoding = base64_encoding_t::base64_encoding); std::string base64_decode_careful(const char* source, size_t source_size, int encoding = base64_encoding_t::base64_encoding); } // namespace hotplace diff --git a/sdk/base/basic/dump_memory.hpp b/sdk/base/basic/dump_memory.hpp index cad805aa..8b5e51c0 100644 --- a/sdk/base/basic/dump_memory.hpp +++ b/sdk/base/basic/dump_memory.hpp @@ -26,7 +26,7 @@ namespace hotplace { * * basic_stream bs; * dump_memory ((byte_t*) data, strlen (data), &bs, 16, 0, 0x0, dump_memory_flag_t::header); - * std::cout << bs.c_str () << std::endl; + * std::cout << bs << std::endl; */ enum dump_memory_flag_t { diff --git a/sdk/base/basic/obfuscate_string.cpp b/sdk/base/basic/obfuscate_string.cpp index be635a9e..0ab82106 100644 --- a/sdk/base/basic/obfuscate_string.cpp +++ b/sdk/base/basic/obfuscate_string.cpp @@ -160,7 +160,7 @@ bool obfuscate_string::operator==(obfuscate_string& o) { return true == compare( bool obfuscate_string::operator!=(obfuscate_string& o) { return false == compare(o); } -std::string& operator<<(std::string& lhs, obfuscate_string const& rhs) { +std::string& operator<<(std::string& lhs, const obfuscate_string& rhs) { binary_t::const_iterator it; for (it = rhs._contents.begin(); it != rhs._contents.end(); it++) { @@ -169,7 +169,7 @@ std::string& operator<<(std::string& lhs, obfuscate_string const& rhs) { return lhs; } -basic_stream& operator<<(basic_stream& lhs, obfuscate_string const& rhs) { +basic_stream& operator<<(basic_stream& lhs, const obfuscate_string& rhs) { binary_t::const_iterator it; for (it = rhs._contents.begin(); it != rhs._contents.end(); it++) { @@ -178,7 +178,7 @@ basic_stream& operator<<(basic_stream& lhs, obfuscate_string const& rhs) { return lhs; } -binary_t& operator<<(binary_t& lhs, obfuscate_string const& rhs) { +binary_t& operator<<(binary_t& lhs, const obfuscate_string& rhs) { binary_t::const_iterator it; for (it = rhs._contents.begin(); it != rhs._contents.end(); it++) { diff --git a/sdk/base/basic/obfuscate_string.hpp b/sdk/base/basic/obfuscate_string.hpp index 2c0097b1..f913ca61 100644 --- a/sdk/base/basic/obfuscate_string.hpp +++ b/sdk/base/basic/obfuscate_string.hpp @@ -152,24 +152,24 @@ class obfuscate_string { /** * @brief append * @param std::string& lhs [out] - * @param obfuscate_string const& rhs [in] + * @param const obfuscate_string& rhs [in] * @return std::string& */ - friend std::string& operator<<(std::string& lhs, obfuscate_string const& rhs); + friend std::string& operator<<(std::string& lhs, const obfuscate_string& rhs); /** * @brief append * @param std::string& lhs [out] - * @param obfuscate_string const& rhs [in] + * @param const obfuscate_string& rhs [in] * @return basic_stream& */ - friend basic_stream& operator<<(basic_stream& lhs, obfuscate_string const& rhs); + friend basic_stream& operator<<(basic_stream& lhs, const obfuscate_string& rhs); /** * @brief append * @param binary_t& lhs [out] - * @param obfuscate_string const& rhs [in] + * @param const obfuscate_string& rhs [in] * @return binary_t& */ - friend binary_t& operator<<(binary_t& lhs, obfuscate_string const& rhs); + friend binary_t& operator<<(binary_t& lhs, const obfuscate_string& rhs); protected: void startup(); diff --git a/sdk/base/basic/valist.cpp b/sdk/base/basic/valist.cpp index 0e58fd7d..f5b33084 100644 --- a/sdk/base/basic/valist.cpp +++ b/sdk/base/basic/valist.cpp @@ -30,7 +30,7 @@ valist& valist::assign(const valist& object) { return *this; } -valist& valist::assign(std::vector const& args) { +valist& valist::assign(const std::vector& args) { critical_section_guard guard(_lock); _args = args; // copy vector @@ -191,7 +191,7 @@ valist& valist::operator<<(const char* value) { return *this; } -valist& valist::operator<<(variant_t const& v) { +valist& valist::operator<<(const variant_t& v) { insert(v); return *this; } @@ -512,7 +512,7 @@ void valist::build() { } } -void valist::insert(variant_t const& v) { +void valist::insert(const variant_t& v) { critical_section_guard guard(_lock); _args.push_back(v); diff --git a/sdk/base/basic/valist.hpp b/sdk/base/basic/valist.hpp index c9e0ceab..7cb69217 100644 --- a/sdk/base/basic/valist.hpp +++ b/sdk/base/basic/valist.hpp @@ -93,7 +93,7 @@ class valist { * @return *this */ valist& assign(const valist& object); - valist& assign(std::vector const& args); + valist& assign(const std::vector& args); valist& operator<<(bool value); valist& operator<<(char value); @@ -110,7 +110,7 @@ class valist { valist& operator<<(double value); valist& operator<<(void* value); valist& operator<<(const char* value); - valist& operator<<(variant_t const& v); + valist& operator<<(const variant_t& v); valist& operator<<(const valist& object); /** * @brief clear @@ -143,7 +143,7 @@ class valist { * @brief insert * @param variant_t& v [in] */ - void insert(variant_t const& v); + void insert(const variant_t& v); typedef std::vector args_t; diff --git a/sdk/base/basic/variant.cpp b/sdk/base/basic/variant.cpp index cdd7c588..8345c98e 100644 --- a/sdk/base/basic/variant.cpp +++ b/sdk/base/basic/variant.cpp @@ -308,7 +308,7 @@ variant& variant::set_nstr_new(const char* value, size_t n) { return *this; } -variant& variant::set_binary_new(binary_t const& bin) { +variant& variant::set_binary_new(const binary_t& bin) { _vt.type = TYPE_BINARY; _vt.size = 0; _vt.flag = flag_binary; @@ -426,7 +426,7 @@ return_t variant::dump(binary_t& target, bool change_endian) const { return ret; } -variant& variant::copy(variant_t const& value) { +variant& variant::copy(const variant_t& value) { __try2 { reset(); diff --git a/sdk/base/basic/variant.hpp b/sdk/base/basic/variant.hpp index 55062bc0..33f5e4c7 100644 --- a/sdk/base/basic/variant.hpp +++ b/sdk/base/basic/variant.hpp @@ -174,7 +174,7 @@ typedef struct __variant_t { } variant_t; template -T t_variant_to_int(variant_t const& vt) { +T t_variant_to_int(const variant_t& vt) { T i = 0; switch (vt.type) { @@ -292,14 +292,14 @@ class variant { variant& set_strn_new(const char* value, size_t n); variant& set_bstr_new(const unsigned char* value, size_t n); variant& set_nstr_new(const char* value, size_t n); - variant& set_binary_new(binary_t const& bin); + variant& set_binary_new(const binary_t& bin); int to_int() const; return_t to_binary(binary_t& target) const; return_t to_string(std::string& target) const; return_t dump(binary_t& target, bool change_endian) const; - variant& copy(variant_t const& value); + variant& copy(const variant_t& value); variant& move(variant_t& value); variant& copy(const variant& source); variant& move(variant& source); diff --git a/sdk/base/inline.hpp b/sdk/base/inline.hpp index f514adf1..fa2a6e45 100644 --- a/sdk/base/inline.hpp +++ b/sdk/base/inline.hpp @@ -65,9 +65,9 @@ static inline std::string& rtrim(std::string& source) { return source; } -static inline bool ends_with(std::string const& source, std::string const& suffix) { return source.rfind(suffix) == (source.size() - suffix.size()); } +static inline bool ends_with(const std::string& source, const std::string& suffix) { return source.rfind(suffix) == (source.size() - suffix.size()); } -static inline bool ends_with(std::wstring const& source, std::wstring const& suffix) { return source.rfind(suffix) == (source.size() - suffix.size()); } +static inline bool ends_with(const std::wstring& source, const std::wstring& suffix) { return source.rfind(suffix) == (source.size() - suffix.size()); } /** * @brief tolower @@ -109,7 +109,7 @@ static inline std::string uppername(const char* input) { * @brief tolower * @param std::string source [in] */ -static inline std::string lowername(std::string const& input) { +static inline std::string lowername(const std::string& input) { std::string ret_value; __try2 { @@ -122,7 +122,7 @@ static inline std::string lowername(std::string const& input) { return ret_value; } -static inline std::string uppername(std::string const& input) { +static inline std::string uppername(const std::string& input) { std::string ret_value; __try2 { @@ -135,25 +135,25 @@ static inline std::string uppername(std::string const& input) { return ret_value; } -static inline std::string base_name(std::string const& path) { +static inline std::string base_name(const std::string& path) { std::string ret_value = path; return ret_value.substr(ret_value.find_last_of("/\\") + 1); } -static inline std::wstring base_name(std::wstring const& path) { +static inline std::wstring base_name(const std::wstring& path) { std::wstring ret_value = path; return ret_value.substr(ret_value.find_last_of(L"/\\") + 1); } -static inline std::string dir_name(std::string const& path) { +static inline std::string dir_name(const std::string& path) { std::string ret_value = path; return ret_value.substr(0, ret_value.find_last_of("/\\")); } -static inline std::wstring dir_name(std::wstring const& path) { +static inline std::wstring dir_name(const std::wstring& path) { std::wstring ret_value = path; return ret_value.substr(0, ret_value.find_last_of(L"/\\")); @@ -176,7 +176,7 @@ static inline binary_t& operator<<(binary_t& lhs, char* rhs) { * @param binary_t& lhs [inout] * @param std::string rhs [in] */ -static inline binary_t& operator<<(binary_t& lhs, std::string const& rhs) { +static inline binary_t& operator<<(binary_t& lhs, const std::string& rhs) { lhs.insert(lhs.end(), rhs.begin(), rhs.end()); return lhs; } @@ -186,19 +186,19 @@ static inline binary_t& operator<<(binary_t& lhs, std::string const& rhs) { * @param binary_t& lhs [inout] * @param binary_t rhs [in] */ -static inline binary_t& operator<<(binary_t& lhs, binary_t const& rhs) { +static inline binary_t& operator<<(binary_t& lhs, const binary_t& rhs) { lhs.insert(lhs.end(), rhs.begin(), rhs.end()); return lhs; } -static inline std::string convert(binary_t const& bin) { +static inline std::string convert(const binary_t& bin) { std::string result; result.assign((char*)&bin[0], bin.size()); return result; } -static inline binary_t convert(std::string const& source) { +static inline binary_t convert(const std::string& source) { binary_t result; result.insert(result.end(), source.begin(), source.end()); @@ -259,7 +259,7 @@ static inline std::wstring concat_filepath(const wchar_t* path, const wchar_t* f return result; } -static inline std::string concat_filepath(std::string const& path, std::string const& file) { +static inline std::string concat_filepath(const std::string& path, const std::string& file) { std::string result; if (file.size()) { @@ -276,7 +276,7 @@ static inline std::string concat_filepath(std::string const& path, std::string c return result; } -static inline std::wstring concat_filepath(std::wstring const& path, std::wstring const& file) { +static inline std::wstring concat_filepath(const std::wstring& path, const std::wstring& file) { std::wstring result; if (file.size()) { diff --git a/sdk/base/stream.hpp b/sdk/base/stream.hpp index e28aeaac..fb4e0224 100644 --- a/sdk/base/stream.hpp +++ b/sdk/base/stream.hpp @@ -49,7 +49,7 @@ class stream_t { * console_colored_stream << concolor.turnon ().set_fgcolor (console_color_t::yellow) * << "hello" * << concolor.turnoff (); - * std::cout << bs.c_str () << std::endl; + * std::cout << bs << std::endl; */ template class t_stream_binder { diff --git a/sdk/base/stream/basic_stream.cpp b/sdk/base/stream/basic_stream.cpp index 0ac8d5e4..b1b19a3b 100644 --- a/sdk/base/stream/basic_stream.cpp +++ b/sdk/base/stream/basic_stream.cpp @@ -126,13 +126,13 @@ return_t basic_stream::printf(const wchar_t* buf, ...) { return_t basic_stream::vprintf(const wchar_t* buf, va_list ap) { return _bio.vprintf(_handle, buf, ap); } #endif -basic_stream& basic_stream::operator=(basic_stream const& obj) { +basic_stream& basic_stream::operator=(const basic_stream& obj) { clear(); write(obj.data(), obj.size()); return *this; } -basic_stream& basic_stream::operator=(std::string const& str) { +basic_stream& basic_stream::operator=(const std::string& str) { clear(); printf(str.c_str()); return *this; @@ -183,19 +183,19 @@ basic_stream& basic_stream::operator<<(unsigned long long value) { return *this; } -basic_stream& basic_stream::operator<<(basic_stream const& value) { +basic_stream& basic_stream::operator<<(const basic_stream& value) { write(value.data(), value.size()); return *this; } -basic_stream& basic_stream::operator<<(std::string const& value) { +basic_stream& basic_stream::operator<<(const std::string& value) { printf("%s", value.c_str()); return *this; } -int basic_stream::compare(basic_stream const& rhs) { return strcmp((*this).c_str(), rhs.c_str()); } +int basic_stream::compare(const basic_stream& rhs) { return strcmp((*this).c_str(), rhs.c_str()); } -int basic_stream::compare(basic_stream& lhs, basic_stream& rhs) { return strcmp(lhs.c_str(), rhs.c_str()); } +int basic_stream::compare(const basic_stream& lhs, const basic_stream& rhs) { return strcmp(lhs.c_str(), rhs.c_str()); } bool basic_stream::operator<(const basic_stream& rhs) const { return 0 > strcmp((*this).c_str(), rhs.c_str()); } @@ -203,4 +203,19 @@ bool basic_stream::operator>(const basic_stream& rhs) const { return 0 < strcmp( bool basic_stream::operator==(const basic_stream& rhs) const { return 0 == strcmp((*this).c_str(), rhs.c_str()); } +std::string& operator+=(std::string& lhs, const basic_stream& rhs) { + lhs += rhs.c_str(); + return lhs; +} + +std::string& operator<<(std::string& lhs, const basic_stream& rhs) { + lhs += rhs.c_str(); + return lhs; +} + +std::ostream& operator<<(std::ostream& lhs, const basic_stream& rhs) { + lhs << rhs.c_str(); + return lhs; +} + } // namespace hotplace diff --git a/sdk/base/stream/basic_stream.hpp b/sdk/base/stream/basic_stream.hpp index 812ad71b..94214ef7 100644 --- a/sdk/base/stream/basic_stream.hpp +++ b/sdk/base/stream/basic_stream.hpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -101,28 +102,28 @@ class basic_stream : public stream_t { basic_stream& operator<<(long value); basic_stream& operator<<(unsigned long value); basic_stream& operator<<(unsigned long long value); - basic_stream& operator<<(basic_stream const& value); - basic_stream& operator<<(std::string const& value); + basic_stream& operator<<(const basic_stream& value); + basic_stream& operator<<(const std::string& value); /** * @brief operator = * @param basic_stream obj [in] */ - basic_stream& operator=(basic_stream const& obj); - basic_stream& operator=(std::string const& str); + basic_stream& operator=(const basic_stream& obj); + basic_stream& operator=(const std::string& str); basic_stream& operator=(const char* str); /** * @brief compare * @param basic_stream obj [in] */ - int compare(basic_stream const& obj); + int compare(const basic_stream& obj); /** * @brief compare * @param basic_stream lhs [in] * @param basic_stream rhs [in] */ - static int compare(basic_stream& lhs, basic_stream& rhs); + static int compare(const basic_stream& lhs, const basic_stream& rhs); /** * @brief operator < * @param basic_stream obj [in] @@ -136,6 +137,10 @@ class basic_stream : public stream_t { bool operator==(const basic_stream& obj) const; + friend std::string& operator+=(std::string& lhs, const basic_stream& rhs); + friend std::string& operator<<(std::string& lhs, const basic_stream& rhs); + friend std::ostream& operator<<(std::ostream& lhs, const basic_stream& rhs); + protected: bufferio _bio; bufferio_context_t* _handle; diff --git a/sdk/base/stream/printf.hpp b/sdk/base/stream/printf.hpp index 29595ad0..362313e5 100644 --- a/sdk/base/stream/printf.hpp +++ b/sdk/base/stream/printf.hpp @@ -54,7 +54,7 @@ namespace hotplace { * { * myprintf_context_t context; * printf_runtime (&context, &callback_printf, "%s %i %1.1f", "sample", 1, 1.1); - * std::cout << context.str.c_str () << std::endl; + * std::cout << context.str << std::endl; * } */ diff --git a/sdk/base/string/string.hpp b/sdk/base/string/string.hpp index 14d4c9ab..06a33a39 100644 --- a/sdk/base/string/string.hpp +++ b/sdk/base/string/string.hpp @@ -22,9 +22,9 @@ namespace hotplace { * std::string data ("hello world"); * replace (data, "world", "neighbor"); */ -void replace(std::string& source, std::string const& a, std::string const& b); +void replace(std::string& source, const std::string& a, const std::string& b); #if defined _WIN32 || defined _WIN64 -void replace(std::wstring& source, std::wstring const& a, std::wstring const& b); +void replace(std::wstring& source, const std::wstring& a, const std::wstring& b); #endif // diff --git a/sdk/base/string/string_charset.cpp b/sdk/base/string/string_charset.cpp index 54e60261..a8ac47f3 100644 --- a/sdk/base/string/string_charset.cpp +++ b/sdk/base/string/string_charset.cpp @@ -17,9 +17,9 @@ namespace hotplace { #if defined _MBCS || defined MBCS -void replace(std::string& source, std::string const& a, std::string const& b) +void replace(std::string& source, const std::string& a, const std::string& b) #elif defined _UNICODE || defined UNICODE -void replace(std::wstring& source, std::wstring const& a, std::wstring const& b) +void replace(std::wstring& source, const std::wstring& a, const std::wstring& b) #endif { size_t i = source.find(a); diff --git a/sdk/base/system/linux/debug_trace.cpp b/sdk/base/system/linux/debug_trace.cpp index 89ae4983..26d71591 100644 --- a/sdk/base/system/linux/debug_trace.cpp +++ b/sdk/base/system/linux/debug_trace.cpp @@ -27,7 +27,7 @@ return_t trace(return_t errorcode) { if (trace_option_t::trace_bt & option) { basic_stream stream; debug_trace(&stream); - std::cout << stream.c_str() << std::endl; + std::cout << stream << std::endl; } } return ret; diff --git a/sdk/base/system/types.cpp b/sdk/base/system/types.cpp index fe0c7129..fb176f7a 100644 --- a/sdk/base/system/types.cpp +++ b/sdk/base/system/types.cpp @@ -102,7 +102,7 @@ return_t i32_b24(byte_t* p, uint8 len, uint32 value) { return ret; } -return_t b24_i32(uint24_t const& u, uint32& value) { return b24_i32(u.data, RTL_FIELD_SIZE(uint24_t, data), value); } +return_t b24_i32(const uint24_t& u, uint32& value) { return b24_i32(u.data, RTL_FIELD_SIZE(uint24_t, data), value); } return_t i32_b24(uint24_t& u, uint32 value) { return i32_b24(u.data, RTL_FIELD_SIZE(uint24_t, data), value); } diff --git a/sdk/base/system/types.hpp b/sdk/base/system/types.hpp index 858b83e1..ed36fe19 100644 --- a/sdk/base/system/types.hpp +++ b/sdk/base/system/types.hpp @@ -61,7 +61,7 @@ typedef struct _uint24_t { byte_t data[3]; } uint24_t; -return_t b24_i32(uint24_t const& u, uint32& value); +return_t b24_i32(const uint24_t& u, uint32& value); return_t i32_b24(uint24_t& u, uint32 value); } // namespace hotplace diff --git a/sdk/base/system/windows/debug_trace.cpp b/sdk/base/system/windows/debug_trace.cpp index e08ad1b5..36f57cae 100644 --- a/sdk/base/system/windows/debug_trace.cpp +++ b/sdk/base/system/windows/debug_trace.cpp @@ -32,7 +32,7 @@ return_t trace(return_t errorcode) { ret = dbg.trace(handle, &rtlcontext, &stream); dbg.close(handle); - std::cout << stream.c_str() << std::endl; + std::cout << stream << std::endl; } } fflush(stdout); diff --git a/sdk/base/unittest/testcase.cpp b/sdk/base/unittest/testcase.cpp index 952f9017..0183adbb 100644 --- a/sdk/base/unittest/testcase.cpp +++ b/sdk/base/unittest/testcase.cpp @@ -51,7 +51,7 @@ void test_case::begin(const char* case_name, ...) { console_colored_stream << _concolor.turnon().set_style(console_style_t::bold).set_fgcolor(console_color_t::magenta) << constexpr_testcase << topic.c_str(); console_colored_stream << _concolor.turnoff(); - std::cout << stream.c_str() << std::endl; + std::cout << stream << std::endl; reset_time(); } @@ -298,7 +298,7 @@ void test_case::test(return_t result, const char* test_function, const char* mes << format("[%s] ", test_function ? test_function : "").c_str() << tltle.c_str(); console_colored_stream << _concolor.turnoff(); - std::cout << stream.c_str() << std::endl; + std::cout << stream << std::endl; } __finally2 { reset_time(); } } @@ -400,7 +400,7 @@ void test_case::report(uint32 top_count) { // print // - std::cout << stream.c_str(); + std::cout << stream; // // file diff --git a/sdk/crypto/basic/crypto_key.hpp b/sdk/crypto/basic/crypto_key.hpp index 154c4cab..64e77bb7 100644 --- a/sdk/crypto/basic/crypto_key.hpp +++ b/sdk/crypto/basic/crypto_key.hpp @@ -33,7 +33,7 @@ class crypto_key_object { alg = _alg; } } - crypto_key_object(crypto_key_object const& key) { + crypto_key_object(const crypto_key_object& key) { pkey = key.pkey; use = key.use; kid = key.kid; diff --git a/sdk/crypto/basic/crypto_keychain.cpp b/sdk/crypto/basic/crypto_keychain.cpp index 102d7c0a..bfb3b918 100644 --- a/sdk/crypto/basic/crypto_keychain.cpp +++ b/sdk/crypto/basic/crypto_keychain.cpp @@ -169,7 +169,7 @@ return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, jwa_t return add_rsa(cryptokey, kid, hint ? hint->alg_name : nullptr, bits, use); } -return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, binary_t const& n, binary_t const& e, binary_t const& d, +return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, const binary_t& n, const binary_t& e, const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; EVP_PKEY* pkey = nullptr; @@ -226,7 +226,7 @@ return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, const return ret; } -return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, binary_t const& n, binary_t const& e, binary_t const& d, +return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, const binary_t& n, const binary_t& e, const binary_t& d, crypto_use_t use) { crypto_advisor* advisor = crypto_advisor::get_instance(); const hint_jose_encryption_t* hint = advisor->hintof_jose_algorithm(alg); @@ -234,8 +234,8 @@ return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, jwa_t return add_rsa(cryptokey, kid, hint ? hint->alg_name : nullptr, n, e, d, use); } -return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, binary_t const& n, binary_t const& e, binary_t const& d, - binary_t const& p, binary_t const& q, binary_t const& dp, binary_t const& dq, binary_t const& qi, crypto_use_t use) { +return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, const binary_t& n, const binary_t& e, const binary_t& d, + const binary_t& p, const binary_t& q, const binary_t& dp, const binary_t& dq, const binary_t& qi, crypto_use_t use) { return_t ret = errorcode_t::success; EVP_PKEY* pkey = nullptr; RSA* rsa = nullptr; @@ -320,8 +320,8 @@ return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, const return ret; } -return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, binary_t const& n, binary_t const& e, binary_t const& d, binary_t const& p, - binary_t const& q, binary_t const& dp, binary_t const& dq, binary_t const& qi, crypto_use_t use) { +return_t crypto_keychain::add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, const binary_t& n, const binary_t& e, const binary_t& d, const binary_t& p, + const binary_t& q, const binary_t& dp, const binary_t& dq, const binary_t& qi, crypto_use_t use) { crypto_advisor* advisor = crypto_advisor::get_instance(); const hint_jose_encryption_t* hint = advisor->hintof_jose_algorithm(alg); @@ -566,15 +566,15 @@ return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const c return ret; } -return_t crypto_keychain::add_ec(crypto_key* cryptokey, int nid, binary_t const& x, binary_t const& y, binary_t const& d, crypto_use_t use) { +return_t crypto_keychain::add_ec(crypto_key* cryptokey, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use) { return add_ec(cryptokey, nullptr, nullptr, nid, x, y, d, use); } -return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, int nid, binary_t const& x, binary_t const& y, binary_t const& d, crypto_use_t use) { +return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use) { return add_ec(cryptokey, kid, nullptr, nid, x, y, d, use); } -return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, binary_t const& y, binary_t const& d, +return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; @@ -595,7 +595,7 @@ return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const c return ret; } -return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, uint8 ybit, binary_t const& d, +return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, uint8 ybit, const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; @@ -616,12 +616,12 @@ return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, const c return ret; } -return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, int nid, binary_t const& x, uint8 ybit, binary_t const& d, crypto_use_t use) { +return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, int nid, const binary_t& x, uint8 ybit, const binary_t& d, crypto_use_t use) { return add_ec(cryptokey, kid, nullptr, nid, x, ybit, d, use); } -return_t crypto_keychain::add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, binary_t const& y, - binary_t const& d, crypto_use_t use) { +return_t crypto_keychain::add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, const binary_t& y, + const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; EVP_PKEY* pkey = nullptr; EC_KEY* ec = nullptr; @@ -754,7 +754,7 @@ return_t crypto_keychain::add_ec_nid_EC(crypto_key* cryptokey, const char* kid, return ret; } -return_t crypto_keychain::add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, uint8 ybit, binary_t const& d, +return_t crypto_keychain::add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, uint8 ybit, const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; EVP_PKEY* pkey = nullptr; @@ -872,7 +872,7 @@ return_t crypto_keychain::add_ec_nid_EC(crypto_key* cryptokey, const char* kid, return ret; } -return_t crypto_keychain::add_ec_nid_OKP(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, binary_t const& d, +return_t crypto_keychain::add_ec_nid_OKP(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; EVP_PKEY* pkey = nullptr; @@ -905,7 +905,7 @@ return_t crypto_keychain::add_ec_nid_OKP(crypto_key* cryptokey, const char* kid, return ret; } -return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, jwa_t alg, int nid, binary_t const& x, binary_t const& y, binary_t const& d, +return_t crypto_keychain::add_ec(crypto_key* cryptokey, const char* kid, jwa_t alg, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use) { crypto_advisor* advisor = crypto_advisor::get_instance(); const hint_jose_encryption_t* hint = advisor->hintof_jose_algorithm(alg); @@ -1250,8 +1250,8 @@ return_t crypto_keychain::add_ec(crypto_key* crypto_key, const char* kid, const return ret; } -return_t crypto_keychain::add_ec(crypto_key* crypto_key, const char* kid, const char* alg, const char* curve, binary_t const& x, binary_t const& y, - binary_t const& d, crypto_use_t use) { +return_t crypto_keychain::add_ec(crypto_key* crypto_key, const char* kid, const char* alg, const char* curve, const binary_t& x, const binary_t& y, + const binary_t& d, crypto_use_t use) { return_t ret = errorcode_t::success; __try2 { @@ -1292,13 +1292,13 @@ return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, jwa_t return add_oct(cryptokey, kid, hint ? hint->alg_name : nullptr, size, use); } -return_t crypto_keychain::add_oct(crypto_key* cryptokey, binary_t const& k, crypto_use_t use) { return add_oct(cryptokey, nullptr, nullptr, k, use); } +return_t crypto_keychain::add_oct(crypto_key* cryptokey, const binary_t& k, crypto_use_t use) { return add_oct(cryptokey, nullptr, nullptr, k, use); } -return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, binary_t const& k, crypto_use_t use) { +return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, const binary_t& k, crypto_use_t use) { return add_oct(cryptokey, kid, nullptr, k, use); } -return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, const char* alg, binary_t const& k, crypto_use_t use) { +return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, const char* alg, const binary_t& k, crypto_use_t use) { return_t ret = errorcode_t::success; EVP_PKEY* pkey = nullptr; @@ -1328,7 +1328,7 @@ return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, const return ret; } -return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, jwa_t alg, binary_t const& k, crypto_use_t use) { +return_t crypto_keychain::add_oct(crypto_key* cryptokey, const char* kid, jwa_t alg, const binary_t& k, crypto_use_t use) { crypto_advisor* advisor = crypto_advisor::get_instance(); const hint_jose_encryption_t* hint = advisor->hintof_jose_algorithm(alg); @@ -1435,7 +1435,7 @@ return_t crypto_keychain::add_oct_b16(crypto_key* crypto_key, const char* kid, c return add_oct(crypto_key, kid, alg, base16_decode(k), use); } -const EVP_PKEY* crypto_keychain::choose(crypto_key* key, std::string const& kid, crypto_kty_t kty, return_t& code) { +const EVP_PKEY* crypto_keychain::choose(crypto_key* key, const std::string& kid, crypto_kty_t kty, return_t& code) { const EVP_PKEY* pkey = nullptr; code = errorcode_t::not_exist; if (key) { diff --git a/sdk/crypto/basic/crypto_keychain.hpp b/sdk/crypto/basic/crypto_keychain.hpp index 8354e113..136183f6 100644 --- a/sdk/crypto/basic/crypto_keychain.hpp +++ b/sdk/crypto/basic/crypto_keychain.hpp @@ -144,54 +144,54 @@ class crypto_keychain { * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] * @param const char* alg [inopt] - * @param binary_t const& n [in] - * @param binary_t const& e [in] - * @param binary_t const& d [inopt] + * @param const binary_t& n [in] + * @param const binary_t& e [in] + * @param const binary_t& d [inopt] * @return error code (see error.hpp) */ - return_t add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, binary_t const& n, binary_t const& e, binary_t const& d, + return_t add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, const binary_t& n, const binary_t& e, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate rsa key * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] * @param jwa_t alg [inopt] - * @param binary_t const& n [in] - * @param binary_t const& e [in] - * @param binary_t const& d [inopt] + * @param const binary_t& n [in] + * @param const binary_t& e [in] + * @param const binary_t& d [inopt] * @return error code (see error.hpp) */ - return_t add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, binary_t const& n, binary_t const& e, binary_t const& d, + return_t add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, const binary_t& n, const binary_t& e, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate rsa key * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] * @param const char* alg [inopt] - * @param binary_t const& n [in] - * @param binary_t const& e [in] - * @param binary_t const& d [inopt] + * @param const binary_t& n [in] + * @param const binary_t& e [in] + * @param const binary_t& d [inopt] * @return error code (see error.hpp) */ - return_t add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, binary_t const& n, binary_t const& e, binary_t const& d, binary_t const& p, - binary_t const& q, binary_t const& dp, binary_t const& dq, binary_t const& qi, crypto_use_t use = crypto_use_t::use_any); + return_t add_rsa(crypto_key* cryptokey, const char* kid, const char* alg, const binary_t& n, const binary_t& e, const binary_t& d, const binary_t& p, + const binary_t& q, const binary_t& dp, const binary_t& dq, const binary_t& qi, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate rsa key * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] * @param jwa_t alg [in] - * @param binary_t const& n [in] - * @param binary_t const& e [in] - * @param binary_t const& d [inopt] - * @param binary_t const& p [inopt] - * @param binary_t const& q [inopt] - * @param binary_t const& dp [inopt] - * @param binary_t const& dq [inopt] - * @param binary_t const& qi [inopt] + * @param const binary_t& n [in] + * @param const binary_t& e [in] + * @param const binary_t& d [inopt] + * @param const binary_t& p [inopt] + * @param const binary_t& q [inopt] + * @param const binary_t& dp [inopt] + * @param const binary_t& dq [inopt] + * @param const binary_t& qi [inopt] * @return error code (see error.hpp) */ - return_t add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, binary_t const& n, binary_t const& e, binary_t const& d, binary_t const& p, - binary_t const& q, binary_t const& dp, binary_t const& dq, binary_t const& qi, crypto_use_t use = crypto_use_t::use_any); + return_t add_rsa(crypto_key* cryptokey, const char* kid, jwa_t alg, const binary_t& n, const binary_t& e, const binary_t& d, const binary_t& p, + const binary_t& q, const binary_t& dp, const binary_t& dq, const binary_t& qi, crypto_use_t use = crypto_use_t::use_any); /** * @brief add * @param crypto_key* crypto_key @@ -306,12 +306,12 @@ class crypto_keychain { * 1035: NID_X448 * 1087: NID_ED25519 * 1088: NID_ED448 - * @param binary_t const& x [in] - * @param binary_t const& y [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& x [in] + * @param const binary_t& y [in] + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec(crypto_key* cryptokey, int nid, binary_t const& x, binary_t const& y, binary_t const& d, crypto_use_t use = crypto_use_t::use_any); + return_t add_ec(crypto_key* cryptokey, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key * @param crypto_key* cryptokey [in] @@ -324,12 +324,12 @@ class crypto_keychain { * 1035: NID_X448 * 1087: NID_ED25519 * 1088: NID_ED448 - * @param binary_t const& x [in] - * @param binary_t const& y [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& x [in] + * @param const binary_t& y [in] + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec(crypto_key* cryptokey, const char* kid, int nid, binary_t const& x, binary_t const& y, binary_t const& d, + return_t add_ec(crypto_key* cryptokey, const char* kid, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key @@ -344,12 +344,12 @@ class crypto_keychain { * 1035: NID_X448 * 1087: NID_ED25519 * 1088: NID_ED448 - * @param binary_t const& x [in] - * @param binary_t const& y [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& x [in] + * @param const binary_t& y [in] + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, binary_t const& y, binary_t const& d, + return_t add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key @@ -360,12 +360,12 @@ class crypto_keychain { * 415 : NID_X9_62_prime256v1 (prime256v1) * 715 : NID_secp384r1 (secp384r1) * 716 : NID_secp521r1 (secp521r1) - * @param binary_t const& x [in] + * @param const binary_t& x [in] * @param uint8 ybit [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, uint8 ybit, binary_t const& d, + return_t add_ec(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, uint8 ybit, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key @@ -375,9 +375,9 @@ class crypto_keychain { * 415 : NID_X9_62_prime256v1 (prime256v1) * 715 : NID_secp384r1 (secp384r1) * 716 : NID_secp521r1 (secp521r1) - * @param binary_t const& x [in] + * @param const binary_t& x [in] * @param uint8 ybit [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) * @sa crypto_key::generate * @@ -387,7 +387,7 @@ class crypto_keychain { * keychain.add_ec (key, "kid", NID_ED448, crypto_use_t::use_sig); // ok * */ - return_t add_ec(crypto_key* cryptokey, const char* kid, int nid, binary_t const& x, uint8 ybit, binary_t const& d, + return_t add_ec(crypto_key* cryptokey, const char* kid, int nid, const binary_t& x, uint8 ybit, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key @@ -398,12 +398,12 @@ class crypto_keychain { * 415 : NID_X9_62_prime256v1 (prime256v1) * 715 : NID_secp384r1 (secp384r1) * 716 : NID_secp521r1 (secp521r1) - * @param binary_t const& x [in] - * @param binary_t const& y [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& x [in] + * @param const binary_t& y [in] + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, binary_t const& y, binary_t const& d, + return_t add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key @@ -414,12 +414,12 @@ class crypto_keychain { * 415 : NID_X9_62_prime256v1 (prime256v1) * 715 : NID_secp384r1 (secp384r1) * 716 : NID_secp521r1 (secp521r1) - * @param binary_t const& x [in] + * @param const binary_t& x [in] * @param uint8 ybit [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, uint8 ybit, binary_t const& d, + return_t add_ec_nid_EC(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, uint8 ybit, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate Ed25519, Ed448 @@ -431,9 +431,9 @@ class crypto_keychain { * 1035: NID_X448 * 1087: NID_ED25519 * 1088: NID_ED448 - * @param binary_t const& x [in] - * @param binary_t const& y [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& x [in] + * @param const binary_t& y [in] + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) * @remarks * 1 EdDSA provides high performance on a variety of platforms; @@ -450,7 +450,7 @@ class crypto_keychain { * Ed25519 and Ed448 use small private keys (32 or 57 bytes respectively), small public keys (32 or 57 bytes) * and small signatures (64 or 114 bytes) with high security level at the same time (128-bit or 224-bit respectively). */ - return_t add_ec_nid_OKP(crypto_key* cryptokey, const char* kid, const char* alg, int nid, binary_t const& x, binary_t const& d, + return_t add_ec_nid_OKP(crypto_key* cryptokey, const char* kid, const char* alg, int nid, const binary_t& x, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate ec key @@ -465,12 +465,12 @@ class crypto_keychain { * 1035: NID_X448 * 1087: NID_ED25519 * 1088: NID_ED448 - * @param binary_t const& x [in] - * @param binary_t const& y [in] - * @param binary_t const& d [inopt] private key + * @param const binary_t& x [in] + * @param const binary_t& y [in] + * @param const binary_t& d [inopt] private key * @return error code (see error.hpp) */ - return_t add_ec(crypto_key* cryptokey, const char* kid, jwa_t alg, int nid, binary_t const& x, binary_t const& y, binary_t const& d, + return_t add_ec(crypto_key* cryptokey, const char* kid, jwa_t alg, int nid, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** * @brief add @@ -518,7 +518,7 @@ class crypto_keychain { const byte_t* d, size_t size_d, crypto_use_t use = crypto_use_t::use_any); return_t add_ec(crypto_key* crypto_key, const char* kid, const char* alg, int nid, const byte_t* x, size_t size_x, const byte_t* y, size_t size_y, const byte_t* d, size_t size_d, crypto_use_t use = crypto_use_t::use_any); - return_t add_ec(crypto_key* crypto_key, const char* kid, const char* alg, const char* curve, binary_t const& x, binary_t const& y, binary_t const& d, + return_t add_ec(crypto_key* crypto_key, const char* kid, const char* alg, const char* curve, const binary_t& x, const binary_t& y, const binary_t& d, crypto_use_t use = crypto_use_t::use_any); /** @@ -558,36 +558,36 @@ class crypto_keychain { /** * @brief generate hmac key * @param crypto_key* cryptokey [in] - * @param binary_t const& k [in] + * @param const binary_t& k [in] * @return error code (see error.hpp) */ - return_t add_oct(crypto_key* cryptokey, binary_t const& k, crypto_use_t use = crypto_use_t::use_any); + return_t add_oct(crypto_key* cryptokey, const binary_t& k, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate hmac key * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] - * @param binary_t const& k [in] + * @param const binary_t& k [in] * @return error code (see error.hpp) */ - return_t add_oct(crypto_key* cryptokey, const char* kid, binary_t const& k, crypto_use_t use = crypto_use_t::use_any); + return_t add_oct(crypto_key* cryptokey, const char* kid, const binary_t& k, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate hmac key * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] * @param const char* alg [inopt] - * @param binary_t const& k [in] + * @param const binary_t& k [in] * @return error code (see error.hpp) */ - return_t add_oct(crypto_key* cryptokey, const char* kid, const char* alg, binary_t const& k, crypto_use_t use = crypto_use_t::use_any); + return_t add_oct(crypto_key* cryptokey, const char* kid, const char* alg, const binary_t& k, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate hmac key * @param crypto_key* cryptokey [in] * @param const char* kid [inopt] * @param jwa_t alg [in] - * @param binary_t const& k [in] + * @param const binary_t& k [in] * @return error code (see error.hpp) */ - return_t add_oct(crypto_key* cryptokey, const char* kid, jwa_t alg, binary_t const& k, crypto_use_t use = crypto_use_t::use_any); + return_t add_oct(crypto_key* cryptokey, const char* kid, jwa_t alg, const binary_t& k, crypto_use_t use = crypto_use_t::use_any); /** * @brief generate hmac key * @param crypto_key* cryptokey [in] @@ -645,7 +645,7 @@ class crypto_keychain { /** * @brief return key * @param crypto_key* key [in] - * @param std::string const& kid [in] + * @param const std::string& kid [in] * @param crypto_kty_t kty [in] * @param return_t& code [out] * @remarks @@ -653,7 +653,7 @@ class crypto_keychain { * return key, errorcode_t::inaccurate : not found kid, but kty exists * return nullptr, errorcode_t::not_exist : not exist kid nor kty */ - const EVP_PKEY* choose(crypto_key* key, std::string const& kid, crypto_kty_t kty, return_t& code); + const EVP_PKEY* choose(crypto_key* key, const std::string& kid, crypto_kty_t kty, return_t& code); protected: }; diff --git a/sdk/crypto/basic/debug_trace.cpp b/sdk/crypto/basic/debug_trace.cpp index 45f2b783..6ba78a3b 100644 --- a/sdk/crypto/basic/debug_trace.cpp +++ b/sdk/crypto/basic/debug_trace.cpp @@ -27,7 +27,7 @@ return_t trace_openssl(return_t errorcode) { if (trace_option_t::trace_bt & option) { ansi_string stream; debug_trace_openssl(&stream); - std::cout << stream.c_str(); + std::cout << stream; } } return ret; diff --git a/sdk/crypto/basic/dump_key.cpp b/sdk/crypto/basic/dump_key.cpp index 57a0e0c5..ec94d12a 100644 --- a/sdk/crypto/basic/dump_key.cpp +++ b/sdk/crypto/basic/dump_key.cpp @@ -21,7 +21,7 @@ namespace hotplace { using namespace io; namespace crypto { -static void pkey_param_printf(crypt_item_t type, binary_t const& key, stream_t* stream, uint8 hex_part, uint8 indent) { +static void pkey_param_printf(crypt_item_t type, const binary_t& key, stream_t* stream, uint8 hex_part, uint8 indent) { constexpr char constexpr_hmac[] = "k"; constexpr char constexpr_rsa_n[] = "modulus (00:n)"; diff --git a/sdk/crypto/basic/openssl_aead.cpp b/sdk/crypto/basic/openssl_aead.cpp index bc2cd45e..e18cbbb9 100644 --- a/sdk/crypto/basic/openssl_aead.cpp +++ b/sdk/crypto/basic/openssl_aead.cpp @@ -24,8 +24,8 @@ namespace crypto { openssl_aead::openssl_aead() {} -return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, binary_t const& k, binary_t const& iv, binary_t const& a, - binary_t const& p, binary_t& q, binary_t& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, const binary_t& k, const binary_t& iv, const binary_t& a, + const binary_t& p, binary_t& q, binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); __try2 { @@ -111,8 +111,8 @@ return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& k, - binary_t const& iv, binary_t const& a, binary_t const& p, binary_t& q, binary_t& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& k, + const binary_t& iv, const binary_t& a, const binary_t& p, binary_t& q, binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); const char* enc_algname = advisor->nameof_cipher(enc_alg, enc_mode); @@ -121,8 +121,8 @@ return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, cryp return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, binary_t const& enc_k, binary_t const& mac_k, binary_t const& iv, - binary_t const& a, binary_t const& p, binary_t& q, binary_t& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, const binary_t& enc_k, const binary_t& mac_k, const binary_t& iv, + const binary_t& a, const binary_t& p, binary_t& q, binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); __try2 { @@ -166,8 +166,8 @@ return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& enc_k, - binary_t const& mac_k, binary_t const& iv, binary_t const& a, binary_t const& p, binary_t& q, binary_t& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& enc_k, + const binary_t& mac_k, const binary_t& iv, const binary_t& a, const binary_t& p, binary_t& q, binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); __try2 { @@ -181,8 +181,8 @@ return_t openssl_aead::aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, cryp return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, binary_t const& k, binary_t const& iv, binary_t const& a, - binary_t const& q, binary_t& p, binary_t const& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, const binary_t& k, const binary_t& iv, const binary_t& a, + const binary_t& q, binary_t& p, const binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); __try2 { @@ -273,8 +273,8 @@ return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& k, - binary_t const& iv, binary_t const& a, binary_t const& q, binary_t& p, binary_t const& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& k, + const binary_t& iv, const binary_t& a, const binary_t& q, binary_t& p, const binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); const char* enc_algname = advisor->nameof_cipher(enc_alg, enc_mode); @@ -283,8 +283,8 @@ return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, cryp return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, binary_t const& enc_k, binary_t const& mac_k, binary_t const& iv, - binary_t const& a, binary_t const& q, binary_t& p, binary_t const& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, const binary_t& enc_k, const binary_t& mac_k, const binary_t& iv, + const binary_t& a, const binary_t& q, binary_t& p, const binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); __try2 { @@ -328,9 +328,9 @@ return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char return ret; } -return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& enc_k, - binary_t const& mac_k, binary_t const& iv, binary_t const& a, binary_t const& q, binary_t& p, - binary_t const& t) { +return_t openssl_aead::aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& enc_k, + const binary_t& mac_k, const binary_t& iv, const binary_t& a, const binary_t& q, binary_t& p, + const binary_t& t) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); __try2 { diff --git a/sdk/crypto/basic/openssl_crypt.cpp b/sdk/crypto/basic/openssl_crypt.cpp index 8b754447..49c3ca2c 100644 --- a/sdk/crypto/basic/openssl_crypt.cpp +++ b/sdk/crypto/basic/openssl_crypt.cpp @@ -216,11 +216,11 @@ return_t openssl_crypt::open(crypt_context_t** handle, crypt_algorithm_t algorit return ret; } -return_t openssl_crypt::open(crypt_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv) { +return_t openssl_crypt::open(crypt_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv) { return open(handle, algorithm, mode, &key[0], key.size(), &iv[0], iv.size()); } -return_t openssl_crypt::open(crypt_context_t** handle, const char* cipher, binary_t const& key, binary_t const& iv) { +return_t openssl_crypt::open(crypt_context_t** handle, const char* cipher, const binary_t& key, const binary_t& iv) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -341,7 +341,7 @@ return_t openssl_crypt::encrypt(crypt_context_t* handle, const unsigned char* da return encrypt2(handle, data_plain, size_plain, out_encrypted); } -return_t openssl_crypt::encrypt(crypt_context_t* handle, binary_t const& input, binary_t& out) { return encrypt(handle, &input[0], input.size(), out); } +return_t openssl_crypt::encrypt(crypt_context_t* handle, const binary_t& input, binary_t& out) { return encrypt(handle, &input[0], input.size(), out); } return_t openssl_crypt::encrypt2(crypt_context_t* handle, const unsigned char* data_plain, size_t size_plain, binary_t& out_encrypted, const binary_t* aad, binary_t* tag) { @@ -367,7 +367,7 @@ return_t openssl_crypt::encrypt2(crypt_context_t* handle, const unsigned char* d return ret; } -return_t openssl_crypt::encrypt2(crypt_context_t* handle, binary_t const& data_plain, binary_t& out_encrypted, const binary_t* aad, binary_t* tag) { +return_t openssl_crypt::encrypt2(crypt_context_t* handle, const binary_t& data_plain, binary_t& out_encrypted, const binary_t* aad, binary_t* tag) { return encrypt2(handle, &data_plain[0], data_plain.size(), out_encrypted, aad, tag); } @@ -578,7 +578,7 @@ return_t openssl_crypt::decrypt(crypt_context_t* handle, const unsigned char* da return decrypt2(handle, data_encrypted, size_encrypted, out_decrypted); } -return_t openssl_crypt::decrypt(crypt_context_t* handle, binary_t const& input, binary_t& out_decrypted) { +return_t openssl_crypt::decrypt(crypt_context_t* handle, const binary_t& input, binary_t& out_decrypted) { return decrypt2(handle, &input[0], input.size(), out_decrypted); } @@ -606,7 +606,7 @@ return_t openssl_crypt::decrypt2(crypt_context_t* handle, const unsigned char* d return ret; } -return_t openssl_crypt::decrypt2(crypt_context_t* handle, binary_t const& data_encrypted, binary_t& out_decrypted, const binary_t* aad, const binary_t* tag) { +return_t openssl_crypt::decrypt2(crypt_context_t* handle, const binary_t& data_encrypted, binary_t& out_decrypted, const binary_t* aad, const binary_t* tag) { return decrypt2(handle, &data_encrypted[0], data_encrypted.size(), out_decrypted, aad, tag); } @@ -754,7 +754,7 @@ return_t openssl_crypt::free_data(unsigned char* data) { return ret; } -return_t openssl_crypt::encrypt(const EVP_PKEY* pkey, binary_t const& input, binary_t& output, crypt_enc_t mode) { +return_t openssl_crypt::encrypt(const EVP_PKEY* pkey, const binary_t& input, binary_t& output, crypt_enc_t mode) { return_t ret = errorcode_t::success; EVP_PKEY_CTX* pkey_context = nullptr; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -843,7 +843,7 @@ return_t openssl_crypt::encrypt(const EVP_PKEY* pkey, binary_t const& input, bin return ret; } -return_t openssl_crypt::decrypt(const EVP_PKEY* pkey, binary_t const& input, binary_t& output, crypt_enc_t mode) { +return_t openssl_crypt::decrypt(const EVP_PKEY* pkey, const binary_t& input, binary_t& output, crypt_enc_t mode) { return_t ret = errorcode_t::success; EVP_PKEY_CTX* pkey_context = nullptr; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -979,7 +979,7 @@ return_t openssl_crypt::query(crypt_context_t* handle, size_t cmd, size_t& value return ret; } -return_t openssl_crypt::encrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& plaintext, binary_t& ciphertext, +return_t openssl_crypt::encrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1002,7 +1002,7 @@ return_t openssl_crypt::encrypt(const char* alg, binary_t const& key, binary_t c return ret; } -return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& plaintext, +return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1025,7 +1025,7 @@ return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, return ret; } -return_t openssl_crypt::encrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& plaintext, binary_t& ciphertext, binary_t const& aad, +return_t openssl_crypt::encrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, const binary_t& aad, binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1048,8 +1048,8 @@ return_t openssl_crypt::encrypt(const char* alg, binary_t const& key, binary_t c return ret; } -return_t openssl_crypt::encrypt(const char* alg, binary_t const& key, binary_t const& iv, const unsigned char* plaintext, size_t size_plaintext, - binary_t& ciphertext, binary_t const& aad, binary_t& tag, encrypt_option_t* options) { +return_t openssl_crypt::encrypt(const char* alg, const binary_t& key, const binary_t& iv, const unsigned char* plaintext, size_t size_plaintext, + binary_t& ciphertext, const binary_t& aad, binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1071,8 +1071,8 @@ return_t openssl_crypt::encrypt(const char* alg, binary_t const& key, binary_t c return ret; } -return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& plaintext, - binary_t& ciphertext, binary_t const& aad, binary_t& tag, encrypt_option_t* options) { +return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& plaintext, + binary_t& ciphertext, const binary_t& aad, binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1093,8 +1093,8 @@ return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, __finally2 { close(crypt_handle); } return ret; } -return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, const unsigned char* plaintext, - size_t size_plaintext, binary_t& ciphertext, binary_t const& aad, binary_t& tag, encrypt_option_t* options) { +return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const unsigned char* plaintext, + size_t size_plaintext, binary_t& ciphertext, const binary_t& aad, binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1116,7 +1116,7 @@ return_t openssl_crypt::encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, return ret; } -return_t openssl_crypt::decrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, binary_t& plaintext, +return_t openssl_crypt::decrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1139,7 +1139,7 @@ return_t openssl_crypt::decrypt(const char* alg, binary_t const& key, binary_t c return ret; } -return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, +return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1162,8 +1162,8 @@ return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, return ret; } -return_t openssl_crypt::decrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, binary_t& plaintext, binary_t const& aad, - binary_t const& tag, encrypt_option_t* options) { +return_t openssl_crypt::decrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, const binary_t& aad, + const binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1185,8 +1185,8 @@ return_t openssl_crypt::decrypt(const char* alg, binary_t const& key, binary_t c return ret; } -return_t openssl_crypt::decrypt(const char* alg, binary_t const& key, binary_t const& iv, const unsigned char* ciphertext, size_t size_ciphertext, - binary_t& plaintext, binary_t const& aad, binary_t const& tag, encrypt_option_t* options) { +return_t openssl_crypt::decrypt(const char* alg, const binary_t& key, const binary_t& iv, const unsigned char* ciphertext, size_t size_ciphertext, + binary_t& plaintext, const binary_t& aad, const binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1208,8 +1208,8 @@ return_t openssl_crypt::decrypt(const char* alg, binary_t const& key, binary_t c return ret; } -return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, - binary_t& plaintext, binary_t const& aad, binary_t const& tag, encrypt_option_t* options) { +return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, + binary_t& plaintext, const binary_t& aad, const binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1231,8 +1231,8 @@ return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, return ret; } -return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, const unsigned char* ciphertext, - size_t size_ciphertext, binary_t& plaintext, binary_t const& aad, binary_t const& tag, encrypt_option_t* options) { +return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const unsigned char* ciphertext, + size_t size_ciphertext, binary_t& plaintext, const binary_t& aad, const binary_t& tag, encrypt_option_t* options) { return_t ret = errorcode_t::success; crypt_context_t* crypt_handle = nullptr; @@ -1254,7 +1254,7 @@ return_t openssl_crypt::decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, return ret; } -return_t openssl_chacha20_iv(binary_t& iv, uint32 counter, binary_t const& nonce) { return openssl_chacha20_iv(iv, counter, &nonce[0], nonce.size()); } +return_t openssl_chacha20_iv(binary_t& iv, uint32 counter, const binary_t& nonce) { return openssl_chacha20_iv(iv, counter, &nonce[0], nonce.size()); } return_t openssl_chacha20_iv(binary_t& iv, uint32 counter, const byte_t* nonce, size_t nonce_size) { return_t ret = errorcode_t::success; diff --git a/sdk/crypto/basic/openssl_crypt.hpp b/sdk/crypto/basic/openssl_crypt.hpp index d6c68154..66639302 100644 --- a/sdk/crypto/basic/openssl_crypt.hpp +++ b/sdk/crypto/basic/openssl_crypt.hpp @@ -101,20 +101,20 @@ class openssl_crypt : public crypt_t { * @param crypt_context_t** handle [out] * @param crypt_algorithm_t algorithm [in] * @param crypt_mode_t mode [in] - * @param binary_t const& key [in] - * @param binary_t const& iv [in] + * @param const binary_t& key [in] + * @param const binary_t& iv [in] * @return error code (see error.hpp) */ - virtual return_t open(crypt_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv); + virtual return_t open(crypt_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv); /** * @brief create a context handle (symmetric) * @param crypt_context_t** handle [out] * @param const char* cipher [in] ex. "aes-128-cbc" - * @param binary_t const& key [in] - * @param binary_t const& iv [in] + * @param const binary_t& key [in] + * @param const binary_t& iv [in] * @return error code (see error.hpp) */ - virtual return_t open(crypt_context_t** handle, const char* cipher, binary_t const& key, binary_t const& iv); + virtual return_t open(crypt_context_t** handle, const char* cipher, const binary_t& key, const binary_t& iv); /** * @brief destroy a context handle * @param crypt_context_t* handle [in] @@ -158,11 +158,11 @@ class openssl_crypt : public crypt_t { /** * @brief encrypt * @param crypt_context_t* handle [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& out [out] * @return error code (see error.hpp) */ - virtual return_t encrypt(crypt_context_t* handle, binary_t const& input, binary_t& out); + virtual return_t encrypt(crypt_context_t* handle, const binary_t& input, binary_t& out); /** * @brief encrypt (GCM/CCM) * @param crypt_context_t* handle [in] @@ -178,13 +178,13 @@ class openssl_crypt : public crypt_t { /** * @brief encrypt (GCM/CCM) * @param crypt_context_t* handle [in] - * @param binary_t const& plain [in] + * @param const binary_t& plain [in] * @param binary_t& out_encrypte [out] * @param binary_t* aad [inopt] * @param binary_t* tag [outopt] * @return error code (see error.hpp) */ - virtual return_t encrypt2(crypt_context_t* handle, binary_t const& plain, binary_t& out_encrypted, const binary_t* aad = nullptr, binary_t* tag = nullptr); + virtual return_t encrypt2(crypt_context_t* handle, const binary_t& plain, binary_t& out_encrypted, const binary_t* aad = nullptr, binary_t* tag = nullptr); /** * @brief encrypt * @param crypt_context_t* handle [in] @@ -226,12 +226,12 @@ class openssl_crypt : public crypt_t { /** * @brief decrypt * @param crypt_context_t* handle [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& out [out] * @return error code (see error.hpp) * @return error code (see error.hpp) */ - virtual return_t decrypt(crypt_context_t* handle, binary_t const& input, binary_t& out); + virtual return_t decrypt(crypt_context_t* handle, const binary_t& input, binary_t& out); /** * @brief decrypt (GCM/CCOM) @@ -248,13 +248,13 @@ class openssl_crypt : public crypt_t { /** * @brief decrypt (GCM/CCOM) * @param crypt_context_t* handle [in] - * @param binary_t const& data_encrypted [in] + * @param const binary_t& data_encrypted [in] * @param binary_t& out_decrypted [out] * @param binary_t* aad [inpot] * @param binary_t* tag [inopt] * @return error code (see error.hpp) */ - virtual return_t decrypt2(crypt_context_t* handle, binary_t const& data_encrypted, binary_t& out_decrypted, const binary_t* aad = nullptr, + virtual return_t decrypt2(crypt_context_t* handle, const binary_t& data_encrypted, binary_t& out_decrypted, const binary_t* aad = nullptr, const binary_t* tag = nullptr); /** * @brief decrypt @@ -279,21 +279,21 @@ class openssl_crypt : public crypt_t { /** * @biref asymmetric encrypt * @param const EVP_PKEY* pkey [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @param crypt_enc_t mode [in] * @return error code (see error.hpp) */ - return_t encrypt(const EVP_PKEY* pkey, binary_t const& input, binary_t& output, crypt_enc_t mode); + return_t encrypt(const EVP_PKEY* pkey, const binary_t& input, binary_t& output, crypt_enc_t mode); /** * @biref asymmetric decrypt * @param const EVP_PKEY* pkey [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @param crypt_enc_t mode [in] * @return error code (see error.hpp) */ - return_t decrypt(const EVP_PKEY* pkey, binary_t const& input, binary_t& output, crypt_enc_t mode); + return_t decrypt(const EVP_PKEY* pkey, const binary_t& input, binary_t& output, crypt_enc_t mode); /** * @brief simple api @@ -304,30 +304,30 @@ class openssl_crypt : public crypt_t { * }; * encrypt("aes-128-cbc", cek, iv, plaintext, ciphertext, options); */ - return_t encrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& plaintext, binary_t& ciphertext, + return_t encrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, encrypt_option_t* options = nullptr); - return_t encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& plaintext, binary_t& ciphertext, + return_t encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, encrypt_option_t* options = nullptr); - return_t encrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& plaintext, binary_t& ciphertext, binary_t const& aad, + return_t encrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, const binary_t& aad, binary_t& tag, encrypt_option_t* options = nullptr); - return_t encrypt(const char* alg, binary_t const& key, binary_t const& iv, const unsigned char* plaintext, size_t size_plaintext, binary_t& ciphertext, - binary_t const& aad, binary_t& tag, encrypt_option_t* options = nullptr); - return_t encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& plaintext, binary_t& ciphertext, - binary_t const& aad, binary_t& tag, encrypt_option_t* options = nullptr); - return_t encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, const unsigned char* plaintext, - size_t size_plaintext, binary_t& ciphertext, binary_t const& aad, binary_t& tag, encrypt_option_t* options = nullptr); - return_t decrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, binary_t& plaintext, + return_t encrypt(const char* alg, const binary_t& key, const binary_t& iv, const unsigned char* plaintext, size_t size_plaintext, binary_t& ciphertext, + const binary_t& aad, binary_t& tag, encrypt_option_t* options = nullptr); + return_t encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& plaintext, binary_t& ciphertext, + const binary_t& aad, binary_t& tag, encrypt_option_t* options = nullptr); + return_t encrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const unsigned char* plaintext, + size_t size_plaintext, binary_t& ciphertext, const binary_t& aad, binary_t& tag, encrypt_option_t* options = nullptr); + return_t decrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, encrypt_option_t* options = nullptr); - return_t decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, binary_t& plaintext, + return_t decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, encrypt_option_t* options = nullptr); - return_t decrypt(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, binary_t& plaintext, binary_t const& aad, - binary_t const& tag, encrypt_option_t* options = nullptr); - return_t decrypt(const char* alg, binary_t const& key, binary_t const& iv, const unsigned char* ciphertext, size_t size_ciphertext, binary_t& plaintext, - binary_t const& aad, binary_t const& tag, encrypt_option_t* options = nullptr); - return_t decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, binary_t const& ciphertext, binary_t& plaintext, - binary_t const& aad, binary_t const& tag, encrypt_option_t* options = nullptr); - return_t decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv, const unsigned char* ciphertext, - size_t size_ciphertext, binary_t& plaintext, binary_t const& aad, binary_t const& tag, encrypt_option_t* options = nullptr); + return_t decrypt(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, const binary_t& aad, + const binary_t& tag, encrypt_option_t* options = nullptr); + return_t decrypt(const char* alg, const binary_t& key, const binary_t& iv, const unsigned char* ciphertext, size_t size_ciphertext, binary_t& plaintext, + const binary_t& aad, const binary_t& tag, encrypt_option_t* options = nullptr); + return_t decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const binary_t& ciphertext, binary_t& plaintext, + const binary_t& aad, const binary_t& tag, encrypt_option_t* options = nullptr); + return_t decrypt(crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv, const unsigned char* ciphertext, + size_t size_ciphertext, binary_t& plaintext, const binary_t& aad, const binary_t& tag, encrypt_option_t* options = nullptr); /** * @brief deprecated - expect block operation size @@ -409,7 +409,7 @@ class openssl_crypt : public crypt_t { * crypt.close (handle); * } */ -return_t openssl_chacha20_iv(binary_t& iv, uint32 counter, binary_t const& nonce); +return_t openssl_chacha20_iv(binary_t& iv, uint32 counter, const binary_t& nonce); return_t openssl_chacha20_iv(binary_t& iv, uint32 counter, const byte_t* nonce, size_t nonce_size); /** @@ -428,10 +428,10 @@ class openssl_aead { * @brief Authenticated Encryption with AES-CBC and HMAC-SHA * @param const char* enc_alg [in] "aes-128-cbc" * @param const char* mac_alg [in] "sha256" - * @param binary_t const& k [in] MAC_KEY || ENC_KEY - * @param binary_t const& iv [in] iv - * @param binary_t const& a [in] aad - * @param binary_t const& p [in] plaintext + * @param const binary_t& k [in] MAC_KEY || ENC_KEY + * @param const binary_t& iv [in] iv + * @param const binary_t& a [in] aad + * @param const binary_t& p [in] plaintext * @param binary_t& q [out] ciphertext * @param binary_t& t [out] AE tag * @return error code (see error.hpp) @@ -443,28 +443,28 @@ class openssl_aead { * * @sa RFC 7516 Appendix B. Example AES_128_CBC_HMAC_SHA_256 Computation */ - return_t aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, binary_t const& k, binary_t const& iv, binary_t const& a, binary_t const& p, + return_t aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, const binary_t& k, const binary_t& iv, const binary_t& a, const binary_t& p, binary_t& q, binary_t& t); - return_t aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& k, binary_t const& iv, - binary_t const& a, binary_t const& p, binary_t& q, binary_t& t); + return_t aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& k, const binary_t& iv, + const binary_t& a, const binary_t& p, binary_t& q, binary_t& t); /** * @brief Authenticated Encryption with AES-CBC and HMAC-SHA * @return error code (see error.hpp) * @desc each ENC_KEY, MAC_KEY */ - return_t aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, binary_t const& enc_k, binary_t const& mac_k, binary_t const& iv, - binary_t const& a, binary_t const& p, binary_t& q, binary_t& t); - return_t aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& enc_k, binary_t const& mac_k, - binary_t const& iv, binary_t const& a, binary_t const& p, binary_t& q, binary_t& t); + return_t aes_cbc_hmac_sha2_encrypt(const char* enc_alg, const char* mac_alg, const binary_t& enc_k, const binary_t& mac_k, const binary_t& iv, + const binary_t& a, const binary_t& p, binary_t& q, binary_t& t); + return_t aes_cbc_hmac_sha2_encrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& enc_k, const binary_t& mac_k, + const binary_t& iv, const binary_t& a, const binary_t& p, binary_t& q, binary_t& t); /** * @brief Authenticated Encryption with AES-CBC and HMAC-SHA * @param const char* enc_alg [in] "aes-128-cbc" * @param const char* mac_alg [in] "sha256" - * @param binary_t const& k [in] MAC_KEY || ENC_KEY - * @param binary_t const& iv [in] iv - * @param binary_t const& a [in] aad - * @param binary_t const& q [in] ciphertext + * @param const binary_t& k [in] MAC_KEY || ENC_KEY + * @param const binary_t& iv [in] iv + * @param const binary_t& a [in] aad + * @param const binary_t& q [in] ciphertext * @param binary_t& p [out] plaintext * @param binary_t& t [in] AE tag * @return error code (see error.hpp) @@ -474,19 +474,19 @@ class openssl_aead { * ENC_KEY = final ENC_KEY_LEN bytes of K * @sa RFC 7516 Appendix B. Example AES_128_CBC_HMAC_SHA_256 Computation */ - return_t aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, binary_t const& k, binary_t const& iv, binary_t const& a, binary_t const& q, - binary_t& p, binary_t const& t); - return_t aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& k, binary_t const& iv, - binary_t const& a, binary_t const& q, binary_t& p, binary_t const& t); + return_t aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, const binary_t& k, const binary_t& iv, const binary_t& a, const binary_t& q, + binary_t& p, const binary_t& t); + return_t aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& k, const binary_t& iv, + const binary_t& a, const binary_t& q, binary_t& p, const binary_t& t); /** * @brief Authenticated Encryption with AES-CBC and HMAC-SHA * @return error code (see error.hpp) * @desc each ENC_KEY, MAC_KEY */ - return_t aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, binary_t const& enc_k, binary_t const& mac_k, binary_t const& iv, - binary_t const& a, binary_t const& q, binary_t& p, binary_t const& t); - return_t aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, binary_t const& enc_k, binary_t const& mac_k, - binary_t const& iv, binary_t const& a, binary_t const& q, binary_t& p, binary_t const& t); + return_t aes_cbc_hmac_sha2_decrypt(const char* enc_alg, const char* mac_alg, const binary_t& enc_k, const binary_t& mac_k, const binary_t& iv, + const binary_t& a, const binary_t& q, binary_t& p, const binary_t& t); + return_t aes_cbc_hmac_sha2_decrypt(crypt_algorithm_t enc_alg, crypt_mode_t enc_mode, hash_algorithm_t mac_alg, const binary_t& enc_k, const binary_t& mac_k, + const binary_t& iv, const binary_t& a, const binary_t& q, binary_t& p, const binary_t& t); }; } // namespace crypto diff --git a/sdk/crypto/basic/openssl_hash.cpp b/sdk/crypto/basic/openssl_hash.cpp index 1a585a62..f093aa23 100644 --- a/sdk/crypto/basic/openssl_hash.cpp +++ b/sdk/crypto/basic/openssl_hash.cpp @@ -80,7 +80,7 @@ return_t openssl_hash::open(hash_context_t** handle, const char* algorithm, cons return ret; } -return_t openssl_hash::open(hash_context_t** handle, const char* algorithm, binary_t const& key) { return open(handle, algorithm, &key[0], key.size()); } +return_t openssl_hash::open(hash_context_t** handle, const char* algorithm, const binary_t& key) { return open(handle, algorithm, &key[0], key.size()); } return_t openssl_hash::open(hash_context_t** handle, hash_algorithm_t algorithm, const unsigned char* key_data, unsigned key_size) { return_t ret = errorcode_t::success; @@ -156,7 +156,7 @@ return_t openssl_hash::open(hash_context_t** handle, hash_algorithm_t algorithm, return ret; } -return_t openssl_hash::open(hash_context_t** handle, hash_algorithm_t algorithm, binary_t const& key) { return open(handle, algorithm, &key[0], key.size()); } +return_t openssl_hash::open(hash_context_t** handle, hash_algorithm_t algorithm, const binary_t& key) { return open(handle, algorithm, &key[0], key.size()); } return_t openssl_hash::open(hash_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, const unsigned char* key_data, unsigned key_size) { return_t ret = errorcode_t::success; @@ -217,7 +217,7 @@ return_t openssl_hash::open(hash_context_t** handle, crypt_algorithm_t algorithm return ret; } -return_t openssl_hash::open(hash_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key) { +return_t openssl_hash::open(hash_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key) { return open(handle, algorithm, mode, &key[0], key.size()); } @@ -321,7 +321,7 @@ return_t openssl_hash::update(hash_context_t* handle, const byte_t* source_data, return ret; } -return_t openssl_hash::update(hash_context_t* handle, binary_t const& input) { return update(handle, &input[0], input.size()); } +return_t openssl_hash::update(hash_context_t* handle, const binary_t& input) { return update(handle, &input[0], input.size()); } return_t openssl_hash::finalize(hash_context_t* handle, byte_t** hash_data, size_t* hash_size) { return_t ret = errorcode_t::success; @@ -489,7 +489,7 @@ crypt_poweredby_t openssl_hash::get_type() { return crypt_poweredby_t::openssl; openssl_digest::openssl_digest() : openssl_hash() {} -return_t openssl_digest::digest(const char* alg, binary_t const& input, binary_t& output) { +return_t openssl_digest::digest(const char* alg, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -507,7 +507,7 @@ return_t openssl_digest::digest(const char* alg, binary_t const& input, binary_t return ret; } -return_t openssl_digest::digest(hash_algorithm_t alg, binary_t const& input, binary_t& output) { +return_t openssl_digest::digest(hash_algorithm_t alg, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -525,7 +525,7 @@ return_t openssl_digest::digest(hash_algorithm_t alg, binary_t const& input, bin return ret; } -return_t openssl_digest::digest(const char* alg, basic_stream const& input, binary_t& output) { +return_t openssl_digest::digest(const char* alg, const basic_stream& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -542,7 +542,7 @@ return_t openssl_digest::digest(const char* alg, basic_stream const& input, bina return ret; } -return_t openssl_digest::digest(const char* alg, basic_stream const& input, std::string& hashstring, encoding_t encoding) { +return_t openssl_digest::digest(const char* alg, const basic_stream& input, std::string& hashstring, encoding_t encoding) { return_t ret = errorcode_t::success; binary_t output; ret = digest(alg, input, output); @@ -556,7 +556,7 @@ return_t openssl_digest::digest(const char* alg, basic_stream const& input, std: return ret; } -return_t openssl_digest::digest(const char* alg, std::string const& input, binary_t& output) { +return_t openssl_digest::digest(const char* alg, const std::string& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -573,7 +573,7 @@ return_t openssl_digest::digest(const char* alg, std::string const& input, binar return ret; } -return_t openssl_digest::digest(const char* alg, std::string const& input, std::string& hashstring, encoding_t encoding) { +return_t openssl_digest::digest(const char* alg, const std::string& input, std::string& hashstring, encoding_t encoding) { return_t ret = errorcode_t::success; binary_t output; ret = digest(alg, input, output); diff --git a/sdk/crypto/basic/openssl_hash.hpp b/sdk/crypto/basic/openssl_hash.hpp index 754d6bee..97b3153e 100644 --- a/sdk/crypto/basic/openssl_hash.hpp +++ b/sdk/crypto/basic/openssl_hash.hpp @@ -69,9 +69,9 @@ class openssl_hash : public hash_t { * @brief open (HMAC, CMAC) * @param hash_context_t** handle [out] * @param const char* algorithm [in] - * @param binary_t const& key [in] + * @param const binary_t& key [in] */ - virtual return_t open(hash_context_t** handle, const char* algorithm, binary_t const& key); + virtual return_t open(hash_context_t** handle, const char* algorithm, const binary_t& key); /** * @brief open (hash, HMAC) @@ -85,7 +85,7 @@ class openssl_hash : public hash_t { /** * @brief open (HMAC) */ - virtual return_t open(hash_context_t** handle, hash_algorithm_t alg, binary_t const& key); + virtual return_t open(hash_context_t** handle, hash_algorithm_t alg, const binary_t& key); /** * @brief open (CMAC) * @param hash_context_t** handle [out] @@ -99,7 +99,7 @@ class openssl_hash : public hash_t { /** * @brief open (CMAC) */ - virtual return_t open(hash_context_t** handle, crypt_algorithm_t alg, crypt_mode_t mode, binary_t const& key); + virtual return_t open(hash_context_t** handle, crypt_algorithm_t alg, crypt_mode_t mode, const binary_t& key); /** * @brief close * @param hash_context_t* handle [in] @@ -130,7 +130,7 @@ class openssl_hash : public hash_t { * hash.free_data(output_data); */ virtual return_t update(hash_context_t* handle, const byte_t* data, size_t datasize); - virtual return_t update(hash_context_t* handle, binary_t const& input); + virtual return_t update(hash_context_t* handle, const binary_t& input); /** * @brief hash * @param hash_context_t* handle [in] @@ -184,22 +184,22 @@ class openssl_digest : public openssl_hash { public: openssl_digest(); - return_t digest(const char* alg, binary_t const& input, binary_t& output); - return_t digest(hash_algorithm_t alg, binary_t const& input, binary_t& output); + return_t digest(const char* alg, const binary_t& input, binary_t& output); + return_t digest(hash_algorithm_t alg, const binary_t& input, binary_t& output); - return_t digest(const char* alg, basic_stream const& input, binary_t& output); - return_t digest(const char* alg, basic_stream const& input, std::string& hashstring, encoding_t encoding = encoding_t::encoding_base16); + return_t digest(const char* alg, const basic_stream& input, binary_t& output); + return_t digest(const char* alg, const basic_stream& input, std::string& hashstring, encoding_t encoding = encoding_t::encoding_base16); - return_t digest(const char* alg, std::string const& input, binary_t& output); - return_t digest(const char* alg, std::string const& input, std::string& hashstring, encoding_t encoding = encoding_t::encoding_base16); + return_t digest(const char* alg, const std::string& input, binary_t& output); + return_t digest(const char* alg, const std::string& input, std::string& hashstring, encoding_t encoding = encoding_t::encoding_base16); }; class openssl_mac : public openssl_hash { public: openssl_mac(); - return_t hmac(const char* alg, binary_t const& key, binary_t const& input, binary_t& output); - return_t hmac(hash_algorithm_t alg, binary_t const& key, binary_t const& input, binary_t& output); + return_t hmac(const char* alg, const binary_t& key, const binary_t& input, binary_t& output); + return_t hmac(hash_algorithm_t alg, const binary_t& key, const binary_t& input, binary_t& output); /** * @brief AES Cipher-Based Message Authentication Code (AES-CMAC) * @desc RFC 4493 The AES-CMAC Algorithm @@ -207,8 +207,8 @@ class openssl_mac : public openssl_hash { * @remarks not the same algorithm AES-CBC-MAC * see also RFC 8152 9.2. AES Message Authentication Code (AES-CBC-MAC) */ - return_t cmac(const char* alg, binary_t const& key, binary_t const& input, binary_t& output); - return_t cmac(crypt_algorithm_t alg, crypt_mode_t mode, binary_t const& key, binary_t const& input, binary_t& output); + return_t cmac(const char* alg, const binary_t& key, const binary_t& input, binary_t& output); + return_t cmac(crypt_algorithm_t alg, crypt_mode_t mode, const binary_t& key, const binary_t& input, binary_t& output); /** * @brief CBC-MAC @@ -231,14 +231,14 @@ class openssl_mac : public openssl_hash { * OMAC is the first good CBC-MAC derivative that uses a single key. * OMAC works the same way CBC-MAC does until the last block, where it XORs the state with an additional value before encrypting. */ - return_t cbc_mac(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& input, binary_t& tag, size_t tagsize); + return_t cbc_mac(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& input, binary_t& tag, size_t tagsize); /** * @brief RFC 8152 9.2. AES Message Authentication Code (AES-CBC-MAC) * @desc * reference https://travis-ci.org/cose-wg/ * difference ... encrypt final block w/ IV */ - return_t cbc_mac_rfc8152(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& input, binary_t& tag, size_t tagsize); + return_t cbc_mac_rfc8152(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& input, binary_t& tag, size_t tagsize); }; } // namespace crypto diff --git a/sdk/crypto/basic/openssl_kdf.cpp b/sdk/crypto/basic/openssl_kdf.cpp index 7ae30ce4..afcd6d2a 100644 --- a/sdk/crypto/basic/openssl_kdf.cpp +++ b/sdk/crypto/basic/openssl_kdf.cpp @@ -24,7 +24,7 @@ openssl_kdf::openssl_kdf() {} openssl_kdf::~openssl_kdf() {} -return_t openssl_kdf::hmac_kdf(binary_t& derived, hash_algorithm_t alg, size_t dlen, binary_t const& key, binary_t const& salt, binary_t const& info) { +return_t openssl_kdf::hmac_kdf(binary_t& derived, hash_algorithm_t alg, size_t dlen, const binary_t& key, const binary_t& salt, const binary_t& info) { return_t ret = errorcode_t::success; EVP_PKEY_CTX* ctx = nullptr; int ret_openssl = 0; @@ -65,7 +65,7 @@ return_t openssl_kdf::hmac_kdf(binary_t& derived, hash_algorithm_t alg, size_t d return ret; } -return_t openssl_kdf::hmac_kdf(binary_t& derived, const char* alg, size_t dlen, binary_t const& key, binary_t const& salt, binary_t const& info) { +return_t openssl_kdf::hmac_kdf(binary_t& derived, const char* alg, size_t dlen, const binary_t& key, const binary_t& salt, const binary_t& info) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -89,7 +89,7 @@ return_t openssl_kdf::hmac_kdf(binary_t& derived, const char* alg, size_t dlen, return ret; } -return_t openssl_kdf::hmac_kdf_extract(binary_t& prk, const char* alg, binary_t const& salt, binary_t const& ikm) { +return_t openssl_kdf::hmac_kdf_extract(binary_t& prk, const char* alg, const binary_t& salt, const binary_t& ikm) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); openssl_mac mac; @@ -128,7 +128,7 @@ return_t openssl_kdf::hmac_kdf_extract(binary_t& prk, const char* alg, binary_t return ret; } -return_t openssl_kdf::hkdf_expand(binary_t& okm, const char* alg, size_t dlen, binary_t const& prk, binary_t const& info) { +return_t openssl_kdf::hkdf_expand(binary_t& okm, const char* alg, size_t dlen, const binary_t& prk, const binary_t& info) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -175,7 +175,7 @@ return_t openssl_kdf::hkdf_expand(binary_t& okm, const char* alg, size_t dlen, b return ret; } -return_t openssl_kdf::hkdf_expand_aes_rfc8152(binary_t& okm, const char* alg, size_t dlen, binary_t const& prk, binary_t const& info) { +return_t openssl_kdf::hkdf_expand_aes_rfc8152(binary_t& okm, const char* alg, size_t dlen, const binary_t& prk, const binary_t& info) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); EVP_CIPHER_CTX* context = nullptr; @@ -338,7 +338,7 @@ return_t openssl_kdf::hkdf_expand_aes_rfc8152(binary_t& okm, const char* alg, si // Likewise, the CKDF-Expand(PRK, info, L) function takes the PRK result from CKDF-Extract, an arbitrary "info" argument and a requested number of bytes // to produce. It calculates the L-byte result, called the "output keying material" (OKM) -return_t openssl_kdf::cmac_kdf(binary_t& okm, crypt_algorithm_t alg, size_t dlen, binary_t const& ikm, binary_t const& salt, binary_t const& info) { +return_t openssl_kdf::cmac_kdf(binary_t& okm, crypt_algorithm_t alg, size_t dlen, const binary_t& ikm, const binary_t& salt, const binary_t& info) { return_t ret = errorcode_t::success; binary_t prk; __try2 { @@ -357,7 +357,7 @@ return_t openssl_kdf::cmac_kdf(binary_t& okm, crypt_algorithm_t alg, size_t dlen // the CKDF-Extract(salt, IKM) function takes an optional, 16-byte salt and an arbitrary-length "input keying material" (IKM) message. // If no salt is given, the 16-byte, all-zero value is used. // It returns the result of AES-CMAC(key = salt, input = IKM), called the "pseudorandom key" (PRK), which will be 16 bytes long. -return_t openssl_kdf::cmac_kdf_extract(binary_t& prk, crypt_algorithm_t alg, binary_t const& salt, binary_t const& ikm) { +return_t openssl_kdf::cmac_kdf_extract(binary_t& prk, crypt_algorithm_t alg, const binary_t& salt, const binary_t& ikm) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); openssl_mac mac; @@ -411,7 +411,7 @@ return_t openssl_kdf::cmac_kdf_extract(binary_t& prk, crypt_algorithm_t alg, bin return ret; } -return_t openssl_kdf::cmac_kdf_expand(binary_t& okm, crypt_algorithm_t alg, size_t dlen, binary_t const& prk, binary_t const& info) { +return_t openssl_kdf::cmac_kdf_expand(binary_t& okm, crypt_algorithm_t alg, size_t dlen, const binary_t& prk, const binary_t& info) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); openssl_mac mac; @@ -446,19 +446,19 @@ return_t openssl_kdf::cmac_kdf_expand(binary_t& okm, crypt_algorithm_t alg, size return ret; } -return_t openssl_kdf::pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, std::string const& password, binary_t const& salt, int iter) { +return_t openssl_kdf::pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, const std::string& password, const binary_t& salt, int iter) { return pbkdf2(derived, alg, dlen, password.c_str(), password.size(), &salt[0], salt.size(), iter); } -return_t openssl_kdf::pbkdf2(binary_t& derived, const char* alg, size_t dlen, std::string const& password, binary_t const& salt, int iter) { +return_t openssl_kdf::pbkdf2(binary_t& derived, const char* alg, size_t dlen, const std::string& password, const binary_t& salt, int iter) { return pbkdf2(derived, alg, dlen, password.c_str(), password.size(), &salt[0], salt.size(), iter); } -return_t openssl_kdf::pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, binary_t const& password, binary_t const& salt, int iter) { +return_t openssl_kdf::pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, const binary_t& password, const binary_t& salt, int iter) { return pbkdf2(derived, alg, dlen, (char*)&password[0], password.size(), &salt[0], salt.size(), iter); } -return_t openssl_kdf::pbkdf2(binary_t& derived, const char* alg, size_t dlen, binary_t const& password, binary_t const& salt, int iter) { +return_t openssl_kdf::pbkdf2(binary_t& derived, const char* alg, size_t dlen, const binary_t& password, const binary_t& salt, int iter) { return pbkdf2(derived, alg, dlen, (char*)&password[0], password.size(), &salt[0], salt.size(), iter); } @@ -514,7 +514,7 @@ return_t openssl_kdf::pbkdf2(binary_t& derived, const char* alg, size_t dlen, co return ret; } -return_t openssl_kdf::scrypt(binary_t& derived, size_t dlen, std::string const& password, binary_t const& salt, int n, int r, int p) { +return_t openssl_kdf::scrypt(binary_t& derived, size_t dlen, const std::string& password, const binary_t& salt, int n, int r, int p) { return_t ret = errorcode_t::success; EVP_PKEY_CTX* ctx = nullptr; int ret_openssl = 0; @@ -554,8 +554,8 @@ return_t openssl_kdf::scrypt(binary_t& derived, size_t dlen, std::string const& return ret; } -return_t openssl_kdf::argon2(binary_t& derived, argon2_t mode, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, - binary_t const& secret, uint32 iteration_cost, uint32 parallel_cost, uint32 memory_cost) { +return_t openssl_kdf::argon2(binary_t& derived, argon2_t mode, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, + const binary_t& secret, uint32 iteration_cost, uint32 parallel_cost, uint32 memory_cost) { return_t ret = errorcode_t::success; #if OPENSSL_VERSION_NUMBER >= 0x30200000L int ret_openssl = 0; @@ -651,17 +651,17 @@ return_t openssl_kdf::argon2(binary_t& derived, argon2_t mode, size_t dlen, bina return ret; } -return_t openssl_kdf::argon2d(binary_t& derived, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, +return_t openssl_kdf::argon2d(binary_t& derived, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost, uint32 parallel_cost, uint32 memory_cost) { return argon2(derived, argon2_t::argon2d, dlen, password, salt, ad, secret, iteration_cost, parallel_cost, memory_cost); } -return_t openssl_kdf::argon2i(binary_t& derived, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, +return_t openssl_kdf::argon2i(binary_t& derived, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost, uint32 parallel_cost, uint32 memory_cost) { return argon2(derived, argon2_t::argon2i, dlen, password, salt, ad, secret, iteration_cost, parallel_cost, memory_cost); } -return_t openssl_kdf::argon2id(binary_t& derived, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, +return_t openssl_kdf::argon2id(binary_t& derived, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost, uint32 parallel_cost, uint32 memory_cost) { return argon2(derived, argon2_t::argon2id, dlen, password, salt, ad, secret, iteration_cost, parallel_cost, memory_cost); } diff --git a/sdk/crypto/basic/openssl_kdf.hpp b/sdk/crypto/basic/openssl_kdf.hpp index 26ef0ecc..39905901 100644 --- a/sdk/crypto/basic/openssl_kdf.hpp +++ b/sdk/crypto/basic/openssl_kdf.hpp @@ -57,65 +57,65 @@ class openssl_kdf { * @param binary_t& okm [out] output key material * @param hash_algorithm_t alg [in] algorithm * @param size_t dlen [in] length - * @param binary_t const& ikm [in] input key material - * @param binary_t const& salt [in] salt - * @param binary_t const& info [in] info + * @param const binary_t& ikm [in] input key material + * @param const binary_t& salt [in] salt + * @param const binary_t& info [in] info * @return error code (see error.hpp) */ - return_t hmac_kdf(binary_t& derived, hash_algorithm_t alg, size_t dlen, binary_t const& ikm, binary_t const& salt, binary_t const& info); + return_t hmac_kdf(binary_t& derived, hash_algorithm_t alg, size_t dlen, const binary_t& ikm, const binary_t& salt, const binary_t& info); /** * @brief HKDF (Extract and Expand) * @param binary_t& okm [out] output key material * @param const char* alg [in] algorithm * @param size_t dlen [in] length - * @param binary_t const& ikm [in] input key material - * @param binary_t const& salt [in] salt - * @param binary_t const& info [in] info + * @param const binary_t& ikm [in] input key material + * @param const binary_t& salt [in] salt + * @param const binary_t& info [in] info * @return error code (see error.hpp) */ - return_t hmac_kdf(binary_t& derived, const char* alg, size_t dlen, binary_t const& ikm, binary_t const& salt, binary_t const& info); + return_t hmac_kdf(binary_t& derived, const char* alg, size_t dlen, const binary_t& ikm, const binary_t& salt, const binary_t& info); /** * @brief HKDF_Extract (aka HMAC) * @param binary_t& prk [out] pseudo-random key * @param const char* alg [in] algorithm - * @param binary_t const& salt [in] salt - * @param binary_t const& ikm [in] input key material + * @param const binary_t& salt [in] salt + * @param const binary_t& ikm [in] input key material * @return error code (see error.hpp) */ - return_t hmac_kdf_extract(binary_t& prk, const char* alg, binary_t const& salt, binary_t const& ikm); + return_t hmac_kdf_extract(binary_t& prk, const char* alg, const binary_t& salt, const binary_t& ikm); /** * @brief HKDF_Expand * @param binary_t& okm [out] output key material * @param const char* alg [in] algorithm * @param size_t dlen [in] length - * @param binary_t const& prk [in] pseudo-random key - * @param binary_t const& info [in] info + * @param const binary_t& prk [in] pseudo-random key + * @param const binary_t& info [in] info * @return error code (see error.hpp) * @remarks */ - return_t hkdf_expand(binary_t& okm, const char* alg, size_t dlen, binary_t const& prk, binary_t const& info); + return_t hkdf_expand(binary_t& okm, const char* alg, size_t dlen, const binary_t& prk, const binary_t& info); /** * @brief AES-based KDF_Expand * @param binary_t& okm [out] output key material * @param const char* alg [in] algorithm * @param size_t dlen [in] length - * @param binary_t const& prk [in] pseudo-random key - * @param binary_t const& info [in] info + * @param const binary_t& prk [in] pseudo-random key + * @param const binary_t& info [in] info * @return error code (see error.hpp) * @remarks RFC 8152 direct+HKDF-AES-128, direct+HKDF-AES-256 * reference https://travis-ci.org/cose-wg/ * just HKDF wo extract */ - return_t hkdf_expand_aes_rfc8152(binary_t& okm, const char* alg, size_t dlen, binary_t const& prk, binary_t const& info); + return_t hkdf_expand_aes_rfc8152(binary_t& okm, const char* alg, size_t dlen, const binary_t& prk, const binary_t& info); /** * @brief CMAC-based Extract-and-Expand Key Derivation Function (CKDF) * @param binary_t& okm [out] output key material * @param crypt_algorithm_t alg [in] algorithm * @param size_t dlen [in] length - * @param binary_t const& ikm [in] input key material - * @param binary_t const& salt [in] salt - * @param binary_t const& info [in] info + * @param const binary_t& ikm [in] input key material + * @param const binary_t& salt [in] salt + * @param const binary_t& info [in] info * @return error code (see error.hpp) * @remarks * CMAC = CKDF-Extract + CKDF-Expand @@ -125,42 +125,42 @@ class openssl_kdf { * CKDF-Expand "aes-128-ecb" * @desc RFC 4493 Figure 2.3. Algorithm AES-CMAC */ - return_t cmac_kdf(binary_t& okm, crypt_algorithm_t alg, size_t dlen, binary_t const& ikm, binary_t const& salt, binary_t const& info); + return_t cmac_kdf(binary_t& okm, crypt_algorithm_t alg, size_t dlen, const binary_t& ikm, const binary_t& salt, const binary_t& info); /** * @brief CMAC-based Extract * @param binary_t& prk [out] pseudo-random key * @param crypt_algorithm_t alg [in] algorithm - * @param binary_t const& salt [in] salt - * @param binary_t const& ikm [in] input key material + * @param const binary_t& salt [in] salt + * @param const binary_t& ikm [in] input key material * @return error code (see error.hpp) * @desc RFC 4493 Figure 2.3. Algorithm AES-CMAC */ - return_t cmac_kdf_extract(binary_t& prk, crypt_algorithm_t alg, binary_t const& salt, binary_t const& ikm); + return_t cmac_kdf_extract(binary_t& prk, crypt_algorithm_t alg, const binary_t& salt, const binary_t& ikm); /** * @brief CMAC-based Expand * @param binary_t& okm [in] output key material * @param crypt_algorithm_t alg [in] algorithm * @param size_t dlen [in] length - * @param binary_t const& prk [in] pseudo-random key - * @param binary_t const& info [in] info + * @param const binary_t& prk [in] pseudo-random key + * @param const binary_t& info [in] info * @return error code (see error.hpp) * @desc RFC 4493 Figure 2.3. Algorithm AES-CMAC */ - return_t cmac_kdf_expand(binary_t& okm, crypt_algorithm_t alg, size_t dlen, binary_t const& prk, binary_t const& info); + return_t cmac_kdf_expand(binary_t& okm, crypt_algorithm_t alg, size_t dlen, const binary_t& prk, const binary_t& info); /** * @brief PBKDF2 * @param binary_t& derived [out] * @param hash_algorithm_t alg [in] * @param size_t dlen [in] - * @param std::string const& password [in] - * @param binary_t const& salt [in] + * @param const std::string& password [in] + * @param const binary_t& salt [in] * @param int iter [in] * @return error code (see error.hpp) */ - return_t pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, std::string const& password, binary_t const& salt, int iter); - return_t pbkdf2(binary_t& derived, const char* alg, size_t dlen, std::string const& password, binary_t const& salt, int iter); - return_t pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, binary_t const& password, binary_t const& salt, int iter); - return_t pbkdf2(binary_t& derived, const char* alg, size_t dlen, binary_t const& password, binary_t const& salt, int iter); + return_t pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, const std::string& password, const binary_t& salt, int iter); + return_t pbkdf2(binary_t& derived, const char* alg, size_t dlen, const std::string& password, const binary_t& salt, int iter); + return_t pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, const binary_t& password, const binary_t& salt, int iter); + return_t pbkdf2(binary_t& derived, const char* alg, size_t dlen, const binary_t& password, const binary_t& salt, int iter); return_t pbkdf2(binary_t& derived, hash_algorithm_t alg, size_t dlen, const char* password, size_t size_password, const byte_t* salt, size_t size_salt, int iter); return_t pbkdf2(binary_t& derived, const char* alg, size_t dlen, const char* password, size_t size_password, const byte_t* salt, size_t size_salt, @@ -169,13 +169,13 @@ class openssl_kdf { * @brief scrypt * @param binary_t& derived [out] * @param size_t dlen [in] - * @param std::string const& password [in] - * @param binary_t const& salt [in] + * @param const std::string& password [in] + * @param const binary_t& salt [in] * @param int n [in] * @param int r [in] * @param int p [in] */ - return_t scrypt(binary_t& derived, size_t dlen, std::string const& password, binary_t const& salt, int n, int r, int p); + return_t scrypt(binary_t& derived, size_t dlen, const std::string& password, const binary_t& salt, int n, int r, int p); // bcrypt - blowfish based... (openssl 3.x deprecates bf) @@ -184,23 +184,23 @@ class openssl_kdf { * @param binary_t& derived [in] * @param argon2_t mode [in] * @param size_t dlen [in] - * @param binary_t const& password [in] - * @param binary_t const& salt [in] - * @param binary_t const& ad [in] - * @param binary_t const& secret [in] + * @param const binary_t& password [in] + * @param const binary_t& salt [in] + * @param const binary_t& ad [in] + * @param const binary_t& secret [in] * @param uint32 iteration_cost [inopt] default 3 * @param uint32 parallel_cost [inopt] default 4 * @param uint32 memory_cost [inopt] default 32 * @return error code (see error.hpp) * not_supported .. openssl-1.1.1, 3.0 */ - return_t argon2(binary_t& derived, argon2_t mode, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, + return_t argon2(binary_t& derived, argon2_t mode, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost = 3, uint32 parallel_cost = 4, uint32 memory_cost = 32); - return_t argon2d(binary_t& derived, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, + return_t argon2d(binary_t& derived, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost = 3, uint32 parallel_cost = 4, uint32 memory_cost = 32); - return_t argon2i(binary_t& derived, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, + return_t argon2i(binary_t& derived, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost = 3, uint32 parallel_cost = 4, uint32 memory_cost = 32); - return_t argon2id(binary_t& derived, size_t dlen, binary_t const& password, binary_t const& salt, binary_t const& ad, binary_t const& secret, + return_t argon2id(binary_t& derived, size_t dlen, const binary_t& password, const binary_t& salt, const binary_t& ad, const binary_t& secret, uint32 iteration_cost = 3, uint32 parallel_cost = 4, uint32 memory_cost = 32); }; diff --git a/sdk/crypto/basic/openssl_mac.cpp b/sdk/crypto/basic/openssl_mac.cpp index 57b2937e..d505240f 100644 --- a/sdk/crypto/basic/openssl_mac.cpp +++ b/sdk/crypto/basic/openssl_mac.cpp @@ -19,7 +19,7 @@ namespace crypto { openssl_mac::openssl_mac() : openssl_hash() {} -return_t openssl_mac::hmac(const char* alg, binary_t const& key, binary_t const& input, binary_t& output) { +return_t openssl_mac::hmac(const char* alg, const binary_t& key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -37,7 +37,7 @@ return_t openssl_mac::hmac(const char* alg, binary_t const& key, binary_t const& return ret; } -return_t openssl_mac::hmac(hash_algorithm_t alg, binary_t const& key, binary_t const& input, binary_t& output) { +return_t openssl_mac::hmac(hash_algorithm_t alg, const binary_t& key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -55,7 +55,7 @@ return_t openssl_mac::hmac(hash_algorithm_t alg, binary_t const& key, binary_t c return ret; } -return_t openssl_mac::cmac(const char* alg, binary_t const& key, binary_t const& input, binary_t& output) { +return_t openssl_mac::cmac(const char* alg, const binary_t& key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -73,7 +73,7 @@ return_t openssl_mac::cmac(const char* alg, binary_t const& key, binary_t const& return ret; } -return_t openssl_mac::cmac(crypt_algorithm_t alg, crypt_mode_t mode, binary_t const& key, binary_t const& input, binary_t& output) { +return_t openssl_mac::cmac(crypt_algorithm_t alg, crypt_mode_t mode, const binary_t& key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; hash_context_t* handle = nullptr; @@ -91,7 +91,7 @@ return_t openssl_mac::cmac(crypt_algorithm_t alg, crypt_mode_t mode, binary_t co return ret; } -return_t openssl_mac::cbc_mac(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& input, binary_t& tag, size_t tagsize) { +return_t openssl_mac::cbc_mac(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& input, binary_t& tag, size_t tagsize) { return_t ret = errorcode_t::success; EVP_CIPHER_CTX* context = nullptr; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -143,7 +143,7 @@ return_t openssl_mac::cbc_mac(const char* alg, binary_t const& key, binary_t con return ret; } -return_t openssl_mac::cbc_mac_rfc8152(const char* alg, binary_t const& key, binary_t const& iv, binary_t const& input, binary_t& tag, size_t tagsize) { +return_t openssl_mac::cbc_mac_rfc8152(const char* alg, const binary_t& key, const binary_t& iv, const binary_t& input, binary_t& tag, size_t tagsize) { return_t ret = errorcode_t::success; EVP_CIPHER_CTX* context = nullptr; crypto_advisor* advisor = crypto_advisor::get_instance(); diff --git a/sdk/crypto/basic/openssl_sign.cpp b/sdk/crypto/basic/openssl_sign.cpp index 0f472b96..1e21d8f2 100644 --- a/sdk/crypto/basic/openssl_sign.cpp +++ b/sdk/crypto/basic/openssl_sign.cpp @@ -27,7 +27,7 @@ openssl_sign::~openssl_sign() { // do nothing } -return_t openssl_sign::sign(const EVP_PKEY* pkey, crypt_sig_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign(const EVP_PKEY* pkey, crypt_sig_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -84,7 +84,7 @@ return_t openssl_sign::sign(const EVP_PKEY* pkey, crypt_sig_t mode, binary_t con return ret; } -return_t openssl_sign::verify(const EVP_PKEY* pkey, crypt_sig_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify(const EVP_PKEY* pkey, crypt_sig_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -143,7 +143,7 @@ return_t openssl_sign::verify(const EVP_PKEY* pkey, crypt_sig_t mode, binary_t c return ret; } -return_t openssl_sign::sign_digest(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign_digest(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); EVP_MD_CTX* md_context = nullptr; @@ -197,7 +197,7 @@ return_t openssl_sign::sign_digest(const EVP_PKEY* pkey, hash_algorithm_t mode, return ret; } -return_t openssl_sign::sign_hmac(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign_hmac(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; __try2 { @@ -213,7 +213,7 @@ return_t openssl_sign::sign_hmac(const EVP_PKEY* pkey, hash_algorithm_t mode, bi return ret; } -return_t openssl_sign::sign_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; __try2 { @@ -229,7 +229,7 @@ return_t openssl_sign::sign_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t return ret; } -return_t openssl_sign::sign_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); openssl_hash hash; @@ -321,7 +321,7 @@ return_t openssl_sign::sign_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t mode, b return ret; } -return_t openssl_sign::sign_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -369,7 +369,7 @@ return_t openssl_sign::sign_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t mo return ret; } -return_t openssl_sign::sign_eddsa(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t& signature) { +return_t openssl_sign::sign_eddsa(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, binary_t& signature) { return_t ret = errorcode_t::success; EVP_MD_CTX* ctx = nullptr; int ret_test = 0; @@ -404,7 +404,7 @@ return_t openssl_sign::sign_eddsa(const EVP_PKEY* pkey, hash_algorithm_t mode, b return ret; } -return_t openssl_sign::verify_digest(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify_digest(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); EVP_MD_CTX* md_context = nullptr; @@ -460,7 +460,7 @@ return_t openssl_sign::verify_digest(const EVP_PKEY* pkey, hash_algorithm_t mode return ret; } -return_t openssl_sign::verify_hmac(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify_hmac(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; __try2 { @@ -480,7 +480,7 @@ return_t openssl_sign::verify_hmac(const EVP_PKEY* pkey, hash_algorithm_t mode, return ret; } -return_t openssl_sign::verify_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; __try2 { @@ -496,7 +496,7 @@ return_t openssl_sign::verify_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm return ret; } -return_t openssl_sign::verify_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); openssl_hash hash; @@ -555,7 +555,7 @@ return_t openssl_sign::verify_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t mode, return ret; } -return_t openssl_sign::verify_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); openssl_hash hash; @@ -598,7 +598,7 @@ return_t openssl_sign::verify_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t return ret; } -return_t openssl_sign::verify_eddsa(const EVP_PKEY* pkey, hash_algorithm_t mode, binary_t const& input, binary_t const& signature) { +return_t openssl_sign::verify_eddsa(const EVP_PKEY* pkey, hash_algorithm_t mode, const binary_t& input, const binary_t& signature) { return_t ret = errorcode_t::success; EVP_MD_CTX* ctx = nullptr; int ret_test = 0; diff --git a/sdk/crypto/basic/openssl_sign.hpp b/sdk/crypto/basic/openssl_sign.hpp index 9a7613da..827ad8cd 100644 --- a/sdk/crypto/basic/openssl_sign.hpp +++ b/sdk/crypto/basic/openssl_sign.hpp @@ -36,127 +36,127 @@ class openssl_sign { * @biref sign * @param const EVP_PKEY* pkey [in] * @param crypt_sig_t mode [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& signature [out] */ - return_t sign(const EVP_PKEY* pkey, crypt_sig_t mode, binary_t const& input, binary_t& signature); + return_t sign(const EVP_PKEY* pkey, crypt_sig_t mode, const binary_t& input, binary_t& signature); /** * @biref verify * @param const EVP_PKEY* pkey [in] * @param crypt_sig_t mode [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] */ - return_t verify(const EVP_PKEY* pkey, crypt_sig_t mode, binary_t const& input, binary_t const& signature); + return_t verify(const EVP_PKEY* pkey, crypt_sig_t mode, const binary_t& input, const binary_t& signature); /* * @brief sign * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc HS256, HS384, HS512 */ - return_t sign_digest(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t& signature); + return_t sign_digest(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, binary_t& signature); /* * @brief sign * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc HS256, HS384, HS512 */ - return_t sign_hmac(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t& signature); + return_t sign_hmac(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, binary_t& signature); /* * @brief sign * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc RS256, RS384, RS512 */ - return_t sign_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t& signature); + return_t sign_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, binary_t& signature); /* * @brief sign * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc ES256, ES384, ES512, ES256K */ - return_t sign_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t& signature); + return_t sign_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, binary_t& signature); /* * @brief sign * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc PS256, PS384, PS512 */ - return_t sign_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t& signature); + return_t sign_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, binary_t& signature); /* * @brief sign * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc EdDSA */ - return_t sign_eddsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t& signature); + return_t sign_eddsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, binary_t& signature); /* * @brief verify * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc HS256, HS384, HS512 */ - return_t verify_digest(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t const& signature); + return_t verify_digest(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, const binary_t& signature); /* * @brief verify * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc HS256, HS384, HS512 */ - return_t verify_hmac(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t const& signature); + return_t verify_hmac(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, const binary_t& signature); /* * @brief verify * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc RS256, RS384, RS512 */ - return_t verify_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t const& signature); + return_t verify_rsassa_pkcs15(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, const binary_t& signature); /* * @brief verify * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc ES256, ES384, ES512, ES256K */ - return_t verify_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t const& signature); + return_t verify_ecdsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, const binary_t& signature); /* * @brief verify * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc PS256, PS384, PS512 */ - return_t verify_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t const& signature); + return_t verify_rsassa_pss(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, const binary_t& signature); /* * @brief verify * @param const EVP_PKEY* pkey [in] * @param hash_algorithm_t hashalg [in] - * @param binary_t const& input [in] - * @param binary_t const& signature [in] + * @param const binary_t& input [in] + * @param const binary_t& signature [in] * @desc EdDSA */ - return_t verify_eddsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, binary_t const& input, binary_t const& signature); + return_t verify_eddsa(const EVP_PKEY* pkey, hash_algorithm_t hashalg, const binary_t& input, const binary_t& signature); }; } // namespace crypto diff --git a/sdk/crypto/cose/cbor_object_encryption.cpp b/sdk/crypto/cose/cbor_object_encryption.cpp index bebbea2b..34c9e830 100644 --- a/sdk/crypto/cose/cbor_object_encryption.cpp +++ b/sdk/crypto/cose/cbor_object_encryption.cpp @@ -37,7 +37,7 @@ cbor_object_encryption::~cbor_object_encryption() { // do nothing } -return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t method, binary_t const& input, binary_t& output) { +return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t method, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; cbor_object_signing_encryption cose; @@ -58,7 +58,7 @@ return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key return ret; } -return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key, std::list methods, binary_t const& input, binary_t& output) { +return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key, std::list methods, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; cbor_object_signing_encryption cose; @@ -75,7 +75,7 @@ return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key return ret; } -return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t* methods, size_t size_method, binary_t const& input, +return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t* methods, size_t size_method, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; @@ -97,7 +97,7 @@ return_t cbor_object_encryption::encrypt(cose_context_t* handle, crypto_key* key return ret; } -return_t cbor_object_encryption::decrypt(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output, bool& result) { +return_t cbor_object_encryption::decrypt(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output, bool& result) { return_t ret = errorcode_t::success; cbor_object_signing_encryption cose; diff --git a/sdk/crypto/cose/cbor_object_encryption.hpp b/sdk/crypto/cose/cbor_object_encryption.hpp index 510157b1..2f92e058 100644 --- a/sdk/crypto/cose/cbor_object_encryption.hpp +++ b/sdk/crypto/cose/cbor_object_encryption.hpp @@ -27,19 +27,19 @@ class cbor_object_encryption { * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param cose_alg_t method [in] must specify an encryption algoritm (see cose_group_enc_aesgcm/cose_group_enc_aesccm) - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @example * encrypt (handle, key, cose_aes128gcm, input, output); */ - return_t encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t method, binary_t const& input, binary_t& output); + return_t encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t method, const binary_t& input, binary_t& output); /** * @brief encrypt ("Encrypt") * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param std::list methods [in] at least one encryption algorithm - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @example @@ -47,14 +47,14 @@ class cbor_object_encryption { * algs.push_back(cose_group_key_ecdhss_hmac); // cose_group_key_xxx * encrypt (handle, key, algs, input, output); */ - return_t encrypt(cose_context_t* handle, crypto_key* key, std::list methods, binary_t const& input, binary_t& output); + return_t encrypt(cose_context_t* handle, crypto_key* key, std::list methods, const binary_t& input, binary_t& output); /** * @brief encrypt * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param cose_alg_t* methods [in] * @param size_t size_method [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @example @@ -63,17 +63,17 @@ class cbor_object_encryption { * cose_alg_t algs2[] = { cose_aesccm_64_64_256, cose_group_key_ecdhss_hmac, cose_group_key_hkdf_aes, }; * encrypt (handle, key, algs2, 2, input, output); */ - return_t encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t* methods, size_t size_method, binary_t const& input, binary_t& output); + return_t encrypt(cose_context_t* handle, crypto_key* key, cose_alg_t* methods, size_t size_method, const binary_t& input, binary_t& output); /** * @brief decrypt * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @param bool& result [out] * @return error code (see error.hpp) */ - return_t decrypt(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output, bool& result); + return_t decrypt(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output, bool& result); protected: }; diff --git a/sdk/crypto/cose/cbor_object_signing.cpp b/sdk/crypto/cose/cbor_object_signing.cpp index cb3f8799..2ae3932b 100644 --- a/sdk/crypto/cose/cbor_object_signing.cpp +++ b/sdk/crypto/cose/cbor_object_signing.cpp @@ -35,7 +35,7 @@ cbor_object_signing::~cbor_object_signing() { // do nothing } -return_t cbor_object_signing::sign(cose_context_t* handle, crypto_key* key, cose_alg_t method, binary_t const& input, binary_t& output) { +return_t cbor_object_signing::sign(cose_context_t* handle, crypto_key* key, cose_alg_t method, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; __try2 { @@ -55,21 +55,21 @@ return_t cbor_object_signing::sign(cose_context_t* handle, crypto_key* key, cose return ret; } -return_t cbor_object_signing::sign(cose_context_t* handle, crypto_key* key, std::list methods, binary_t const& input, binary_t& output) { +return_t cbor_object_signing::sign(cose_context_t* handle, crypto_key* key, std::list methods, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; cbor_object_signing_encryption cose; ret = cose.sign(handle, key, methods, input, output); return ret; } -return_t cbor_object_signing::mac(cose_context_t* handle, crypto_key* key, std::list methods, binary_t const& input, binary_t& output) { +return_t cbor_object_signing::mac(cose_context_t* handle, crypto_key* key, std::list methods, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; cbor_object_signing_encryption cose; ret = cose.mac(handle, key, methods, input, output); return ret; } -return_t cbor_object_signing::verify(cose_context_t* handle, crypto_key* key, binary_t const& input, bool& result) { +return_t cbor_object_signing::verify(cose_context_t* handle, crypto_key* key, const binary_t& input, bool& result) { return_t ret = errorcode_t::success; cbor_object_signing_encryption cose; __try2 { diff --git a/sdk/crypto/cose/cbor_object_signing.hpp b/sdk/crypto/cose/cbor_object_signing.hpp index 912ba142..8c61a07f 100644 --- a/sdk/crypto/cose/cbor_object_signing.hpp +++ b/sdk/crypto/cose/cbor_object_signing.hpp @@ -29,44 +29,44 @@ class cbor_object_signing { * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param cose_alg_t method [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::sign */ - return_t sign(cose_context_t* handle, crypto_key* key, cose_alg_t method, binary_t const& input, binary_t& output); + return_t sign(cose_context_t* handle, crypto_key* key, cose_alg_t method, const binary_t& input, binary_t& output); /** * @brief sign * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param std::list methods [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::sign */ - return_t sign(cose_context_t* handle, crypto_key* key, std::list methods, binary_t const& input, binary_t& output); + return_t sign(cose_context_t* handle, crypto_key* key, std::list methods, const binary_t& input, binary_t& output); /** * @brief mac * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param std::list methods [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) */ - return_t mac(cose_context_t* handle, crypto_key* key, std::list methods, binary_t const& input, binary_t& output); + return_t mac(cose_context_t* handle, crypto_key* key, std::list methods, const binary_t& input, binary_t& output); /** * @brief verify with kid * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] CBOR + * @param const binary_t& input [in] CBOR * @param bool& result [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::verify */ - return_t verify(cose_context_t* handle, crypto_key* key, binary_t const& input, bool& result); + return_t verify(cose_context_t* handle, crypto_key* key, const binary_t& input, bool& result); protected: }; diff --git a/sdk/crypto/cose/cbor_object_signing_encryption.cpp b/sdk/crypto/cose/cbor_object_signing_encryption.cpp index eff7df44..78f99d04 100644 --- a/sdk/crypto/cose/cbor_object_signing_encryption.cpp +++ b/sdk/crypto/cose/cbor_object_signing_encryption.cpp @@ -117,7 +117,7 @@ return_t cbor_object_signing_encryption::get(cose_context_t* handle, uint32& fla return ret; } -return_t cbor_object_signing_encryption::set(cose_context_t* handle, cose_param_t id, binary_t const& bin) { +return_t cbor_object_signing_encryption::set(cose_context_t* handle, cose_param_t id, const binary_t& bin) { return_t ret = errorcode_t::success; __try2 { if (nullptr == handle) { @@ -149,7 +149,7 @@ return_t cbor_object_signing_encryption::set(cose_context_t* handle, cose_param_ return ret; } -return_t cbor_object_signing_encryption::encrypt(cose_context_t* handle, crypto_key* key, std::list& algs, binary_t const& input, +return_t cbor_object_signing_encryption::encrypt(cose_context_t* handle, crypto_key* key, std::list& algs, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; @@ -180,7 +180,7 @@ return_t cbor_object_signing_encryption::encrypt(cose_context_t* handle, crypto_ return ret; } -return_t cbor_object_signing_encryption::encrypt(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output) { +return_t cbor_object_signing_encryption::encrypt(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; __try2 { @@ -215,13 +215,13 @@ return_t cbor_object_signing_encryption::encrypt(cose_context_t* handle, crypto_ return ret; } -return_t cbor_object_signing_encryption::decrypt(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output, bool& result) { +return_t cbor_object_signing_encryption::decrypt(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output, bool& result) { return_t ret = errorcode_t::success; ret = process(handle, key, input, output, cose_mode_t::cose_mode_recv); return ret; } -return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key* key, cose_alg_t alg, binary_t const& input, binary_t& output) { +return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key* key, cose_alg_t alg, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; std::list algs; algs.push_back(alg); @@ -229,7 +229,7 @@ return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key return ret; } -return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key* key, std::list& algs, binary_t const& input, binary_t& output) { +return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key* key, std::list& algs, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; __try2 { @@ -259,7 +259,7 @@ return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key return ret; } -return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output) { +return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; __try2 { @@ -294,7 +294,7 @@ return_t cbor_object_signing_encryption::sign(cose_context_t* handle, crypto_key return ret; } -return_t cbor_object_signing_encryption::mac(cose_context_t* handle, crypto_key* key, std::list& algs, binary_t const& input, binary_t& output) { +return_t cbor_object_signing_encryption::mac(cose_context_t* handle, crypto_key* key, std::list& algs, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; __try2 { if (nullptr == handle || nullptr == key) { @@ -323,7 +323,7 @@ return_t cbor_object_signing_encryption::mac(cose_context_t* handle, crypto_key* return ret; } -return_t cbor_object_signing_encryption::mac(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output) { +return_t cbor_object_signing_encryption::mac(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; __try2 { @@ -358,14 +358,14 @@ return_t cbor_object_signing_encryption::mac(cose_context_t* handle, crypto_key* return ret; } -return_t cbor_object_signing_encryption::verify(cose_context_t* handle, crypto_key* key, binary_t const& input, bool& result) { +return_t cbor_object_signing_encryption::verify(cose_context_t* handle, crypto_key* key, const binary_t& input, bool& result) { return_t ret = errorcode_t::success; binary_t dummy; ret = process(handle, key, input, dummy, cose_mode_t::cose_mode_recv); return ret; } -return_t cbor_object_signing_encryption::process(cose_context_t* handle, crypto_key* key, binary_t const& cbor, binary_t& output, cose_mode_t mode) { +return_t cbor_object_signing_encryption::process(cose_context_t* handle, crypto_key* key, const binary_t& cbor, binary_t& output, cose_mode_t mode) { return_t ret = errorcode_t::success; return_t check = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -508,7 +508,7 @@ return_t cbor_object_signing_encryption::subprocess(cose_context_t* handle, cryp } return_t cbor_object_signing_encryption::preprocess(cose_context_t* handle, crypto_key* key, std::list& algs, crypt_category_t category, - binary_t const& input) { + const binary_t& input) { return_t ret = errorcode_t::success; __try2 { ret = preprocess_skeleton(handle, key, algs, category, input); @@ -526,7 +526,7 @@ return_t cbor_object_signing_encryption::preprocess(cose_context_t* handle, cryp return ret; } -return_t cbor_object_signing_encryption::preprocess(cose_context_t* handle, crypto_key* key, binary_t const& input) { +return_t cbor_object_signing_encryption::preprocess(cose_context_t* handle, crypto_key* key, const binary_t& input) { return_t ret = errorcode_t::success; __try2 { @@ -550,7 +550,7 @@ return_t cbor_object_signing_encryption::preprocess(cose_context_t* handle, cryp } return_t cbor_object_signing_encryption::preprocess_skeleton(cose_context_t* handle, crypto_key* key, std::list& algs, crypt_category_t category, - binary_t const& input) { + const binary_t& input) { return_t ret = errorcode_t::success; return_t check = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -1385,7 +1385,7 @@ return_t cbor_object_signing_encryption::process_keyagreement(cose_context_t* ha return ret; } -return_t split(binary_t const& source, size_t& sizeof_ciphertext, binary_t& tag, size_t tagsize) { +return_t split(const binary_t& source, size_t& sizeof_ciphertext, binary_t& tag, size_t tagsize) { // RFC 8152 Combine the authentication tag for encryption algorithms with the ciphertext. return_t ret = errorcode_t::success; tag.clear(); diff --git a/sdk/crypto/cose/cbor_object_signing_encryption.hpp b/sdk/crypto/cose/cbor_object_signing_encryption.hpp index d4c25747..ff61c420 100644 --- a/sdk/crypto/cose/cbor_object_signing_encryption.hpp +++ b/sdk/crypto/cose/cbor_object_signing_encryption.hpp @@ -66,17 +66,17 @@ class cbor_object_signing_encryption { * @brief set * @param cose_context_t* handle [in] * @param cose_param_t id [in] cose_external, cose_public, cose_private - * @param binary_t const& bin [in] + * @param const binary_t& bin [in] * @return error code (see error.hpp) */ - return_t set(cose_context_t* handle, cose_param_t id, binary_t const& bin); + return_t set(cose_context_t* handle, cose_param_t id, const binary_t& bin); /** * @brief encrypt * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param std::list& algs [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @example @@ -107,12 +107,12 @@ class cbor_object_signing_encryption { * } * } */ - return_t encrypt(cose_context_t* handle, crypto_key* key, std::list& algs, binary_t const& input, binary_t& output); + return_t encrypt(cose_context_t* handle, crypto_key* key, std::list& algs, const binary_t& input, binary_t& output); /** * @brief encrypt * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @example @@ -129,35 +129,35 @@ class cbor_object_signing_encryption { * } * cose.close(handle); */ - return_t encrypt(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output); + return_t encrypt(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output); /** * @brief decrypt * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] decrypted * @param bool& result [out] * @return error code (see error.hpp) * @remarks see json_object_encryption::decrypt */ - return_t decrypt(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output, bool& result); + return_t decrypt(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output, bool& result); /** * @brief sign * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param cose_alg_t method [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @remarks see json_object_signing::sign */ - return_t sign(cose_context_t* handle, crypto_key* key, cose_alg_t method, binary_t const& input, binary_t& output); + return_t sign(cose_context_t* handle, crypto_key* key, cose_alg_t method, const binary_t& input, binary_t& output); /** * @brief sign * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param std::list& methods [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @remarks see json_object_signing::sign @@ -175,12 +175,12 @@ class cbor_object_signing_encryption { * cose.sign (handle, key, algs, input, output); * } */ - return_t sign(cose_context_t* handle, crypto_key* key, std::list& methods, binary_t const& input, binary_t& output); + return_t sign(cose_context_t* handle, crypto_key* key, std::list& methods, const binary_t& input, binary_t& output); /** * @brief sign * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @example @@ -194,13 +194,13 @@ class cbor_object_signing_encryption { * * cose.close(handle); */ - return_t sign(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output); + return_t sign(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output); /** * @brief mac * @param cose_context_t* handle [in] * @param crypto_key* key [in] * @param std::list& methods [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @example @@ -231,12 +231,12 @@ class cbor_object_signing_encryption { * } */ - return_t mac(cose_context_t* handle, crypto_key* key, std::list& methods, binary_t const& input, binary_t& output); + return_t mac(cose_context_t* handle, crypto_key* key, std::list& methods, const binary_t& input, binary_t& output); /** * @brief mac * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] CBOR * @return error code (see error.hpp) * @example @@ -253,23 +253,23 @@ class cbor_object_signing_encryption { * } * cose.close(handle); */ - return_t mac(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output); + return_t mac(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output); /** * @brief verify with kid * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param bool& result [out] * @return error code (see error.hpp) * @remarks see json_object_signing::verify */ - return_t verify(cose_context_t* handle, crypto_key* key, binary_t const& input, bool& result); + return_t verify(cose_context_t* handle, crypto_key* key, const binary_t& input, bool& result); /** * @brief process * @param cose_context_t* handle [in] * @param crypto_key* key [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @examples @@ -278,14 +278,14 @@ class cbor_object_signing_encryption { * cose.process(handle, key, cbor, output); // decrypt, verifysign, verifymac (tagged/untagged) * cose.close(handle); */ - return_t process(cose_context_t* handle, crypto_key* key, binary_t const& input, binary_t& output, cose_mode_t mode = cose_mode_t::cose_mode_recv); + return_t process(cose_context_t* handle, crypto_key* key, const binary_t& input, binary_t& output, cose_mode_t mode = cose_mode_t::cose_mode_recv); protected: return_t subprocess(cose_context_t* handle, crypto_key* key, cose_layer* layer, cose_mode_t mode); - return_t preprocess(cose_context_t* handle, crypto_key* key, std::list& algs, crypt_category_t category, binary_t const& input); - return_t preprocess(cose_context_t* handle, crypto_key* key, binary_t const& input); + return_t preprocess(cose_context_t* handle, crypto_key* key, std::list& algs, crypt_category_t category, const binary_t& input); + return_t preprocess(cose_context_t* handle, crypto_key* key, const binary_t& input); - return_t preprocess_skeleton(cose_context_t* handle, crypto_key* key, std::list& algs, crypt_category_t category, binary_t const& input); + return_t preprocess_skeleton(cose_context_t* handle, crypto_key* key, std::list& algs, crypt_category_t category, const binary_t& input); return_t preprocess_random(cose_context_t* handle, crypto_key* key); return_t preprocess_dorandom(cose_context_t* handle, crypto_key* key, cose_layer* layer); diff --git a/sdk/crypto/cose/cbor_web_key.cpp b/sdk/crypto/cose/cbor_web_key.cpp index 0b2e5978..ac4bcd21 100644 --- a/sdk/crypto/cose/cbor_web_key.cpp +++ b/sdk/crypto/cose/cbor_web_key.cpp @@ -58,7 +58,7 @@ return_t cbor_web_key::load(crypto_key* crypto_key, const char* buffer, int flag return ret; } -return_t cbor_web_key::load(crypto_key* crypto_key, std::string const& buf, int flags) { return load(crypto_key, buf.c_str(), flags); } +return_t cbor_web_key::load(crypto_key* crypto_key, const std::string& buf, int flags) { return load(crypto_key, buf.c_str(), flags); } typedef struct _cose_object_key { int type; @@ -99,7 +99,7 @@ return_t cbor_web_key::load(crypto_key* crypto_key, const byte_t* buffer, size_t return ret; } -return_t cbor_web_key::load(crypto_key* crypto_key, binary_t const& buffer, int flags) { +return_t cbor_web_key::load(crypto_key* crypto_key, const binary_t& buffer, int flags) { return_t ret = errorcode_t::success; __try2 { diff --git a/sdk/crypto/cose/cbor_web_key.hpp b/sdk/crypto/cose/cbor_web_key.hpp index 228f325c..676e5cad 100644 --- a/sdk/crypto/cose/cbor_web_key.hpp +++ b/sdk/crypto/cose/cbor_web_key.hpp @@ -35,15 +35,15 @@ class cbor_web_key : public crypto_keychain { /** * @brief load key from a buffer * @param crypto_key * crypto_key [in] - * @param std::string const& buf [in] + * @param const std::string& buf [in] * @param int flags [inopt] reserved * @return error code (see error.hpp) */ - return_t load(crypto_key* crypto_key, std::string const& buf, int flags = 0); + return_t load(crypto_key* crypto_key, const std::string& buf, int flags = 0); /** * @brief load key from a buffer * @param crypto_key * crypto_key [in] - * @param byte_t* const& buffer [in] + * @param byte_t* const buffer [in] * @param size_t size [in] * @param int flags [inopt] reserved * @return error code (see error.hpp) @@ -52,11 +52,11 @@ class cbor_web_key : public crypto_keychain { /** * @brief load key from a buffer * @param crypto_key * crypto_key [in] - * @param binary_t* const& buffer [in] + * @param const binary_t& buffer [in] * @param int flags [in] reserved * @return error code (see error.hpp) */ - return_t load(crypto_key* crypto_key, binary_t const& buffer, int flags = 0); + return_t load(crypto_key* crypto_key, const binary_t& buffer, int flags = 0); /** * @brief load key from a buffer * @param crypto_key * crypto_key [in] diff --git a/sdk/crypto/cose/cose_composer.cpp b/sdk/crypto/cose/cose_composer.cpp index 95a1493b..7accbd9c 100644 --- a/sdk/crypto/cose/cose_composer.cpp +++ b/sdk/crypto/cose/cose_composer.cpp @@ -26,7 +26,7 @@ namespace crypto { cose_data::cose_key::cose_key() : _curve(0) {} -void cose_data::cose_key::set(crypto_key* key, uint16 curve, binary_t const& x, binary_t const& y) { +void cose_data::cose_key::set(crypto_key* key, uint16 curve, const binary_t& x, const binary_t& y) { _curve = curve; _x = x; _y = y; @@ -39,7 +39,7 @@ void cose_data::cose_key::set(crypto_key* key, uint16 curve, binary_t const& x, keychain.add_ec(key, nullptr, hint->nid, x, y, d); } -void cose_data::cose_key::set(crypto_key* key, uint16 curve, binary_t const& x, bool ysign) { +void cose_data::cose_key::set(crypto_key* key, uint16 curve, const binary_t& x, bool ysign) { _curve = curve; _x = x; _y.clear(); @@ -176,15 +176,15 @@ cose_data& cose_data::replace(int key, const unsigned char* value, size_t size) cose_data& cose_data::add(int key, std::string& value) { return add(key, (unsigned char*)value.c_str(), value.size()); } -cose_data& cose_data::add(int key, std::string const& value) { return add(key, (unsigned char*)value.c_str(), value.size()); } +cose_data& cose_data::add(int key, const std::string& value) { return add(key, (unsigned char*)value.c_str(), value.size()); } cose_data& cose_data::add(int key, binary_t& value) { return add(key, &value[0], value.size()); } -cose_data& cose_data::add(int key, binary_t const& value) { return add(key, &value[0], value.size()); } +cose_data& cose_data::add(int key, const binary_t& value) { return add(key, &value[0], value.size()); } -cose_data& cose_data::replace(int key, binary_t const& value) { return replace(key, &value[0], value.size()); } +cose_data& cose_data::replace(int key, const binary_t& value) { return replace(key, &value[0], value.size()); } -cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, binary_t const& y) { +cose_data& cose_data::add(int key, uint16 curve, const binary_t& x, const binary_t& y) { cose_key* k = nullptr; return_t ret = errorcode_t::success; __try2 { @@ -201,7 +201,7 @@ cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, binary_t con return *this; } -cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, binary_t const& y, std::list& order) { +cose_data& cose_data::add(int key, uint16 curve, const binary_t& x, const binary_t& y, std::list& order) { cose_key* k = nullptr; return_t ret = errorcode_t::success; __try2 { @@ -219,7 +219,7 @@ cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, binary_t con return *this; } -cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, bool ysign) { +cose_data& cose_data::add(int key, uint16 curve, const binary_t& x, bool ysign) { cose_key* k = nullptr; return_t ret = errorcode_t::success; __try2 { @@ -236,7 +236,7 @@ cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, bool ysign) return *this; } -cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, bool ysign, std::list& order) { +cose_data& cose_data::add(int key, uint16 curve, const binary_t& x, bool ysign, std::list& order) { cose_key* k = nullptr; return_t ret = errorcode_t::success; __try2 { @@ -254,7 +254,7 @@ cose_data& cose_data::add(int key, uint16 curve, binary_t const& x, bool ysign, return *this; } -cose_data& cose_data::add(cose_alg_t alg, const char* kid, binary_t const& signature) { +cose_data& cose_data::add(cose_alg_t alg, const char* kid, const binary_t& signature) { cose_countersign* countersign = nullptr; return_t ret = errorcode_t::success; @@ -309,12 +309,12 @@ cose_data& cose_data::add(int key, variant& value) { return *this; } -cose_data& cose_data::set(binary_t const& bin) { +cose_data& cose_data::set(const binary_t& bin) { _payload = bin; return *this; } -cose_data& cose_data::set(std::string const& value) { +cose_data& cose_data::set(const std::string& value) { _payload = convert(value); return *this; } @@ -849,7 +849,7 @@ cose_protected& cose_protected::add(cose_key_t key, uint32 value) { return *this; } -cose_protected& cose_protected::set(binary_t const& bin) { +cose_protected& cose_protected::set(const binary_t& bin) { _protected.set(bin); cbor_object* root = nullptr; cbor_parse(&root, bin); @@ -897,7 +897,7 @@ cose_unprotected& cose_unprotected::add(cose_key_t key, std::string& value) { return *this; } -cose_unprotected& cose_unprotected::add(cose_key_t key, std::string const& value) { +cose_unprotected& cose_unprotected::add(cose_key_t key, const std::string& value) { _unprotected.add(key, value); return *this; } @@ -907,22 +907,22 @@ cose_unprotected& cose_unprotected::add(cose_key_t key, binary_t& value) { return *this; } -cose_unprotected& cose_unprotected::add(cose_key_t key, binary_t const& value) { +cose_unprotected& cose_unprotected::add(cose_key_t key, const binary_t& value) { _unprotected.add(key, value); return *this; } -cose_unprotected& cose_unprotected::add(cose_key_t key, uint16 curve, binary_t const& x, binary_t const& y) { +cose_unprotected& cose_unprotected::add(cose_key_t key, uint16 curve, const binary_t& x, const binary_t& y) { _unprotected.add(key, curve, x, y); return *this; } -cose_unprotected& cose_unprotected::add(cose_key_t key, uint16 curve, binary_t const& x, bool ysign) { +cose_unprotected& cose_unprotected::add(cose_key_t key, uint16 curve, const binary_t& x, bool ysign) { _unprotected.add(key, curve, x, ysign); return *this; } -cose_unprotected& cose_unprotected::add(cose_alg_t alg, const char* kid, binary_t const& signature) { +cose_unprotected& cose_unprotected::add(cose_alg_t alg, const char* kid, const binary_t& signature) { _unprotected.add(alg, kid, signature); return *this; } @@ -949,17 +949,17 @@ cose_binary& cose_binary::set_b16(const char* value) { return *this; } -cose_binary& cose_binary::set_b16(std::string const& value) { +cose_binary& cose_binary::set_b16(const std::string& value) { _payload.set_b16(value); return *this; } -cose_binary& cose_binary::set(std::string const& value) { +cose_binary& cose_binary::set(const std::string& value) { _payload.set(value); return *this; } -cose_binary& cose_binary::set(binary_t const& value) { +cose_binary& cose_binary::set(const binary_t& value) { _payload.set(value); return *this; } @@ -1153,7 +1153,7 @@ return_t cose_recipient::finditem(int key, binary_t& value, int scope) { return ret; } -return_t cose_recipient::setparam(cose_param_t id, binary_t const& bin) { +return_t cose_recipient::setparam(cose_param_t id, const binary_t& bin) { return_t ret = errorcode_t::success; __try2 { switch (id) { @@ -1621,7 +1621,7 @@ cose_unsent& cose_unsent::add(int key, binary_t& value) { return *this; } -cose_unsent& cose_unsent::add(int key, binary_t const& value) { +cose_unsent& cose_unsent::add(int key, const binary_t& value) { if (isvalid(key)) { _unsent.add(key, value); } @@ -1751,7 +1751,7 @@ return_t cose_composer::diagnose(cbor_array** object, basic_stream& stream, bool return ret; } -return_t cose_composer::parse(binary_t const& input) { +return_t cose_composer::parse(const binary_t& input) { return_t ret = errorcode_t::success; cbor_object* root = nullptr; cbor_array* cbor_message = nullptr; diff --git a/sdk/crypto/cose/cose_composer.hpp b/sdk/crypto/cose/cose_composer.hpp index 32798b34..38fab81e 100644 --- a/sdk/crypto/cose/cose_composer.hpp +++ b/sdk/crypto/cose/cose_composer.hpp @@ -72,32 +72,32 @@ class cose_data { cose_data& add(int key, const char* value); cose_data& add(int key, const unsigned char* value, size_t size); cose_data& add(int key, std::string& value); - cose_data& add(int key, std::string const& value); + cose_data& add(int key, const std::string& value); cose_data& add(int key, binary_t& value); - cose_data& add(int key, binary_t const& value); + cose_data& add(int key, const binary_t& value); cose_data& add(int key, variant& value); cose_data& replace(int key, const unsigned char* value, size_t size); - cose_data& replace(int key, binary_t const& value); + cose_data& replace(int key, const binary_t& value); /** * @brief ephemeral/static key */ - cose_data& add(int key, uint16 curve, binary_t const& x, binary_t const& y); - cose_data& add(int key, uint16 curve, binary_t const& x, bool ysign); - cose_data& add(int key, uint16 curve, binary_t const& x, binary_t const& y, std::list& order); - cose_data& add(int key, uint16 curve, binary_t const& x, bool ysign, std::list& order); + cose_data& add(int key, uint16 curve, const binary_t& x, const binary_t& y); + cose_data& add(int key, uint16 curve, const binary_t& x, bool ysign); + cose_data& add(int key, uint16 curve, const binary_t& x, const binary_t& y, std::list& order); + cose_data& add(int key, uint16 curve, const binary_t& x, bool ysign, std::list& order); /** * @brief counter signature */ - cose_data& add(cose_alg_t alg, const char* kid, binary_t const& signature); + cose_data& add(cose_alg_t alg, const char* kid, const binary_t& signature); cose_data& add(cose_recipient* countersig); cose_data& add(int key, vartype_t vty, void* p); /** * @brief payload (binary/base16) */ - cose_data& set(binary_t const& value); - cose_data& set(std::string const& value); + cose_data& set(const binary_t& value); + cose_data& set(const std::string& value); cose_data& set_b16(std::string const value); cose_data& set_b16(const char* value); /** @@ -167,8 +167,8 @@ class cose_data { class cose_key { public: cose_key(); - void set(crypto_key* key, uint16 curve, binary_t const& x, binary_t const& y); - void set(crypto_key* key, uint16 curve, binary_t const& x, bool ysign); + void set(crypto_key* key, uint16 curve, const binary_t& x, const binary_t& y); + void set(crypto_key* key, uint16 curve, const binary_t& x, bool ysign); void set(cose_orderlist_t& order); cbor_map* cbor(); @@ -208,7 +208,7 @@ class cose_protected { /** * @brief set */ - cose_protected& set(binary_t const& bin); + cose_protected& set(const binary_t& bin); /** * @brief data */ @@ -250,22 +250,22 @@ class cose_unprotected { cose_unprotected& add(cose_key_t key, int32 value); cose_unprotected& add(cose_key_t key, const char* value); cose_unprotected& add(cose_key_t key, std::string& value); - cose_unprotected& add(cose_key_t key, std::string const& value); + cose_unprotected& add(cose_key_t key, const std::string& value); cose_unprotected& add(cose_key_t key, binary_t& value); - cose_unprotected& add(cose_key_t key, binary_t const& value); + cose_unprotected& add(cose_key_t key, const binary_t& value); /** * @brief ephemeral key * @param cose_key_t key [in] cose_key_t::cose_ephemeral_key * @param uint16 curve [in] - * @param binary_t const& x [in] - * @param binary_t const& y [in] + * @param const binary_t& x [in] + * @param const binary_t& y [in] */ - cose_unprotected& add(cose_key_t key, uint16 curve, binary_t const& x, binary_t const& y); - cose_unprotected& add(cose_key_t key, uint16 curve, binary_t const& x, bool ysign); + cose_unprotected& add(cose_key_t key, uint16 curve, const binary_t& x, const binary_t& y); + cose_unprotected& add(cose_key_t key, uint16 curve, const binary_t& x, bool ysign); /** * @brief counter signature */ - cose_unprotected& add(cose_alg_t alg, const char* kid, binary_t const& signature); + cose_unprotected& add(cose_alg_t alg, const char* kid, const binary_t& signature); /** * @brief data */ @@ -304,9 +304,9 @@ class cose_binary { * @brief set */ cose_binary& set_b16(const char* value); - cose_binary& set_b16(std::string const& value); - cose_binary& set(std::string const& value); - cose_binary& set(binary_t const& value); + cose_binary& set_b16(const std::string& value); + cose_binary& set(const std::string& value); + cose_binary& set(const binary_t& value); /** * @brief data */ @@ -429,7 +429,7 @@ class cose_recipient { return_t finditem(int key, std::string& value, int scope = cose_scope_layer); return_t finditem(int key, binary_t& value, int scope = cose_scope_layer); - return_t setparam(cose_param_t id, binary_t const& bin); + return_t setparam(cose_param_t id, const binary_t& bin); return_t getparam(cose_param_t id, binary_t& bin); cose_alg_t get_algorithm(); @@ -475,7 +475,7 @@ class cose_unsent { cose_unsent& add(int key, const char* value); cose_unsent& add(int key, const unsigned char* value, size_t size); cose_unsent& add(int key, binary_t& value); - cose_unsent& add(int key, binary_t const& value); + cose_unsent& add(int key, const binary_t& value); cose_data& data(); @@ -565,7 +565,7 @@ class cose_composer { * composer.parse(cbor); * composer.compose(&root); */ - return_t parse(binary_t const& input); + return_t parse(const binary_t& input); /** * @brief get * @desc diff --git a/sdk/crypto/crypto.hpp b/sdk/crypto/crypto.hpp index 48388ccb..6fc3564a 100644 --- a/sdk/crypto/crypto.hpp +++ b/sdk/crypto/crypto.hpp @@ -46,20 +46,20 @@ class crypt_t { * @param crypt_context_t** handle [out] * @param crypt_algorithm_t algorithm [in] * @param crypt_mode_t mode [in] - * @param binary_t const& key [in] - * @param binary_t const& iv [in] + * @param const binary_t& key [in] + * @param const binary_t& iv [in] * @return error code (see error.hpp) */ - virtual return_t open(crypt_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, binary_t const& key, binary_t const& iv) = 0; + virtual return_t open(crypt_context_t** handle, crypt_algorithm_t algorithm, crypt_mode_t mode, const binary_t& key, const binary_t& iv) = 0; /** * @brief create a context handle (symmetric) * @param crypt_context_t** handle [out] * @param const char* cipher [in] ex. "aes-128-cbc" - * @param binary_t const& key [in] - * @param binary_t const& iv [in] + * @param const binary_t& key [in] + * @param const binary_t& iv [in] * @return error code (see error.hpp) */ - virtual return_t open(crypt_context_t** handle, const char* cipher, binary_t const& key, binary_t const& iv) = 0; + virtual return_t open(crypt_context_t** handle, const char* cipher, const binary_t& key, const binary_t& iv) = 0; /** * @brief destroy a context handle * @param crypt_context_t* handle [in] @@ -100,12 +100,12 @@ class crypt_t { /** * @brief encrypt * @param crypt_context_t* handle [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& out [out] * @return error code (see error.hpp) * @example */ - virtual return_t encrypt(crypt_context_t* handle, binary_t const& input, binary_t& out) = 0; + virtual return_t encrypt(crypt_context_t* handle, const binary_t& input, binary_t& out) = 0; /** * @brief encrypt (GCM) @@ -145,11 +145,11 @@ class crypt_t { /** * @brief decrypt * @param crypt_context_t* handle [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& out [out] * @return error code (see error.hpp) */ - virtual return_t decrypt(crypt_context_t* handle, binary_t const& input, binary_t& out) = 0; + virtual return_t decrypt(crypt_context_t* handle, const binary_t& input, binary_t& out) = 0; /** * @brief decrypt (GCM) @@ -227,13 +227,13 @@ class hash_t { /** * @brief open (HMAC, CMAC) */ - virtual return_t open(hash_context_t** handle, const char* algorithm, binary_t const& key) = 0; + virtual return_t open(hash_context_t** handle, const char* algorithm, const binary_t& key) = 0; virtual return_t open(hash_context_t** handle, hash_algorithm_t alg, const unsigned char* key = nullptr, unsigned keysize = 0) = 0; /** * @brief open (HMAC) */ - virtual return_t open(hash_context_t** handle, hash_algorithm_t alg, binary_t const& key) = 0; + virtual return_t open(hash_context_t** handle, hash_algorithm_t alg, const binary_t& key) = 0; /** * @brief open (CMAC) * @param hash_context_t** handle [out] @@ -247,7 +247,7 @@ class hash_t { /** * @brief open (CMAC) */ - virtual return_t open(hash_context_t** handle, crypt_algorithm_t alg, crypt_mode_t mode, binary_t const& key) = 0; + virtual return_t open(hash_context_t** handle, crypt_algorithm_t alg, crypt_mode_t mode, const binary_t& key) = 0; /** * @brief close * @param hash_context_t* handle [in] @@ -278,7 +278,7 @@ class hash_t { * hash.free_data(output_data); */ virtual return_t update(hash_context_t* handle, const byte_t* data, size_t datasize) = 0; - virtual return_t update(hash_context_t* handle, binary_t const& input) = 0; + virtual return_t update(hash_context_t* handle, const binary_t& input) = 0; /** * @brief get * @param hash_context_t* handle [in] diff --git a/sdk/crypto/jose/json_object_encryption.cpp b/sdk/crypto/jose/json_object_encryption.cpp index deeaea71..bd94fd63 100644 --- a/sdk/crypto/jose/json_object_encryption.cpp +++ b/sdk/crypto/jose/json_object_encryption.cpp @@ -41,7 +41,7 @@ json_object_encryption::~json_object_encryption() { // do nothing } -return_t json_object_encryption::encrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, binary_t const& input, std::string& output, jose_serialization_t type) { +return_t json_object_encryption::encrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const binary_t& input, std::string& output, jose_serialization_t type) { return_t ret = errorcode_t::success; json_object_encryption::composer composer; @@ -77,7 +77,7 @@ return_t json_object_encryption::encrypt(jose_context_t* handle, jwe_t enc, jwa_ return ret; } -return_t json_object_encryption::encrypt(jose_context_t* handle, jwe_t enc, std::list algs, binary_t const& input, std::string& output, +return_t json_object_encryption::encrypt(jose_context_t* handle, jwe_t enc, std::list algs, const binary_t& input, std::string& output, jose_serialization_t type) { return_t ret = errorcode_t::success; json_object_encryption::composer composer; @@ -138,7 +138,7 @@ return_t json_object_encryption::encrypt(jose_context_t* handle, jwe_t enc, std: return ret; } -return_t json_object_encryption::decrypt(jose_context_t* handle, std::string const& input, binary_t& output, bool& result) { +return_t json_object_encryption::decrypt(jose_context_t* handle, const std::string& input, binary_t& output, bool& result) { return_t ret = errorcode_t::success; json_object_encryption::composer composer; @@ -211,7 +211,7 @@ return_t json_object_encryption::decrypt(jose_context_t* handle, std::string con return ret; } -return_t json_object_encryption::doencrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, binary_t const& input, binary_t& output) { +return_t json_object_encryption::doencrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; json_object_encryption::composer composer; openssl_crypt crypt; @@ -448,11 +448,11 @@ return_t json_object_encryption::doencrypt(jose_context_t* handle, jwe_t enc, jw return ret; } -return_t json_object_encryption::dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, binary_t const& input, binary_t& output) { +return_t json_object_encryption::dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const binary_t& input, binary_t& output) { return dodecrypt(handle, enc, alg, nullptr, input, output); } -return_t json_object_encryption::dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const char* kid, binary_t const& input, binary_t& output) { +return_t json_object_encryption::dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const char* kid, const binary_t& input, binary_t& output) { return_t ret = errorcode_t::success; openssl_crypt crypt; openssl_hash hash; @@ -909,7 +909,7 @@ return_t json_object_encryption::composer::compose_encryption(jose_context_t* ha return ret; } -return_t json_object_encryption::composer::compose_encryption_aead_header(std::string const& source_encoded, binary_t const& tag, binary_t& aad, +return_t json_object_encryption::composer::compose_encryption_aead_header(const std::string& source_encoded, const binary_t& tag, binary_t& aad, std::string& output_encoded) { return_t ret = errorcode_t::success; json_t* json_header = nullptr; @@ -1058,7 +1058,7 @@ return_t json_object_encryption::composer::compose_encryption_dorandom(jose_cont return ret; } -return_t json_object_encryption::composer::docompose_protected_header(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, std::string const& kid, +return_t json_object_encryption::composer::docompose_protected_header(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, const std::string& kid, uint32 flags) { return_t ret = errorcode_t::success; crypt_datamap_t datamap; @@ -1069,7 +1069,7 @@ return_t json_object_encryption::composer::docompose_protected_header(binary_t& } return_t json_object_encryption::composer::docompose_encryption_header_parameter(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, - std::string const& kid, crypt_datamap_t& datamap, + const std::string& kid, crypt_datamap_t& datamap, crypt_variantmap_t& variantmap, uint32 flags) { return_t ret = errorcode_t::success; json_t* json_header = nullptr; diff --git a/sdk/crypto/jose/json_object_encryption.hpp b/sdk/crypto/jose/json_object_encryption.hpp index 7d538955..741f9cd6 100644 --- a/sdk/crypto/jose/json_object_encryption.hpp +++ b/sdk/crypto/jose/json_object_encryption.hpp @@ -28,7 +28,7 @@ class json_object_encryption { * @param jose_context_t* context [in] * @param jwe_t enc [in] * @param jwa_t alg [in] support all algorithms including jwa_t::jwa_dir, jwa_t::jwa_ecdh_es - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -49,7 +49,7 @@ class json_object_encryption { * jose.close (handle_encrypt); * jose.close (handle_decrypt); */ - return_t encrypt(jose_context_t* context, jwe_t enc, jwa_t alg, binary_t const& input, std::string& output, + return_t encrypt(jose_context_t* context, jwe_t enc, jwa_t alg, const binary_t& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief encrypt @@ -64,7 +64,7 @@ class json_object_encryption { * case "ECDH-ES" * read cek using ECDH-ES * protected, iv, ciphertext, tag, recipients:[ header {alg:ECDH-ES, epk}, encrypted_key ] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -95,12 +95,12 @@ class json_object_encryption { * ret = jose.encrypt (handle_encrypt, jwe_t::jwe_a128cbc_hs256, algs, convert (input), encrypted, jose_serialization_t::jose_json); * jose.close (handle_encrypt); */ - return_t encrypt(jose_context_t* context, jwe_t enc, std::list algs, binary_t const& input, std::string& output, + return_t encrypt(jose_context_t* context, jwe_t enc, std::list algs, const binary_t& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief decrypt * @param jose_context_t* context [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param binary_t& output [out] * @param bool& result [out] * @return error code (see error.hpp) @@ -115,7 +115,7 @@ class json_object_encryption { * ret = jose.decrypt (handle_decrypt, encrypted, output, result); * jose.close (handle_decrypt); */ - return_t decrypt(jose_context_t* context, std::string const& input, binary_t& output, bool& result); + return_t decrypt(jose_context_t* context, const std::string& input, binary_t& output, bool& result); protected: /** @@ -123,35 +123,35 @@ class json_object_encryption { * @param jose_context_t* handle [in] see json_object_signing_encryption::open and close * @param jwe_t enc [in] * @param jwa_t alg [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::encrypt */ - return_t doencrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, binary_t const& input, binary_t& output); + return_t doencrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const binary_t& input, binary_t& output); /** * @brief decrypt * @param jose_context_t* handle * @param jwe_t enc [in] * @param jwa_t alg [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::decrypt */ - return_t dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, binary_t const& input, binary_t& output); + return_t dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const binary_t& input, binary_t& output); /** * @brief decrypt * @param jose_context_t* handle * @param jwe_t enc [in] * @param jwa_t alg [in] * @param const char* kid [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::decrypt */ - return_t dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const char* kid, binary_t const& input, binary_t& output); + return_t dodecrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const char* kid, const binary_t& input, binary_t& output); /** * @brief constraints @@ -172,12 +172,12 @@ class json_object_encryption { return_t compose_encryption(jose_context_t* context, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief update tag after AESGCMKW - * @param std::string const& source_encoded [in] - * @param binary_t const& tag [in] + * @param const std::string& source_encoded [in] + * @param const binary_t& tag [in] * @param binary_t& aad [out] * @param std::string& output_encoded [out] */ - return_t compose_encryption_aead_header(std::string const& source_encoded, binary_t const& tag, binary_t& aad, std::string& output_encoded); + return_t compose_encryption_aead_header(const std::string& source_encoded, const binary_t& tag, binary_t& aad, std::string& output_encoded); /** * @brief encryption * @param jwe_t enc [in] @@ -201,24 +201,24 @@ class json_object_encryption { * @param jwe_t enc [in] * @param jwa_t alg [in] * @param jose_compose_t flag [in] - * @param std::string const& kid [in] + * @param const std::string& kid [in] * @param uint32 flags [inopt] see setoption * @remarks * docompose_protected_header (header, jwe_t::jwe_a128cbc_hs256, jwa_t::jwa_unknown, jose_compose_t::jose_enc_alg, ""); */ - return_t docompose_protected_header(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, std::string const& kid, uint32 flags = 0); + return_t docompose_protected_header(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, const std::string& kid, uint32 flags = 0); /** * @brief header * @param binary_t& header [out] * @param jwe_t enc [in] * @param jwa_t alg [in] * @param jose_compose_t flag [in] - * @param std::string const& kid [in] + * @param const std::string& kid [in] * @param crypt_datamap_t& datamap [in] * @param crypt_variantmap_t& variantmap [in] * @param uint32 flags [inopt] see setoption */ - return_t docompose_encryption_header_parameter(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, std::string const& kid, + return_t docompose_encryption_header_parameter(binary_t& header, jwe_t enc, jwa_t alg, jose_compose_t flag, const std::string& kid, crypt_datamap_t& datamap, crypt_variantmap_t& variantmap, uint32 flags = 0); /** * @biref recipient diff --git a/sdk/crypto/jose/json_object_signing.cpp b/sdk/crypto/jose/json_object_signing.cpp index 23fc85c4..996fe574 100644 --- a/sdk/crypto/jose/json_object_signing.cpp +++ b/sdk/crypto/jose/json_object_signing.cpp @@ -25,14 +25,14 @@ json_object_signing::json_object_signing() { openssl_startup(); } json_object_signing::~json_object_signing() { openssl_cleanup(); } -return_t json_object_signing::sign(jose_context_t* handle, jws_t sig, std::string const& input, std::string& output, jose_serialization_t type) { +return_t json_object_signing::sign(jose_context_t* handle, jws_t sig, const std::string& input, std::string& output, jose_serialization_t type) { std::list methods; methods.push_back(sig); return sign(handle, methods, input, output, type); } -return_t json_object_signing::sign(jose_context_t* handle, std::list const& methods, std::string const& input, std::string& output, +return_t json_object_signing::sign(jose_context_t* handle, std::list const& methods, const std::string& input, std::string& output, jose_serialization_t type) { return_t ret = errorcode_t::success; crypto_advisor* advisor = crypto_advisor::get_instance(); @@ -64,7 +64,7 @@ return_t json_object_signing::sign(jose_context_t* handle, std::list cons return ret; } -return_t json_object_signing::sign(jose_context_t* handle, std::string const& protected_header, std::string const& input, std::string& output, +return_t json_object_signing::sign(jose_context_t* handle, const std::string& protected_header, const std::string& input, std::string& output, jose_serialization_t type) { std::list headers; @@ -72,7 +72,7 @@ return_t json_object_signing::sign(jose_context_t* handle, std::string const& pr return sign(handle, headers, input, output, type); } -return_t json_object_signing::sign(jose_context_t* handle, std::list const& headers, std::string const& input, std::string& output, +return_t json_object_signing::sign(jose_context_t* handle, std::list const& headers, const std::string& input, std::string& output, jose_serialization_t type) { return_t ret = errorcode_t::success; json_object_signing::composer composer; @@ -140,7 +140,7 @@ return_t json_object_signing::sign(jose_context_t* handle, std::list const& methods [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -72,13 +72,13 @@ class json_object_signing { * jose.verify (jose_context, jws_result, result); * jose.close (jose_context); */ - return_t sign(jose_context_t* context, std::list const& methods, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, std::list const& methods, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief sign * @param jose_context_t* context [in] - * @param std::string const& protected_header [in] - * @param std::string const& input [in] + * @param const std::string& protected_header [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -96,69 +96,69 @@ class json_object_signing { * jose.verify (jose_context, jws_result, result); * jose.close (jose_context); */ - return_t sign(jose_context_t* context, std::string const& protected_header, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, const std::string& protected_header, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief sign * @param jose_context_t* context [in] * @param std::list const& headers [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) */ - return_t sign(jose_context_t* context, std::list const& headers, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, std::list const& headers, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief verify * @param jose_context_t* context [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param bool& result [out] * @return error code (see error.hpp) */ - return_t verify(jose_context_t* context, std::string const& input, bool& result); + return_t verify(jose_context_t* context, const std::string& input, bool& result); protected: /** * @brief sign * @param crypto_key* key [in] * @param jws_t method [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @remarks see json_object_signing_encryption::sign */ - return_t dosign(crypto_key* key, jws_t method, binary_t const& input, binary_t& output); + return_t dosign(crypto_key* key, jws_t method, const binary_t& input, binary_t& output); /** * @brief sign and return signature and kid * @param crypto_key* key [in] * @param jws_t method [in] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param binary_t& output [out] * @param std::string& kid [out] * @remarks see json_object_signing_encryption::sign */ - return_t dosign(crypto_key* key, jws_t method, binary_t const& input, binary_t& output, std::string& kid); + return_t dosign(crypto_key* key, jws_t method, const binary_t& input, binary_t& output, std::string& kid); /** * @brief verify * @param crypto_key* key [in] * @param jws_t method [in] - * @param binary_t const& input [in] - * @param binary_t const& output [in] + * @param const binary_t& input [in] + * @param const binary_t& output [in] * @param bool& result [out] * @remarks see json_object_signing_encryption::verify */ - return_t doverify(crypto_key* key, jws_t method, binary_t const& input, binary_t const& output, bool& result); + return_t doverify(crypto_key* key, jws_t method, const binary_t& input, const binary_t& output, bool& result); /** * @brief verify with kid * @param crypto_key* key [in] * @param const char* kid [in] * @param jws_t method [in] - * @param binary_t const& input [in] - * @param binary_t const& output [in] + * @param const binary_t& input [in] + * @param const binary_t& output [in] * @param bool& result [out] * @remarks see json_object_signing_encryption::verify */ - return_t doverify(crypto_key* key, const char* kid, jws_t method, binary_t const& input, binary_t const& output, bool& result); + return_t doverify(crypto_key* key, const char* kid, jws_t method, const binary_t& input, const binary_t& output, bool& result); /** * @brief constraints diff --git a/sdk/crypto/jose/json_object_signing_encryption.cpp b/sdk/crypto/jose/json_object_signing_encryption.cpp index 0d088327..30acab02 100644 --- a/sdk/crypto/jose/json_object_signing_encryption.cpp +++ b/sdk/crypto/jose/json_object_signing_encryption.cpp @@ -106,54 +106,54 @@ return_t json_object_signing_encryption::setoption(jose_context_t* handle, uint3 return ret; } -return_t json_object_signing_encryption::encrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, binary_t const& input, std::string& output, +return_t json_object_signing_encryption::encrypt(jose_context_t* handle, jwe_t enc, jwa_t alg, const binary_t& input, std::string& output, jose_serialization_t type) { json_object_encryption jwe; return jwe.encrypt(handle, enc, alg, input, output, type); } -return_t json_object_signing_encryption::encrypt(jose_context_t* handle, jwe_t enc, std::list algs, binary_t const& input, std::string& output, +return_t json_object_signing_encryption::encrypt(jose_context_t* handle, jwe_t enc, std::list algs, const binary_t& input, std::string& output, jose_serialization_t type) { json_object_encryption jwe; return jwe.encrypt(handle, enc, algs, input, output, type); } -return_t json_object_signing_encryption::decrypt(jose_context_t* handle, std::string const& input, binary_t& output, bool& result) { +return_t json_object_signing_encryption::decrypt(jose_context_t* handle, const std::string& input, binary_t& output, bool& result) { json_object_encryption jwe; return jwe.decrypt(handle, input, output, result); } -return_t json_object_signing_encryption::sign(jose_context_t* context, jws_t method, std::string const& input, std::string& output, jose_serialization_t type) { +return_t json_object_signing_encryption::sign(jose_context_t* context, jws_t method, const std::string& input, std::string& output, jose_serialization_t type) { json_object_signing jws; return jws.sign(context, method, input, output, type); } -return_t json_object_signing_encryption::sign(jose_context_t* context, std::list const& methods, std::string const& input, std::string& output, +return_t json_object_signing_encryption::sign(jose_context_t* context, std::list const& methods, const std::string& input, std::string& output, jose_serialization_t type) { json_object_signing jws; return jws.sign(context, methods, input, output, type); } -return_t json_object_signing_encryption::sign(jose_context_t* context, std::string const& protected_header, std::string const& input, std::string& output, +return_t json_object_signing_encryption::sign(jose_context_t* context, const std::string& protected_header, const std::string& input, std::string& output, jose_serialization_t type) { json_object_signing jws; return jws.sign(context, protected_header, input, output, type); } -return_t json_object_signing_encryption::sign(jose_context_t* context, std::list const& headers, std::string const& input, std::string& output, +return_t json_object_signing_encryption::sign(jose_context_t* context, std::list const& headers, const std::string& input, std::string& output, jose_serialization_t type) { json_object_signing jws; return jws.sign(context, headers, input, output, type); } -return_t json_object_signing_encryption::verify(jose_context_t* context, std::string const& input, bool& result) { +return_t json_object_signing_encryption::verify(jose_context_t* context, const std::string& input, bool& result) { json_object_signing jws; return jws.verify(context, input, result); diff --git a/sdk/crypto/jose/json_object_signing_encryption.hpp b/sdk/crypto/jose/json_object_signing_encryption.hpp index 5faba394..96bee6c1 100644 --- a/sdk/crypto/jose/json_object_signing_encryption.hpp +++ b/sdk/crypto/jose/json_object_signing_encryption.hpp @@ -211,7 +211,7 @@ class json_object_signing_encryption { * @param jose_context_t* context [in] * @param jwe_t enc [in] * @param jwa_t alg [in] support all algorithms including jwa_t::jwa_dir, jwa_t::jwa_ecdh_es - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -232,7 +232,7 @@ class json_object_signing_encryption { * jose.close (handle_encrypt); * jose.close (handle_decrypt); */ - return_t encrypt(jose_context_t* context, jwe_t enc, jwa_t alg, binary_t const& input, std::string& output, + return_t encrypt(jose_context_t* context, jwe_t enc, jwa_t alg, const binary_t& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief encrypt @@ -247,7 +247,7 @@ class json_object_signing_encryption { * case "ECDH-ES" * read cek using ECDH-ES * protected, iv, ciphertext, tag, recipients:[ header {alg:ECDH-ES, epk}, encrypted_key ] - * @param binary_t const& input [in] + * @param const binary_t& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -278,12 +278,12 @@ class json_object_signing_encryption { * ret = jose.encrypt (handle_encrypt, jwe_t::jwe_a128cbc_hs256, algs, convert (input), encrypted, jose_serialization_t::jose_json); * jose.close (handle_encrypt); */ - return_t encrypt(jose_context_t* context, jwe_t enc, std::list algs, binary_t const& input, std::string& output, + return_t encrypt(jose_context_t* context, jwe_t enc, std::list algs, const binary_t& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief decrypt * @param jose_context_t* context [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param binary_t& output [out] * @param bool& result [out] * @return error code (see error.hpp) @@ -298,12 +298,12 @@ class json_object_signing_encryption { * ret = jose.decrypt (handle_decrypt, encrypted, output, result); * jose.close (handle_decrypt); */ - return_t decrypt(jose_context_t* context, std::string const& input, binary_t& output, bool& result); + return_t decrypt(jose_context_t* context, const std::string& input, binary_t& output, bool& result); /** * @brief sign * @param jose_context_t* context [in] * @param jws_t method [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -321,13 +321,13 @@ class json_object_signing_encryption { * jose.verify (jose_context, jws_result, result); * jose.close (jose_context); */ - return_t sign(jose_context_t* context, jws_t method, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, jws_t method, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief sign * @param jose_context_t* context [in] * @param std::list const& methods [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -349,13 +349,13 @@ class json_object_signing_encryption { * jose.verify (jose_context, jws_result, result); * jose.close (jose_context); */ - return_t sign(jose_context_t* context, std::list const& methods, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, std::list const& methods, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief sign * @param jose_context_t* context [in] - * @param std::string const& protected_header [in] - * @param std::string const& input [in] + * @param const std::string& protected_header [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) @@ -373,27 +373,27 @@ class json_object_signing_encryption { * jose.verify (jose_context, jws_result, result); * jose.close (jose_context); */ - return_t sign(jose_context_t* context, std::string const& protected_header, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, const std::string& protected_header, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief sign * @param jose_context_t* context [in] * @param std::list const& headers [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param std::string& output [out] * @param jose_serialization_t type [inopt] * @return error code (see error.hpp) */ - return_t sign(jose_context_t* context, std::list const& headers, std::string const& input, std::string& output, + return_t sign(jose_context_t* context, std::list const& headers, const std::string& input, std::string& output, jose_serialization_t type = jose_serialization_t::jose_compact); /** * @brief verify * @param jose_context_t* context [in] - * @param std::string const& input [in] + * @param const std::string& input [in] * @param bool& result [out] * @return error code (see error.hpp) */ - return_t verify(jose_context_t* context, std::string const& input, bool& result); + return_t verify(jose_context_t* context, const std::string& input, bool& result); /** * @brief clear/reset diff --git a/sdk/crypto/jose/json_web_signature.cpp b/sdk/crypto/jose/json_web_signature.cpp index bbf276d5..5e069658 100644 --- a/sdk/crypto/jose/json_web_signature.cpp +++ b/sdk/crypto/jose/json_web_signature.cpp @@ -23,7 +23,7 @@ json_web_signature::~json_web_signature() { // do nothing } -return_t json_web_signature::sign(crypto_key* crypto_key, std::string const& header, std::string const& claims, std::string& signature, +return_t json_web_signature::sign(crypto_key* crypto_key, const std::string& header, const std::string& claims, std::string& signature, jose_serialization_t mode) { return_t ret = errorcode_t::success; json_object_signing_encryption jose; @@ -43,7 +43,7 @@ return_t json_web_signature::sign(crypto_key* crypto_key, std::string const& hea return ret; } -return_t json_web_signature::sign(crypto_key* crypto_key, std::list const& headers, std::string const& claims, std::string& signature, +return_t json_web_signature::sign(crypto_key* crypto_key, std::list const& headers, const std::string& claims, std::string& signature, jose_serialization_t mode) { return_t ret = errorcode_t::success; json_object_signing_encryption jose; @@ -63,14 +63,14 @@ return_t json_web_signature::sign(crypto_key* crypto_key, std::list return ret; } -return_t json_web_signature::sign(crypto_key* crypto_key, jws_t alg, std::string const& claims, std::string& signature, jose_serialization_t mode) { +return_t json_web_signature::sign(crypto_key* crypto_key, jws_t alg, const std::string& claims, std::string& signature, jose_serialization_t mode) { std::list algs; algs.push_back(alg); return sign(crypto_key, algs, claims, signature, mode); } -return_t json_web_signature::sign(crypto_key* crypto_key, std::list const& algs, std::string const& claims, std::string& signature, +return_t json_web_signature::sign(crypto_key* crypto_key, std::list const& algs, const std::string& claims, std::string& signature, jose_serialization_t mode) { return_t ret = errorcode_t::success; json_object_signing_encryption jose; @@ -90,7 +90,7 @@ return_t json_web_signature::sign(crypto_key* crypto_key, std::list const return ret; } -return_t json_web_signature::verify(crypto_key* crypto_key, std::string const& signature, bool& result) { +return_t json_web_signature::verify(crypto_key* crypto_key, const std::string& signature, bool& result) { return_t ret = errorcode_t::success; json_object_signing_encryption jose; jose_context_t* jose_context = nullptr; diff --git a/sdk/crypto/jose/json_web_signature.hpp b/sdk/crypto/jose/json_web_signature.hpp index 852a6ea7..9eac5988 100644 --- a/sdk/crypto/jose/json_web_signature.hpp +++ b/sdk/crypto/jose/json_web_signature.hpp @@ -69,8 +69,8 @@ class json_web_signature { /** * @brief sign * @param crypto_key* crypto_key [in] - * @param std::string const& header [in] - * @param std::string const& claims [in] + * @param const std::string& header [in] + * @param const std::string& claims [in] * @param std::string& signature [out] * @param jose_serialization_t mode [in] * @return error code (see error.hpp) @@ -87,13 +87,13 @@ class json_web_signature { * // . * // DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q */ - return_t sign(crypto_key* crypto_key, std::string const& header, std::string const& claims, std::string& signature, + return_t sign(crypto_key* crypto_key, const std::string& header, const std::string& claims, std::string& signature, jose_serialization_t mode = jose_serialization_t::jose_compact); /** * @brief sign * @param crypto_key* crypto_key [in] * @param std::list const& headers [in] - * @param std::string const& claims [in] + * @param const std::string& claims [in] * @param std::string& signature [out] * @param jose_serialization_t mode [in] * @return error code (see error.hpp) @@ -105,13 +105,13 @@ class json_web_signature { * headers.push_back (ps256_header); * jws.sign (&crypto_key, headers, claim, signature); */ - return_t sign(crypto_key* crypto_key, std::list const& headers, std::string const& claims, std::string& signature, + return_t sign(crypto_key* crypto_key, std::list const& headers, const std::string& claims, std::string& signature, jose_serialization_t mode = jose_serialization_t::jose_compact); /** * @brief sign * @param crypto_key* crypto_key [in] * @param jws_t alg header [in] - * @param std::string const& claims [in] + * @param const std::string& claims [in] * @param std::string& signature [out] * @param jose_serialization_t mode [in] * @return error code (see error.hpp) @@ -119,13 +119,13 @@ class json_web_signature { * @example * jws.sign (&crypto_key, jws_t::jws_hs256, claim, signature); */ - return_t sign(crypto_key* crypto_key, jws_t alg, std::string const& claims, std::string& signature, + return_t sign(crypto_key* crypto_key, jws_t alg, const std::string& claims, std::string& signature, jose_serialization_t mode = jose_serialization_t::jose_compact); /** * @brief sign * @param crypto_key* crypto_key [in] * @param std::list const& algs [in] - * @param std::string const& claims [in] + * @param const std::string& claims [in] * @param std::string& signature [out] * @param jose_serialization_t mode [in] * @return error code (see error.hpp) @@ -137,17 +137,17 @@ class json_web_signature { * algs.push_back (jws_t::jws_ps256); * jws.sign (&crypto_key, algs, claim, signature); */ - return_t sign(crypto_key* crypto_key, std::list const& algs, std::string const& claims, std::string& signature, + return_t sign(crypto_key* crypto_key, std::list const& algs, const std::string& claims, std::string& signature, jose_serialization_t mode = jose_serialization_t::jose_compact); /** * @brief verify * @param crypto_key* crypto_key [in] - * @param std::string const& signature [in] + * @param const std::string& signature [in] * @param bool& result [out] * @return error code (see error.hpp) * @remarks see json_object_signing_encryption::verify */ - return_t verify(crypto_key* crypto_key, std::string const& signature, bool& result); + return_t verify(crypto_key* crypto_key, const std::string& signature, bool& result); }; } // namespace crypto diff --git a/sdk/io/basic/keyvalue.cpp b/sdk/io/basic/keyvalue.cpp index ddd1ec78..2c06cf64 100644 --- a/sdk/io/basic/keyvalue.cpp +++ b/sdk/io/basic/keyvalue.cpp @@ -69,7 +69,7 @@ return_t key_value::set(const char* name, const char* value, int mode) { return ret; } -return_t key_value::set(std::string const& key, std::string const& value, int mode) { +return_t key_value::set(const std::string& key, const std::string& value, int mode) { return_t ret = errorcode_t::success; ret = set(key.c_str(), value.c_str(), mode); return ret; @@ -77,7 +77,7 @@ return_t key_value::set(std::string const& key, std::string const& value, int mo return_t key_value::update(const char* name, const char* value) { return set(name, value, key_value_mode_t::update); } -return_t key_value::update(std::string const& name, std::string const& value) { return update(name.c_str(), value.c_str()); } +return_t key_value::update(const std::string& name, const std::string& value) { return update(name.c_str(), value.c_str()); } return_t key_value::remove(const char* name) { return_t ret = errorcode_t::success; @@ -191,7 +191,7 @@ return_t key_value::query(const char* name, std::string& value) { return ret; } -return_t key_value::query(std::string const& name, std::string& value) { +return_t key_value::query(const std::string& name, std::string& value) { return_t ret = errorcode_t::success; __try2 { @@ -214,7 +214,7 @@ return_t key_value::query(std::string const& name, std::string& value) { return ret; } -std::string key_value::get(std::string const& name) { +std::string key_value::get(const std::string& name) { std::string ret_value; query(name.c_str(), ret_value); return ret_value; @@ -261,7 +261,7 @@ key_value& key_value::operator<<(key_value& rhs) { return *this; } -void key_value::foreach (std::function func, void* param) { +void key_value::foreach (std::function func, void* param) { critical_section_guard guard(_lock); key_order_map_t::iterator order_iter; for (order_iter = _order_map.begin(); order_iter != _order_map.end(); order_iter++) { diff --git a/sdk/io/basic/keyvalue.hpp b/sdk/io/basic/keyvalue.hpp index d73ef15b..a76e655e 100644 --- a/sdk/io/basic/keyvalue.hpp +++ b/sdk/io/basic/keyvalue.hpp @@ -63,7 +63,7 @@ class key_value { * set (key1, value2, key_value_mode_t::update); // update, return errorcode_t::success */ return_t set(const char* name, const char* value, int mode = key_value_mode_t::update); - return_t set(std::string const& name, std::string const& value, int mode = key_value_mode_t::update); + return_t set(const std::string& name, const std::string& value, int mode = key_value_mode_t::update); /** * @brief update * @param const char* name [in] @@ -73,7 +73,7 @@ class key_value { * set(name, value, key_value_mode_t::update); */ return_t update(const char* name, const char* value); - return_t update(std::string const& name, std::string const& value); + return_t update(const std::string& name, const std::string& value); /** * @brief remove * @param const char* name [IN] @@ -113,8 +113,8 @@ class key_value { * kv.query ("value", value); // "" */ return_t query(const char* name, std::string& value); - return_t query(std::string const& name, std::string& value); - std::string get(std::string const& name); + return_t query(const std::string& name, std::string& value); + std::string get(const std::string& name); /** * @brief copy @@ -141,10 +141,10 @@ class key_value { /** * @brief foreach - * @param std::function func [in] + * @param std::function func [in] * @param void* param [inopt] */ - void foreach (std::function func, void* param = nullptr); + void foreach (std::function func, void* param = nullptr); /** * @brief operator << diff --git a/sdk/io/basic/payload.cpp b/sdk/io/basic/payload.cpp index d8ddad6f..50a81143 100644 --- a/sdk/io/basic/payload.cpp +++ b/sdk/io/basic/payload.cpp @@ -58,7 +58,7 @@ payload_member::payload_member(uint128 value, bool change_endian, const char* na get_variant().set_uint128(value); } -payload_member::payload_member(binary_t const& value, const char* name, const char* group) : _change_endian(false), _member_value_of(nullptr), _reserve(0) { +payload_member::payload_member(const binary_t& value, const char* name, const char* group) : _change_endian(false), _member_value_of(nullptr), _reserve(0) { set_name(name).set_group(group); get_variant().set_binary_new(value); } @@ -241,19 +241,19 @@ payload& payload::operator<<(payload_member* member) { return *this; } -payload& payload::set_group(std::string const& name, bool optional) { +payload& payload::set_group(const std::string& name, bool optional) { _option[name] = optional; return *this; } -bool payload::get_group_condition(std::string const& name) { +bool payload::get_group_condition(const std::string& name) { bool ret = true; maphint hint(_option); hint.find(name, &ret); return ret; } -payload& payload::set_reference_value(std::string const& name, std::string const& ref) { +payload& payload::set_reference_value(const std::string& name, const std::string& ref) { size_t space = 0; if (name.size() && ref.size()) { payload_member* member_ref = nullptr; @@ -281,7 +281,7 @@ return_t payload::dump(binary_t& bin) { return ret; } -return_t payload::read(binary_t const& bin) { return read((byte_t*)&bin[0], bin.size()); } +return_t payload::read(const binary_t& bin) { return read((byte_t*)&bin[0], bin.size()); } return_t payload::read(byte_t* base, size_t size) { return_t ret = errorcode_t::success; @@ -380,7 +380,7 @@ payload& payload::for_each(std::function func) { return *this; } -payload_member* payload::select(std::string const& name) { +payload_member* payload::select(const std::string& name) { payload_member* item = nullptr; maphint hint(_members_map); hint.find(name, &item); diff --git a/sdk/io/basic/payload.hpp b/sdk/io/basic/payload.hpp index 4867bf30..bd7f846f 100644 --- a/sdk/io/basic/payload.hpp +++ b/sdk/io/basic/payload.hpp @@ -71,7 +71,7 @@ class payload_member { payload_member(uint32 value, bool change_endian, const char* name = nullptr, const char* group = nullptr); payload_member(uint64 value, bool change_endian, const char* name = nullptr, const char* group = nullptr); payload_member(uint128 value, bool change_endian, const char* name = nullptr, const char* group = nullptr); - payload_member(binary_t const& value, const char* name = nullptr, const char* group = nullptr); + payload_member(const binary_t& value, const char* name = nullptr, const char* group = nullptr); bool get_change_endian(); std::string get_name() const; @@ -109,16 +109,16 @@ class payload { payload& operator<<(payload_member* member); - payload& set_group(std::string const& name, bool optional); - bool get_group_condition(std::string const& name); - payload& set_reference_value(std::string const& name, std::string const& ref); + payload& set_group(const std::string& name, bool optional); + bool get_group_condition(const std::string& name); + payload& set_reference_value(const std::string& name, const std::string& ref); return_t dump(binary_t& bin); - return_t read(binary_t const& bin); + return_t read(const binary_t& bin); return_t read(byte_t* p, size_t size); payload& for_each(std::function func); - payload_member* select(std::string const& name); + payload_member* select(const std::string& name); /** * @brief size diff --git a/sdk/io/basic/zlib.cpp b/sdk/io/basic/zlib.cpp index 6d8de90a..2a9c82b3 100644 --- a/sdk/io/basic/zlib.cpp +++ b/sdk/io/basic/zlib.cpp @@ -25,11 +25,11 @@ namespace hotplace { namespace io { -return_t zlib_deflate(zlib_windowbits_t windowbits, binary_t const& input, binary_t& output) { +return_t zlib_deflate(zlib_windowbits_t windowbits, const binary_t& input, binary_t& output) { return zlib_deflate(windowbits, &input[0], input.size(), output); } -return_t zlib_inflate(zlib_windowbits_t windowbits, binary_t const& input, binary_t& output) { +return_t zlib_inflate(zlib_windowbits_t windowbits, const binary_t& input, binary_t& output) { return zlib_inflate(windowbits, &input[0], input.size(), output); } @@ -153,11 +153,11 @@ return_t zlib_inflate(zlib_windowbits_t windowbits, byte_t const* input, size_t return dwRet; } -return_t zlib_deflate(zlib_windowbits_t windowbits, binary_t const& input, stream_t* output) { +return_t zlib_deflate(zlib_windowbits_t windowbits, const binary_t& input, stream_t* output) { return zlib_deflate(windowbits, &input[0], input.size(), output); } -return_t zlib_inflate(zlib_windowbits_t windowbits, binary_t const& input, stream_t* output) { +return_t zlib_inflate(zlib_windowbits_t windowbits, const binary_t& input, stream_t* output) { return zlib_inflate(windowbits, &input[0], input.size(), output); } diff --git a/sdk/io/basic/zlib.hpp b/sdk/io/basic/zlib.hpp index d2044fb7..3c320b97 100644 --- a/sdk/io/basic/zlib.hpp +++ b/sdk/io/basic/zlib.hpp @@ -23,14 +23,14 @@ enum zlib_windowbits_t { windowbits_gzip = 2, /* RFC1952 : GZIP file format specification version 4.3, using windowBits MAX_WBITS + 16(31) */ }; -return_t zlib_deflate(zlib_windowbits_t windowbits, binary_t const& input, binary_t& output); -return_t zlib_inflate(zlib_windowbits_t windowbits, binary_t const& input, binary_t& output); +return_t zlib_deflate(zlib_windowbits_t windowbits, const binary_t& input, binary_t& output); +return_t zlib_inflate(zlib_windowbits_t windowbits, const binary_t& input, binary_t& output); return_t zlib_deflate(zlib_windowbits_t windowbits, byte_t const* input, size_t size, binary_t& output); return_t zlib_inflate(zlib_windowbits_t windowbits, byte_t const* input, size_t size, binary_t& output); return_t zlib_deflate(zlib_windowbits_t windowbits, stream_t const* input, binary_t& output); return_t zlib_inflate(zlib_windowbits_t windowbits, stream_t const* input, binary_t& output); -return_t zlib_deflate(zlib_windowbits_t windowbits, binary_t const& input, stream_t* output); -return_t zlib_inflate(zlib_windowbits_t windowbits, binary_t const& input, stream_t* output); +return_t zlib_deflate(zlib_windowbits_t windowbits, const binary_t& input, stream_t* output); +return_t zlib_inflate(zlib_windowbits_t windowbits, const binary_t& input, stream_t* output); return_t zlib_deflate(zlib_windowbits_t windowbits, byte_t const* input, size_t size, stream_t* output); return_t zlib_inflate(zlib_windowbits_t windowbits, byte_t const* input, size_t size, stream_t* output); return_t zlib_deflate(zlib_windowbits_t windowbits, stream_t const* input, stream_t* output); diff --git a/sdk/io/cbor/cbor_data.cpp b/sdk/io/cbor/cbor_data.cpp index e3f46a86..de16b93d 100644 --- a/sdk/io/cbor/cbor_data.cpp +++ b/sdk/io/cbor/cbor_data.cpp @@ -35,15 +35,15 @@ cbor_data::cbor_data(int128 value) : cbor_object(cbor_type_t::cbor_type_data) { cbor_data::cbor_data(const byte_t* bstr, size_t size) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_bstr_new(bstr, size); } -cbor_data::cbor_data(binary_t const& data) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_binary_new(data); } +cbor_data::cbor_data(const binary_t& data) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_binary_new(data); } cbor_data::cbor_data(const char* tstr) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_str_new(tstr); } cbor_data::cbor_data(const char* tstr, size_t length) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_strn_new(tstr, length); } -cbor_data::cbor_data(std::string const& data) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_str_new(data.c_str()); } +cbor_data::cbor_data(const std::string& data) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_str_new(data.c_str()); } -cbor_data::cbor_data(fp16_t const& value) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_fp16(value.storage); } +cbor_data::cbor_data(const fp16_t& value) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_fp16(value.storage); } cbor_data::cbor_data(float value) : cbor_object(cbor_type_t::cbor_type_data) { _vt.set_float(value); } diff --git a/sdk/io/cbor/cbor_data.hpp b/sdk/io/cbor/cbor_data.hpp index 4ab25d31..6535277d 100644 --- a/sdk/io/cbor/cbor_data.hpp +++ b/sdk/io/cbor/cbor_data.hpp @@ -49,11 +49,11 @@ class cbor_data : public cbor_object { cbor_data(int128 value); #endif cbor_data(const byte_t* bstr, size_t size); - cbor_data(binary_t const& bin); + cbor_data(const binary_t& bin); cbor_data(const char* tstr); cbor_data(const char* tstr, size_t length); - cbor_data(std::string const& bin); - cbor_data(fp16_t const& value); + cbor_data(const std::string& bin); + cbor_data(const fp16_t& value); cbor_data(float value); cbor_data(double value); cbor_data(variant_t& vt); diff --git a/sdk/io/cbor/cbor_encode.cpp b/sdk/io/cbor/cbor_encode.cpp index b6003892..efe71e18 100644 --- a/sdk/io/cbor/cbor_encode.cpp +++ b/sdk/io/cbor/cbor_encode.cpp @@ -528,7 +528,7 @@ return_t cbor_encode::encode(binary_t& bin, byte_t const* value, size_t size) { return ret; } -return_t cbor_encode::encode(binary_t& bin, binary_t const& value) { return encode(bin, &value[0], value.size()); } +return_t cbor_encode::encode(binary_t& bin, const binary_t& value) { return encode(bin, &value[0], value.size()); } return_t cbor_encode::encode(binary_t& bin, char* value) { return_t ret = errorcode_t::success; diff --git a/sdk/io/cbor/cbor_encode.hpp b/sdk/io/cbor/cbor_encode.hpp index f7c62b92..3a8585dc 100644 --- a/sdk/io/cbor/cbor_encode.hpp +++ b/sdk/io/cbor/cbor_encode.hpp @@ -106,7 +106,7 @@ class cbor_encode { return_t encode(binary_t& bin, float value); return_t encode(binary_t& bin, double value); return_t encode(binary_t& bin, byte_t const* value, size_t size); - return_t encode(binary_t& bin, binary_t const& value); + return_t encode(binary_t& bin, const binary_t& value); return_t encode(binary_t& bin, char* value); return_t encode(binary_t& bin, char* value, size_t size); return_t encode(binary_t& bin, cbor_major_t type, cbor_control_t control, cbor_object* object); diff --git a/sdk/io/cbor/cbor_reader.cpp b/sdk/io/cbor/cbor_reader.cpp index d70e8d91..7af8b574 100644 --- a/sdk/io/cbor/cbor_reader.cpp +++ b/sdk/io/cbor/cbor_reader.cpp @@ -223,7 +223,7 @@ return_t cbor_reader::parse(cbor_reader_context_t* handle, const byte_t* data, s return ret; } -return_t cbor_reader::parse(cbor_reader_context_t* handle, binary_t const& expression) { +return_t cbor_reader::parse(cbor_reader_context_t* handle, const binary_t& expression) { return_t ret = errorcode_t::success; __try2 { @@ -578,7 +578,7 @@ return_t cbor_reader::cbor_foreach(cbor_reader_context_t* handle, void (*functio return cbor_foreach_t(handle, function, param); } -return_t cbor_parse(cbor_object** object, binary_t const& cbor) { +return_t cbor_parse(cbor_object** object, const binary_t& cbor) { return_t ret = errorcode_t::success; cbor_reader reader; cbor_reader_context_t* reader_context = nullptr; diff --git a/sdk/io/cbor/cbor_reader.hpp b/sdk/io/cbor/cbor_reader.hpp index 39963eef..91b9fe87 100644 --- a/sdk/io/cbor/cbor_reader.hpp +++ b/sdk/io/cbor/cbor_reader.hpp @@ -68,7 +68,7 @@ class cbor_reader { /* * @brief parse * @param cbor_reader_context_t* handle [in] - * @param byte_t* const& data [in] + * @param const byte_t* data [in] * @param size_t size [in] * @return error code (see error.hpp) */ @@ -79,7 +79,7 @@ class cbor_reader { * @param const char* expr [in] * @return error code (see error.hpp) */ - return_t parse(cbor_reader_context_t* handle, binary_t const& bin); + return_t parse(cbor_reader_context_t* handle, const binary_t& bin); /* * @brief publish @@ -129,14 +129,14 @@ class cbor_reader { /** * @brief parse * @param cbor_object** object [out] - * @param binary_t const& cbor [in] + * @param const binary_t& cbor [in] * @return error code (see error.hpp) * no_data if cbor is empty * @remarks * 1. if(0 == cbor.size()) return * 2. if(errorcode_t::no_data == cbor_parse()) return */ -return_t cbor_parse(cbor_object** object, binary_t const& cbor); +return_t cbor_parse(cbor_object** object, const binary_t& cbor); } // namespace io } // namespace hotplace diff --git a/sdk/io/stream/ansi_string.cpp b/sdk/io/stream/ansi_string.cpp index 438e5dbf..6c07aa2c 100644 --- a/sdk/io/stream/ansi_string.cpp +++ b/sdk/io/stream/ansi_string.cpp @@ -262,7 +262,7 @@ ansi_string& ansi_string::operator=(double buf) { return *this; } -ansi_string& ansi_string::operator=(ansi_string& buf) { +ansi_string& ansi_string::operator=(const ansi_string& buf) { clear(); write(buf.data(), buf.size()); return *this; @@ -319,7 +319,7 @@ ansi_string& ansi_string::operator+=(double buf) { return *this; } -ansi_string& ansi_string::operator+=(ansi_string& buf) { +ansi_string& ansi_string::operator+=(const ansi_string& buf) { write(buf.data(), buf.size()); return *this; } @@ -375,7 +375,7 @@ ansi_string& ansi_string::operator<<(double buf) { return *this; } -ansi_string& ansi_string::operator<<(ansi_string& buf) { +ansi_string& ansi_string::operator<<(const ansi_string& buf) { write(buf.data(), buf.size()); return *this; } @@ -399,9 +399,9 @@ ansi_string& ansi_string::operator<<(uint128 buf) { #endif -int ansi_string::compare(ansi_string& rhs) { return strcmp(c_str(), rhs.c_str()); } +int ansi_string::compare(const ansi_string& rhs) { return strcmp(c_str(), rhs.c_str()); } -int ansi_string::compare(ansi_string& lhs, ansi_string& rhs) { return strcmp(lhs.c_str(), rhs.c_str()); } +int ansi_string::compare(const ansi_string& lhs, const ansi_string& rhs) { return strcmp(lhs.c_str(), rhs.c_str()); } bool ansi_string::operator<(const ansi_string& rhs) const { return 0 > strcmp(c_str(), rhs.c_str()); } @@ -453,5 +453,20 @@ bool ansi_string::operator!=(const char* input) { return ret; } +std::string& operator+=(std::string& lhs, const ansi_string& rhs) { + lhs += rhs.c_str(); + return lhs; +} + +std::string& operator<<(std::string& lhs, const ansi_string& rhs) { + lhs += rhs.c_str(); + return lhs; +} + +std::ostream& operator<<(std::ostream& lhs, const ansi_string& rhs) { + lhs << rhs.c_str(); + return lhs; +} + } // namespace io } // namespace hotplace diff --git a/sdk/io/stream/dump_memory.cpp b/sdk/io/stream/dump_memory.cpp index 0cd74558..0930b392 100644 --- a/sdk/io/stream/dump_memory.cpp +++ b/sdk/io/stream/dump_memory.cpp @@ -22,15 +22,15 @@ return_t dump_memory(const char* data, stream_t* stream_object, unsigned hex_par return dump_memory((byte_t*)data, size, stream_object, hex_part, indent, rebase, flags); } -return_t dump_memory(std::string const& data, stream_t* stream_object, unsigned hex_part, unsigned indent, size_t rebase, int flags) { +return_t dump_memory(const std::string& data, stream_t* stream_object, unsigned hex_part, unsigned indent, size_t rebase, int flags) { return dump_memory((byte_t*)data.c_str(), data.size(), stream_object, hex_part, indent, rebase, flags); } -return_t dump_memory(binary_t const& data, stream_t* stream_object, unsigned hex_part, unsigned indent, size_t rebase, int flags) { +return_t dump_memory(const binary_t& data, stream_t* stream_object, unsigned hex_part, unsigned indent, size_t rebase, int flags) { return dump_memory(&data[0], data.size(), stream_object, hex_part, indent, rebase, flags); } -return_t dump_memory(basic_stream const& data, stream_t* stream_object, unsigned hex_part, unsigned indent, size_t rebase, int flags) { +return_t dump_memory(const basic_stream& data, stream_t* stream_object, unsigned hex_part, unsigned indent, size_t rebase, int flags) { return dump_memory(data.data(), data.size(), stream_object, hex_part, indent, rebase, flags); } diff --git a/sdk/io/stream/printf.cpp b/sdk/io/stream/printf.cpp index 2d59a575..279a2ae4 100644 --- a/sdk/io/stream/printf.cpp +++ b/sdk/io/stream/printf.cpp @@ -135,7 +135,7 @@ return_t sprintf(stream_t* stream, const char* fmt, valist va) { return ret; } -return_t vtprintf(stream_t* stream, variant_t const& vt, vtprintf_style_t style) { +return_t vtprintf(stream_t* stream, const variant_t& vt, vtprintf_style_t style) { return_t ret = errorcode_t::success; __try2 { diff --git a/sdk/io/stream/stream.hpp b/sdk/io/stream/stream.hpp index edefb805..46934236 100644 --- a/sdk/io/stream/stream.hpp +++ b/sdk/io/stream/stream.hpp @@ -132,22 +132,22 @@ return_t vprintf(stream_t* stream, const char* fmt, Args... args) { * vtprintf (&bs, v); * variant_free (v); * - * std::cout << bs.c_str () << std::endl; + * std::cout << bs << std::endl; */ enum vtprintf_style_t { vtprintf_style_normal = 0, vtprintf_style_cbor = 1, }; -return_t vtprintf(stream_t* stream, variant_t const& vt, vtprintf_style_t style = vtprintf_style_normal); +return_t vtprintf(stream_t* stream, const variant_t& vt, vtprintf_style_t style = vtprintf_style_normal); // // part - dump // return_t dump_memory(const char* data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); -return_t dump_memory(std::string const& data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); -return_t dump_memory(binary_t const& data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); -return_t dump_memory(basic_stream const& data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); +return_t dump_memory(const std::string& data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); +return_t dump_memory(const binary_t& data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); +return_t dump_memory(const basic_stream& data, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); return_t dump_memory(bufferio_context_t* context, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); return_t dump_memory(variant_t vt, stream_t* stream_object, unsigned hex_part = 16, unsigned indent = 0, size_t rebase = 0x0, int flags = 0); diff --git a/sdk/io/stream/string.hpp b/sdk/io/stream/string.hpp index ee50c4e5..0a90b609 100644 --- a/sdk/io/stream/string.hpp +++ b/sdk/io/stream/string.hpp @@ -11,6 +11,7 @@ #ifndef __HOTPLACE_SDK_IO_STREAM_STRING__ #define __HOTPLACE_SDK_IO_STREAM_STRING__ +#include #include #include @@ -89,7 +90,7 @@ class ansi_string : public stream_t { ansi_string& operator=(uint64 buf); ansi_string& operator=(float buf); ansi_string& operator=(double buf); - ansi_string& operator=(ansi_string& buf); + ansi_string& operator=(const ansi_string& buf); ansi_string& operator+=(const char* buf); #if defined _WIN32 || defined _WIN64 @@ -102,7 +103,7 @@ class ansi_string : public stream_t { ansi_string& operator+=(uint64 buf); ansi_string& operator+=(float buf); ansi_string& operator+=(double buf); - ansi_string& operator+=(ansi_string& buf); + ansi_string& operator+=(const ansi_string& buf); ansi_string& operator<<(const char* buf); #if defined _WIN32 || defined _WIN64 @@ -115,7 +116,7 @@ class ansi_string : public stream_t { ansi_string& operator<<(uint64 buf); ansi_string& operator<<(float buf); ansi_string& operator<<(double buf); - ansi_string& operator<<(ansi_string& buf); + ansi_string& operator<<(const ansi_string& buf); #if defined __SIZEOF_INT128__ ansi_string& operator=(uint128 buf); @@ -123,8 +124,8 @@ class ansi_string : public stream_t { ansi_string& operator<<(uint128 buf); #endif - int compare(ansi_string& buf); - static int compare(ansi_string& lhs, ansi_string& rhs); + int compare(const ansi_string& buf); + static int compare(const ansi_string& lhs, const ansi_string& rhs); bool operator<(const ansi_string& buf) const; bool operator>(const ansi_string& buf) const; @@ -135,6 +136,10 @@ class ansi_string : public stream_t { bool operator==(const char* input); bool operator!=(const char* input); + friend std::string& operator+=(std::string& lhs, const ansi_string& rhs); + friend std::string& operator<<(std::string& lhs, const ansi_string& rhs); + friend std::ostream& operator<<(std::ostream& lhs, const ansi_string& rhs); + protected: bufferio _bio; bufferio_context_t* _handle; @@ -212,7 +217,7 @@ class wide_string : public stream_t { wide_string& operator=(uint64 buf); wide_string& operator=(float buf); wide_string& operator=(double buf); - wide_string& operator=(wide_string& buf); + wide_string& operator=(const wide_string& buf); wide_string& operator+=(const char* buf); wide_string& operator+=(const wchar_t* buf); @@ -223,7 +228,7 @@ class wide_string : public stream_t { wide_string& operator+=(uint64 buf); wide_string& operator+=(float buf); wide_string& operator+=(double buf); - wide_string& operator+=(wide_string& buf); + wide_string& operator+=(const wide_string& buf); wide_string& operator<<(const char* buf); wide_string& operator<<(const wchar_t* buf); @@ -234,7 +239,7 @@ class wide_string : public stream_t { wide_string& operator<<(uint64 buf); wide_string& operator<<(float buf); wide_string& operator<<(double buf); - wide_string& operator<<(wide_string& buf); + wide_string& operator<<(const wide_string& buf); #if defined __SIZEOF_INT128__ wide_string& operator=(uint128 buf); @@ -242,8 +247,8 @@ class wide_string : public stream_t { wide_string& operator<<(uint128 buf); #endif - int compare(wide_string& buf); - static int compare(wide_string& lhs, wide_string& rhs); + int compare(const wide_string& buf); + static int compare(const wide_string& lhs, const wide_string& rhs); bool operator<(const wide_string& buf) const; bool operator>(const wide_string& buf) const; @@ -254,6 +259,10 @@ class wide_string : public stream_t { bool operator==(const wchar_t* input); bool operator!=(const wchar_t* input); + friend std::wstring& operator+=(std::wstring& lhs, const wide_string& rhs); + friend std::wstring& operator<<(std::wstring& lhs, const wide_string& rhs); + friend std::ostream& operator<<(std::ostream& lhs, const wide_string& rhs); + protected: bufferio _bio; bufferio_context_t* _handle; diff --git a/sdk/io/stream/unicode/wide_string.cpp b/sdk/io/stream/unicode/wide_string.cpp index 70534c66..95f83d58 100644 --- a/sdk/io/stream/unicode/wide_string.cpp +++ b/sdk/io/stream/unicode/wide_string.cpp @@ -9,6 +9,7 @@ */ #include +#include #include #include @@ -270,7 +271,7 @@ wide_string& wide_string::operator=(double buf) { return *this; } -wide_string& wide_string::operator=(wide_string& buf) { +wide_string& wide_string::operator=(const wide_string& buf) { clear(); write(buf.data(), buf.size()); return *this; @@ -332,7 +333,7 @@ wide_string& wide_string::operator+=(double buf) { return *this; } -wide_string& wide_string::operator+=(wide_string& buf) { +wide_string& wide_string::operator+=(const wide_string& buf) { write(buf.data(), buf.size()); return *this; } @@ -393,14 +394,14 @@ wide_string& wide_string::operator<<(double buf) { return *this; } -wide_string& wide_string::operator<<(wide_string& buf) { +wide_string& wide_string::operator<<(const wide_string& buf) { write(buf.data(), buf.size()); return *this; } -int wide_string::compare(wide_string& rhs) { return wcscmp(c_str(), rhs.c_str()); } +int wide_string::compare(const wide_string& rhs) { return wcscmp(c_str(), rhs.c_str()); } -int wide_string::compare(wide_string& lhs, wide_string& rhs) { return wcscmp(lhs.c_str(), rhs.c_str()); } +int wide_string::compare(const wide_string& lhs, const wide_string& rhs) { return wcscmp(lhs.c_str(), rhs.c_str()); } bool wide_string::operator<(const wide_string& rhs) const { return 0 > wcscmp(c_str(), rhs.c_str()); } @@ -452,5 +453,22 @@ bool wide_string::operator!=(const wchar_t* input) { return ret; } +std::wstring& operator+=(std::wstring& lhs, const wide_string& rhs) { + lhs += rhs.c_str(); + return lhs; +} + +std::wstring& operator<<(std::wstring& lhs, const wide_string& rhs) { + lhs += rhs.c_str(); + return lhs; +} + +std::ostream& operator<<(std::ostream& lhs, const wide_string& rhs) { + basic_stream bs; + W2A(&bs, rhs.c_str()); + lhs << bs.c_str(); + return lhs; +} + } // namespace io } // namespace hotplace diff --git a/sdk/io/string/regex.cpp b/sdk/io/string/regex.cpp index 770ba56e..e41640ff 100644 --- a/sdk/io/string/regex.cpp +++ b/sdk/io/string/regex.cpp @@ -19,7 +19,7 @@ namespace hotplace { namespace io { -void regex_token(std::string const& input, std::string const& expr, size_t& pos, std::list& tokens) { +void regex_token(const std::string& input, const std::string& expr, size_t& pos, std::list& tokens) { tokens.clear(); #if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)) diff --git a/sdk/io/string/string.hpp b/sdk/io/string/string.hpp index 7790ded0..36c6db92 100644 --- a/sdk/io/string/string.hpp +++ b/sdk/io/string/string.hpp @@ -48,9 +48,9 @@ return_t W2A(std::string& target, const wchar_t* source, uint32 codepage = 0); * gettoken (data, token, 1, value); // "item1" * _test_case.assert (value == "item1", __FUNCTION__, "gettoken"); */ -bool gettoken(std::string const& source, std::string const& token, size_t index, std::string& value); +bool gettoken(const std::string& source, const std::string& token, size_t index, std::string& value); #if defined _WIN32 || defined _WIN64 -bool gettoken(std::wstring const& source, std::wstring const& token, size_t index, std::wstring& value); +bool gettoken(const std::wstring& source, const std::wstring& token, size_t index, std::wstring& value); #endif /** @@ -70,9 +70,9 @@ bool gettoken(std::wstring const& source, std::wstring const& token, size_t inde enum tokenize_mode_t { token_quoted = 1, }; -std::string tokenize(std::string const& source, std::string const& tokens, size_t& pos, int mode = 0); +std::string tokenize(const std::string& source, const std::string& tokens, size_t& pos, int mode = 0); #if defined _WIN32 || defined _WIN64 -std::wstring tokenize(std::wstring const& source, std::wstring const& tokens, size_t& pos, int mode = 0); +std::wstring tokenize(const std::wstring& source, const std::wstring& tokens, size_t& pos, int mode = 0); #endif /** @@ -161,13 +161,13 @@ return_t scan(const wchar_t* stream, size_t sizestream, size_t startpos, size_t* /** * @brief regular expression - * @param std::string const& input [in] - * @param std::string const& expr [in] + * @param const std::string& input [in] + * @param const std::string& expr [in] * @param size_t& pos [out] * @param std::list& tokens [out] * @sa split_url */ -void regex_token(std::string const& input, std::string const& expr, size_t& pos, std::list& tokens); +void regex_token(const std::string& input, const std::string& expr, size_t& pos, std::list& tokens); /** * @brief escape_url @@ -183,7 +183,7 @@ return_t escape_url(const char* url, stream_t* s, uint32 flags = 0); * @example * basic_stream bs; * unescape("https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb", &bs); - * std::cout << bs.c_str() << std::endl; // https://client.example.com/cb + * std::cout << bs << std::endl; // https://client.example.com/cb */ return_t unescape_url(const char* url, stream_t* s); diff --git a/sdk/io/string/string_charset.cpp b/sdk/io/string/string_charset.cpp index 8792cd4a..c7b5e803 100644 --- a/sdk/io/string/string_charset.cpp +++ b/sdk/io/string/string_charset.cpp @@ -18,9 +18,9 @@ namespace hotplace { namespace io { #if defined _MBCS || defined MBCS -std::string tokenize(std::string const& source, std::string const& tokens, size_t& pos, int mode) +std::string tokenize(const std::string& source, const std::string& tokens, size_t& pos, int mode) #elif defined _UNICODE || defined UNICODE -std::wstring tokenize(std::wstring const& source, std::wstring const& tokens, size_t& pos, int mode) +std::wstring tokenize(const std::wstring& source, const std::wstring& tokens, size_t& pos, int mode) #endif { #if defined _MBCS || defined MBCS @@ -87,9 +87,9 @@ std::wstring tokenize(std::wstring const& source, std::wstring const& tokens, si } #if defined _MBCS || defined MBCS -bool gettoken(std::string const& source, std::string const& token, size_t index, std::string& value) +bool gettoken(const std::string& source, const std::string& token, size_t index, std::string& value) #elif defined _UNICODE || defined UNICODE -bool gettoken(std::wstring const& source, std::wstring const& token, size_t index, std::wstring& value) +bool gettoken(const std::wstring& source, const std::wstring& token, size_t index, std::wstring& value) #endif { bool ret = false; diff --git a/sdk/io/system/types.cpp b/sdk/io/system/types.cpp index fda7fd5b..0387b7f5 100644 --- a/sdk/io/system/types.cpp +++ b/sdk/io/system/types.cpp @@ -18,9 +18,9 @@ namespace io { #if defined __SIZEOF_INT128__ -int128 atoi128(std::string const& in) { return t_atoi(in); } +int128 atoi128(const std::string& in) { return t_atoi(in); } -uint128 atou128(std::string const& in) { return t_atoi(in); } +uint128 atou128(const std::string& in) { return t_atoi(in); } #endif diff --git a/sdk/io/system/types.hpp b/sdk/io/system/types.hpp index 058d14a0..3a52afd5 100644 --- a/sdk/io/system/types.hpp +++ b/sdk/io/system/types.hpp @@ -22,7 +22,7 @@ namespace io { * atoi (int128) */ template -TYPE t_atoi(std::string const& in) { +TYPE t_atoi(const std::string& in) { return_t ret = errorcode_t::success; TYPE res = 0; @@ -84,8 +84,8 @@ T t_htoi(const char* hex) { return value; } -int128 atoi128(std::string const& in); -uint128 atou128(std::string const& in); +int128 atoi128(const std::string& in); +uint128 atou128(const std::string& in); #endif diff --git a/sdk/net/http/auth/basic_authentication_provider.cpp b/sdk/net/http/auth/basic_authentication_provider.cpp index e84fd4f0..57832cf9 100644 --- a/sdk/net/http/auth/basic_authentication_provider.cpp +++ b/sdk/net/http/auth/basic_authentication_provider.cpp @@ -19,7 +19,7 @@ using namespace crypto; using namespace io; namespace net { -basic_authentication_provider::basic_authentication_provider(std::string const& realm) : http_authenticate_provider(realm) {} +basic_authentication_provider::basic_authentication_provider(const std::string& realm) : http_authenticate_provider(realm) {} basic_authentication_provider::~basic_authentication_provider() {} diff --git a/sdk/net/http/auth/basic_authentication_provider.hpp b/sdk/net/http/auth/basic_authentication_provider.hpp index 8b224c3b..35fab778 100644 --- a/sdk/net/http/auth/basic_authentication_provider.hpp +++ b/sdk/net/http/auth/basic_authentication_provider.hpp @@ -37,7 +37,7 @@ namespace net { */ class basic_authentication_provider : public http_authenticate_provider { public: - basic_authentication_provider(std::string const& realm); + basic_authentication_provider(const std::string& realm); virtual ~basic_authentication_provider(); /** diff --git a/sdk/net/http/auth/basic_credentials.cpp b/sdk/net/http/auth/basic_credentials.cpp index ccdfe448..2651ea25 100644 --- a/sdk/net/http/auth/basic_credentials.cpp +++ b/sdk/net/http/auth/basic_credentials.cpp @@ -22,7 +22,7 @@ namespace net { basic_credentials::basic_credentials() {} -basic_credentials& basic_credentials::add(std::string const& username, std::string const& password) { +basic_credentials& basic_credentials::add(const std::string& username, const std::string& password) { basic_stream bs; bs << username << ":" << password; @@ -30,13 +30,13 @@ basic_credentials& basic_credentials::add(std::string const& username, std::stri return add(challenge); } -basic_credentials& basic_credentials::add(std::string const& challenge) { +basic_credentials& basic_credentials::add(const std::string& challenge) { critical_section_guard guard(_lock); _basic_credential.insert(challenge); return *this; } -bool basic_credentials::verify(http_authenticate_provider* provider, std::string const& credential) { +bool basic_credentials::verify(http_authenticate_provider* provider, const std::string& credential) { bool ret = false; critical_section_guard guard(_lock); diff --git a/sdk/net/http/auth/basic_credentials.hpp b/sdk/net/http/auth/basic_credentials.hpp index 693429b9..decfb537 100644 --- a/sdk/net/http/auth/basic_credentials.hpp +++ b/sdk/net/http/auth/basic_credentials.hpp @@ -25,9 +25,9 @@ class basic_credentials { public: basic_credentials(); - basic_credentials& add(std::string const& username, std::string const& password); - basic_credentials& add(std::string const& challenge); - bool verify(http_authenticate_provider* provider, std::string const& credential); + basic_credentials& add(const std::string& username, const std::string& password); + basic_credentials& add(const std::string& challenge); + bool verify(http_authenticate_provider* provider, const std::string& credential); private: critical_section _lock; diff --git a/sdk/net/http/auth/bearer_authentication_provider.cpp b/sdk/net/http/auth/bearer_authentication_provider.cpp index dd0f5288..c0795618 100644 --- a/sdk/net/http/auth/bearer_authentication_provider.cpp +++ b/sdk/net/http/auth/bearer_authentication_provider.cpp @@ -19,7 +19,7 @@ using namespace crypto; using namespace io; namespace net { -bearer_authentication_provider::bearer_authentication_provider(std::string const& realm) : http_authenticate_provider(realm) {} +bearer_authentication_provider::bearer_authentication_provider(const std::string& realm) : http_authenticate_provider(realm) {} bearer_authentication_provider::~bearer_authentication_provider() {} diff --git a/sdk/net/http/auth/bearer_authentication_provider.hpp b/sdk/net/http/auth/bearer_authentication_provider.hpp index 6f6bea3c..676b1ea4 100644 --- a/sdk/net/http/auth/bearer_authentication_provider.hpp +++ b/sdk/net/http/auth/bearer_authentication_provider.hpp @@ -28,7 +28,7 @@ namespace net { class bearer_authentication_provider : public http_authenticate_provider { public: - bearer_authentication_provider(std::string const& realm); + bearer_authentication_provider(const std::string& realm); virtual ~bearer_authentication_provider(); /** diff --git a/sdk/net/http/auth/bearer_credentials.cpp b/sdk/net/http/auth/bearer_credentials.cpp index 30b167db..4efcc974 100644 --- a/sdk/net/http/auth/bearer_credentials.cpp +++ b/sdk/net/http/auth/bearer_credentials.cpp @@ -20,13 +20,13 @@ namespace net { bearer_credentials::bearer_credentials() {} -bearer_credentials& bearer_credentials::add(std::string const& client_id, std::string const& access_token) { +bearer_credentials& bearer_credentials::add(const std::string& client_id, const std::string& access_token) { critical_section_guard guard(_lock); _bearer_credential.insert(std::make_pair(access_token, client_id)); return *this; } -bool bearer_credentials::verify(http_authenticate_provider* provider, std::string const& token) { +bool bearer_credentials::verify(http_authenticate_provider* provider, const std::string& token) { bool ret = false; critical_section_guard guard(_lock); diff --git a/sdk/net/http/auth/bearer_credentials.hpp b/sdk/net/http/auth/bearer_credentials.hpp index ea84a636..fee27cef 100644 --- a/sdk/net/http/auth/bearer_credentials.hpp +++ b/sdk/net/http/auth/bearer_credentials.hpp @@ -25,8 +25,8 @@ class bearer_credentials { public: bearer_credentials(); - bearer_credentials& add(std::string const& client_id, std::string const& access_token); - bool verify(http_authenticate_provider* provider, std::string const& token); + bearer_credentials& add(const std::string& client_id, const std::string& access_token); + bool verify(http_authenticate_provider* provider, const std::string& token); private: critical_section _lock; diff --git a/sdk/net/http/auth/custom_credentials.cpp b/sdk/net/http/auth/custom_credentials.cpp index fdd8766d..72ade450 100644 --- a/sdk/net/http/auth/custom_credentials.cpp +++ b/sdk/net/http/auth/custom_credentials.cpp @@ -20,7 +20,7 @@ namespace net { custom_credentials::custom_credentials() {} -custom_credentials& custom_credentials::add(std::string const& username, std::string const& password) { +custom_credentials& custom_credentials::add(const std::string& username, const std::string& password) { critical_section_guard guard(_lock); openssl_digest dgst; std::string password_hash; @@ -29,7 +29,7 @@ custom_credentials& custom_credentials::add(std::string const& username, std::st return *this; } -bool custom_credentials::verify(http_authenticate_provider* provider, std::string const& username, std::string const& password) { +bool custom_credentials::verify(http_authenticate_provider* provider, const std::string& username, const std::string& password) { bool ret = false; critical_section_guard guard(_lock); openssl_digest dgst; diff --git a/sdk/net/http/auth/custom_credentials.hpp b/sdk/net/http/auth/custom_credentials.hpp index 6d32eaae..f5dfaef2 100644 --- a/sdk/net/http/auth/custom_credentials.hpp +++ b/sdk/net/http/auth/custom_credentials.hpp @@ -24,8 +24,8 @@ class custom_credentials { public: custom_credentials(); - custom_credentials& add(std::string const& username, std::string const& password); - bool verify(http_authenticate_provider* provider, std::string const& username, std::string const& password); + custom_credentials& add(const std::string& username, const std::string& password); + bool verify(http_authenticate_provider* provider, const std::string& username, const std::string& password); private: critical_section _lock; diff --git a/sdk/net/http/auth/digest_access_authentication_provider.cpp b/sdk/net/http/auth/digest_access_authentication_provider.cpp index 2ca3906c..3081164c 100644 --- a/sdk/net/http/auth/digest_access_authentication_provider.cpp +++ b/sdk/net/http/auth/digest_access_authentication_provider.cpp @@ -19,17 +19,17 @@ using namespace crypto; using namespace io; namespace net { -digest_access_authentication_provider::digest_access_authentication_provider(std::string const& realm) +digest_access_authentication_provider::digest_access_authentication_provider(const std::string& realm) : http_authenticate_provider(realm), _qop("auth, auth-int"), _userhash(false) {} -digest_access_authentication_provider::digest_access_authentication_provider(std::string const& realm, const char* algorithm, const char* qop, bool userhash) +digest_access_authentication_provider::digest_access_authentication_provider(const std::string& realm, const char* algorithm, const char* qop, bool userhash) : http_authenticate_provider(realm) { set_algorithm(algorithm); set_qop(qop); set_userhash(userhash); } -digest_access_authentication_provider::digest_access_authentication_provider(std::string const& realm, std::string const& algorithm, std::string const& qop, +digest_access_authentication_provider::digest_access_authentication_provider(const std::string& realm, const std::string& algorithm, const std::string& qop, bool userhash) : http_authenticate_provider(realm), _algorithm(algorithm), _qop(qop), _userhash(userhash) {} diff --git a/sdk/net/http/auth/digest_access_authentication_provider.hpp b/sdk/net/http/auth/digest_access_authentication_provider.hpp index 2b1e82bf..e8dcb4fe 100644 --- a/sdk/net/http/auth/digest_access_authentication_provider.hpp +++ b/sdk/net/http/auth/digest_access_authentication_provider.hpp @@ -55,9 +55,9 @@ class digest_access_authentication_provider : public http_authenticate_provider * @brief constructor * @param const char* realm [in] */ - digest_access_authentication_provider(std::string const& realm); - digest_access_authentication_provider(std::string const& realm, const char* algorithm, const char* qop, bool userhash = false); - digest_access_authentication_provider(std::string const& realm, std::string const& algorithm, std::string const& qop, bool userhash = false); + digest_access_authentication_provider(const std::string& realm); + digest_access_authentication_provider(const std::string& realm, const char* algorithm, const char* qop, bool userhash = false); + digest_access_authentication_provider(const std::string& realm, const std::string& algorithm, const std::string& qop, bool userhash = false); virtual ~digest_access_authentication_provider(); /** diff --git a/sdk/net/http/auth/digest_credentials.cpp b/sdk/net/http/auth/digest_credentials.cpp index 98bd1e44..e31ef2e4 100644 --- a/sdk/net/http/auth/digest_credentials.cpp +++ b/sdk/net/http/auth/digest_credentials.cpp @@ -22,13 +22,13 @@ namespace net { digest_credentials::digest_credentials() {} -digest_credentials& digest_credentials::add(std::string const& username, std::string const& password) { +digest_credentials& digest_credentials::add(const std::string& username, const std::string& password) { critical_section_guard guard(_lock); _digest_access_credential.insert(std::make_pair(username, password)); return *this; } -digest_credentials& digest_credentials::add(std::string const& realm, std::string const& algorithm, std::string const& username, std::string const& password) { +digest_credentials& digest_credentials::add(const std::string& realm, const std::string& algorithm, const std::string& username, const std::string& password) { rfc2617_digest dgst; dgst.add(username).add(":").add(realm).digest(algorithm); diff --git a/sdk/net/http/auth/digest_credentials.hpp b/sdk/net/http/auth/digest_credentials.hpp index 5d6d99f6..5ca06cc4 100644 --- a/sdk/net/http/auth/digest_credentials.hpp +++ b/sdk/net/http/auth/digest_credentials.hpp @@ -26,8 +26,8 @@ class digest_credentials { public: digest_credentials(); - digest_credentials& add(std::string const& userid, std::string const& password); - digest_credentials& add(std::string const& realm, std::string const& algorithm, std::string const& userid, std::string const& password); + digest_credentials& add(const std::string& userid, const std::string& password); + digest_credentials& add(const std::string& realm, const std::string& algorithm, const std::string& userid, const std::string& password); bool verify(http_authenticate_provider* provider, key_value& kv); private: diff --git a/sdk/net/http/auth/oauth2.cpp b/sdk/net/http/auth/oauth2.cpp index 55d7d590..af265f0e 100644 --- a/sdk/net/http/auth/oauth2.cpp +++ b/sdk/net/http/auth/oauth2.cpp @@ -351,7 +351,7 @@ oauth2_provider& oauth2_provider::add(oauth2_grant_provider* provider) { return *this; } -oauth2_provider& oauth2_provider::set(oauth2_provider_key_t key, std::string const& value) { +oauth2_provider& oauth2_provider::set(oauth2_provider_key_t key, const std::string& value) { _values[key] = value; return *this; } @@ -402,7 +402,7 @@ void oauth2_provider::clear() { _providers.clear(); } -return_t oauth2_provider::choose(oauth2_grant_provider_ref_map_t& object, std::string const& key, oauth2_grant_provider** provider_upref) { +return_t oauth2_provider::choose(oauth2_grant_provider_ref_map_t& object, const std::string& key, oauth2_grant_provider** provider_upref) { return_t ret = errorcode_t::success; oauth2_grant_provider* provider = nullptr; __try2 { diff --git a/sdk/net/http/auth/oauth2.hpp b/sdk/net/http/auth/oauth2.hpp index 0f07b37a..6826df7e 100644 --- a/sdk/net/http/auth/oauth2.hpp +++ b/sdk/net/http/auth/oauth2.hpp @@ -153,7 +153,7 @@ class oauth2_provider { virtual ~oauth2_provider(); oauth2_provider& add(oauth2_grant_provider* provider); - oauth2_provider& set(oauth2_provider_key_t key, std::string const& value); + oauth2_provider& set(oauth2_provider_key_t key, const std::string& value); std::string get(oauth2_provider_key_t key); oauth2_provider& set_token_endpoint_authentication(http_authenticate_provider* auth); oauth2_provider& apply(http_router& router); @@ -165,7 +165,7 @@ class oauth2_provider { typedef std::pair oauth2_grant_provider_ref_map_pib_t; void clear(); - return_t choose(oauth2_grant_provider_ref_map_t& object, std::string const& key, oauth2_grant_provider** provider_upref); + return_t choose(oauth2_grant_provider_ref_map_t& object, const std::string& key, oauth2_grant_provider** provider_upref); void authorization_handler(network_session* session, http_request* request, http_response* response, http_router* router); void token_handler(network_session* session, http_request* request, http_response* response, http_router* router); diff --git a/sdk/net/http/auth/oauth2_credentials.cpp b/sdk/net/http/auth/oauth2_credentials.cpp index 6506e529..18813edf 100644 --- a/sdk/net/http/auth/oauth2_credentials.cpp +++ b/sdk/net/http/auth/oauth2_credentials.cpp @@ -20,7 +20,7 @@ using namespace crypto; using namespace io; namespace net { -access_token_t::access_token_t(std::string const& client_id, std::string const& access_token, std::string const& refresh_token, uint16 expire) +access_token_t::access_token_t(const std::string& client_id, const std::string& access_token, const std::string& refresh_token, uint16 expire) : _client_id(client_id), _access_token(access_token), _refresh_token(refresh_token) { _shared.make_share(this); } @@ -55,8 +55,8 @@ oauth2_credentials::oauth2_credentials() {} oauth2_credentials::~oauth2_credentials() { clear(); } -return_t oauth2_credentials::add(std::string& client_id, std::string& client_secret, std::string const& userid, std::string const& appname, - std::string const& redirect_uri, std::list scope) { +return_t oauth2_credentials::add(std::string& client_id, std::string& client_secret, const std::string& userid, const std::string& appname, + const std::string& redirect_uri, std::list scope) { return_t ret = errorcode_t::success; __try2 { openssl_prng prng; @@ -78,8 +78,8 @@ return_t oauth2_credentials::add(std::string& client_id, std::string& client_sec return ret; } -return_t oauth2_credentials::insert(std::string const& client_id, std::string const& client_secret, std::string const& userid, std::string const& appname, - std::string const& redirect_uri, std::list scope) { +return_t oauth2_credentials::insert(const std::string& client_id, const std::string& client_secret, const std::string& userid, const std::string& appname, + const std::string& redirect_uri, std::list scope) { return_t ret = errorcode_t::success; __try2 { critical_section_guard guard(_lock); @@ -101,7 +101,7 @@ return_t oauth2_credentials::insert(std::string const& client_id, std::string co return ret; } -return_t oauth2_credentials::remove(std::string const& client_id) { +return_t oauth2_credentials::remove(const std::string& client_id) { return_t ret = errorcode_t::success; __try2 { critical_section_guard guard(_lock); @@ -135,7 +135,7 @@ return_t oauth2_credentials::remove(std::string const& client_id) { return ret; } -return_t oauth2_credentials::check(std::string const& client_id, std::string const& redirect_uri) { +return_t oauth2_credentials::check(const std::string& client_id, const std::string& redirect_uri) { return_t ret = errorcode_t::success; __try2 { critical_section_guard guard(_lock); @@ -162,7 +162,7 @@ return_t oauth2_credentials::check(std::string const& client_id, std::string con return ret; } -return_t oauth2_credentials::list(std::string const& userid, std::list& clientids) { +return_t oauth2_credentials::list(const std::string& userid, std::list& clientids) { return_t ret = errorcode_t::success; __try2 { clientids.clear(); @@ -198,7 +198,7 @@ return_t oauth2_credentials::grant_code(std::string& code, uint16 expire) { return ret; } -return_t oauth2_credentials::verify_grant_code(std::string const& code) { +return_t oauth2_credentials::verify_grant_code(const std::string& code) { return_t ret = errorcode_t::success; critical_section_guard guard(_lock); @@ -225,7 +225,7 @@ return_t oauth2_credentials::clear_grant_codes() { return ret; } -return_t oauth2_credentials::grant(std::string& access_token, std::string& refresh_token, std::string const& client_id, uint16 expire) { +return_t oauth2_credentials::grant(std::string& access_token, std::string& refresh_token, const std::string& client_id, uint16 expire) { return_t ret = errorcode_t::success; access_token_t* token = nullptr; __try2 { @@ -275,7 +275,7 @@ return_t oauth2_credentials::grant(std::string& access_token, std::string& refre return ret; } -return_t oauth2_credentials::revoke(std::string const& access_token) { +return_t oauth2_credentials::revoke(const std::string& access_token) { return_t ret = errorcode_t::success; __try2 { critical_section_guard guard(_lock); @@ -304,7 +304,7 @@ return_t oauth2_credentials::revoke(std::string const& access_token) { return ret; } -return_t oauth2_credentials::isvalid(std::string const& access_token) { +return_t oauth2_credentials::isvalid(const std::string& access_token) { return_t ret = errorcode_t::failed; __try2 { critical_section_guard guard(_lock); @@ -338,7 +338,7 @@ return_t oauth2_credentials::isvalid(std::string const& access_token) { return ret; } -return_t oauth2_credentials::refresh(std::string& next_access_token, std::string& next_refresh_token, std::string const& refresh_token, uint16 expire) { +return_t oauth2_credentials::refresh(std::string& next_access_token, std::string& next_refresh_token, const std::string& refresh_token, uint16 expire) { return_t ret = errorcode_t::success; __try2 { critical_section_guard guard(_lock); diff --git a/sdk/net/http/auth/oauth2_credentials.hpp b/sdk/net/http/auth/oauth2_credentials.hpp index 50e7de17..d015c8fb 100644 --- a/sdk/net/http/auth/oauth2_credentials.hpp +++ b/sdk/net/http/auth/oauth2_credentials.hpp @@ -218,7 +218,7 @@ class t_expirable_tokens : t_expirable { */ class access_token_t { public: - access_token_t(std::string const& client_id, std::string const& accesstoken, std::string const& refreshtoken, uint16 expire); + access_token_t(const std::string& client_id, const std::string& accesstoken, const std::string& refreshtoken, uint16 expire); std::string access_token() const; std::string refresh_token() const; @@ -251,41 +251,41 @@ class oauth2_credentials { * @brief register an web application * @param std::string& client_id [out] * @param std::string& client_secret [out] - * @param std::string const& userid [in] - * @param std::string const& appname [in] - * @param std::string const& redirect_uri [in] + * @param const std::string& userid [in] + * @param const std::string& appname [in] + * @param const std::string& redirect_uri [in] * @param std::list scope [in] */ - return_t add(std::string& client_id, std::string& client_secret, std::string const& userid, std::string const& appname, std::string const& redirect_uri, + return_t add(std::string& client_id, std::string& client_secret, const std::string& userid, const std::string& appname, const std::string& redirect_uri, std::list scope); /** * @brief add (load from db, ...) - * @param std::string const& client_id [in] - * @param std::string const& client_secret [in] - * @param std::string const& userid [in] - * @param std::string const& appname [in] - * @param std::string const& redirect_uri [in] + * @param const std::string& client_id [in] + * @param const std::string& client_secret [in] + * @param const std::string& userid [in] + * @param const std::string& appname [in] + * @param const std::string& redirect_uri [in] * @param std::list scope [in] */ - return_t insert(std::string const& client_id, std::string const& client_secret, std::string const& userid, std::string const& appname, - std::string const& redirect_uri, std::list scope); + return_t insert(const std::string& client_id, const std::string& client_secret, const std::string& userid, const std::string& appname, + const std::string& redirect_uri, std::list scope); /** * @brief unregister an web application - * @param std::string const& client_id [in] + * @param const std::string& client_id [in] */ - return_t remove(std::string const& client_id); + return_t remove(const std::string& client_id); /** * @brief check */ - return_t check(std::string const& client_id, std::string const& redirect_uri); + return_t check(const std::string& client_id, const std::string& redirect_uri); /** * @brief list of client_id */ - return_t list(std::string const& userid, std::list& clientid); + return_t list(const std::string& userid, std::list& clientid); return_t grant_code(std::string& code, uint16 expire = 10 * 60); - return_t verify_grant_code(std::string const& code); + return_t verify_grant_code(const std::string& code); return_t expire_grant_codes(); return_t clear_grant_codes(); @@ -293,28 +293,28 @@ class oauth2_credentials { * @brief access_token * @param std::string& access_token [out] * @param std::string& refresh_token [out] - * @param std::string const& client_id [in] + * @param const std::string& client_id [in] * @param uint16 expire [inopt] */ - return_t grant(std::string& access_token, std::string& refresh_token, std::string const& client_id, uint16 expire = 60 * 60); + return_t grant(std::string& access_token, std::string& refresh_token, const std::string& client_id, uint16 expire = 60 * 60); /** * @brief revoke an access_token - * @param std::string const& access_token [in] + * @param const std::string& access_token [in] */ - return_t revoke(std::string const& access_token); + return_t revoke(const std::string& access_token); /** * @brief validate - * @param std::string const& access_token [in] + * @param const std::string& access_token [in] */ - return_t isvalid(std::string const& access_token); + return_t isvalid(const std::string& access_token); /** * @brief refresh * @param std::string& next_access_token [out] * @param std::string& next_refresh_token [out] - * @param std::string const& refresh_token [in] + * @param const std::string& refresh_token [in] * @param uint16 expire [inopt] */ - return_t refresh(std::string& next_access_token, std::string& next_refresh_token, std::string const& refresh_token, uint16 expire = 60 * 60); + return_t refresh(std::string& next_access_token, std::string& next_refresh_token, const std::string& refresh_token, uint16 expire = 60 * 60); void revoke_if_expired(); diff --git a/sdk/net/http/auth/rfc2617_digest.cpp b/sdk/net/http/auth/rfc2617_digest.cpp index 58e14fe1..816f0bad 100644 --- a/sdk/net/http/auth/rfc2617_digest.cpp +++ b/sdk/net/http/auth/rfc2617_digest.cpp @@ -26,13 +26,13 @@ rfc2617_digest& rfc2617_digest::add(const char* data) { return *this; } -rfc2617_digest& rfc2617_digest::add(std::string const& data) { +rfc2617_digest& rfc2617_digest::add(const std::string& data) { _stream << data; _sequence << data; return *this; } -rfc2617_digest& rfc2617_digest::add(basic_stream const& data) { +rfc2617_digest& rfc2617_digest::add(const basic_stream& data) { _stream << data; _sequence << data; return *this; @@ -44,19 +44,19 @@ rfc2617_digest& rfc2617_digest::operator<<(const char* data) { return *this; } -rfc2617_digest& rfc2617_digest::operator<<(std::string const& data) { +rfc2617_digest& rfc2617_digest::operator<<(const std::string& data) { _stream << data; _sequence << data; return *this; } -rfc2617_digest& rfc2617_digest::operator<<(basic_stream const& data) { +rfc2617_digest& rfc2617_digest::operator<<(const basic_stream& data) { _stream << data; _sequence << data; return *this; } -rfc2617_digest& rfc2617_digest::digest(std::string const& algorithm) { +rfc2617_digest& rfc2617_digest::digest(const std::string& algorithm) { openssl_digest dgst; std::string digest_value; diff --git a/sdk/net/http/auth/rfc2617_digest.hpp b/sdk/net/http/auth/rfc2617_digest.hpp index 80246a7c..4e02ac71 100644 --- a/sdk/net/http/auth/rfc2617_digest.hpp +++ b/sdk/net/http/auth/rfc2617_digest.hpp @@ -24,12 +24,12 @@ class rfc2617_digest { public: rfc2617_digest(); rfc2617_digest& add(const char* data); - rfc2617_digest& add(std::string const& data); - rfc2617_digest& add(basic_stream const& data); + rfc2617_digest& add(const std::string& data); + rfc2617_digest& add(const basic_stream& data); rfc2617_digest& operator<<(const char* data); - rfc2617_digest& operator<<(std::string const& data); - rfc2617_digest& operator<<(basic_stream const& data); - rfc2617_digest& digest(std::string const& algorithm); + rfc2617_digest& operator<<(const std::string& data); + rfc2617_digest& operator<<(const basic_stream& data); + rfc2617_digest& digest(const std::string& algorithm); std::string get(); std::string get_sequence(); rfc2617_digest& clear(); diff --git a/sdk/net/http/html_documents.cpp b/sdk/net/http/html_documents.cpp index 1c76687c..c2de288d 100644 --- a/sdk/net/http/html_documents.cpp +++ b/sdk/net/http/html_documents.cpp @@ -18,11 +18,11 @@ namespace net { html_documents::html_documents() : _use(false) {} -html_documents::html_documents(std::string const& root_uri, std::string const& directory) : _use(false) { add_documents_root(root_uri, directory); } +html_documents::html_documents(const std::string& root_uri, const std::string& directory) : _use(false) { add_documents_root(root_uri, directory); } bool html_documents::test() { return _use; } -html_documents& html_documents::add_documents_root(std::string const& root_uri, std::string const& directory) { +html_documents& html_documents::add_documents_root(const std::string& root_uri, const std::string& directory) { critical_section_guard guard(_lock); // concat / @@ -42,18 +42,18 @@ html_documents& html_documents::add_documents_root(std::string const& root_uri, return *this; } -html_documents& html_documents::add_content_type(std::string const& dot_ext, std::string const& content_type) { +html_documents& html_documents::add_content_type(const std::string& dot_ext, const std::string& content_type) { critical_section_guard guard(_lock); _content_types.insert(std::make_pair(dot_ext, content_type)); return *this; } -html_documents& html_documents::set_default_document(std::string const& document) { +html_documents& html_documents::set_default_document(const std::string& document) { _document = document; return *this; } -bool html_documents::map(std::string const& uri, std::string& local) { +bool html_documents::map(const std::string& uri, std::string& local) { bool ret_value = false; local.clear(); @@ -75,7 +75,7 @@ bool html_documents::map(std::string const& uri, std::string& local) { return ret_value; } -return_t html_documents::load(std::string const& uri, std::string& content_type, binary_t& content) { +return_t html_documents::load(const std::string& uri, std::string& content_type, binary_t& content) { return_t ret = errorcode_t::success; __try2 { // todo compare timestamp @@ -100,7 +100,7 @@ return_t html_documents::load(std::string const& uri, std::string& content_type, return ret; } -return_t html_documents::handler(std::string const& uri, network_session* session, http_request* request, http_response* response) { +return_t html_documents::handler(const std::string& uri, network_session* session, http_request* request, http_response* response) { return_t ret = errorcode_t::success; if (test()) { std::string content_type; @@ -115,7 +115,7 @@ return_t html_documents::handler(std::string const& uri, network_session* sessio return ret; } -return_t html_documents::search_cache(std::string const& uri, binary_t& content) { +return_t html_documents::search_cache(const std::string& uri, binary_t& content) { return_t ret = errorcode_t::success; critical_section_guard guard(_lock); std::map::iterator iter = _cache_map.find(uri); @@ -127,14 +127,14 @@ return_t html_documents::search_cache(std::string const& uri, binary_t& content) return ret; } -return_t html_documents::insert_cache(std::string const& uri, binary_t& content) { +return_t html_documents::insert_cache(const std::string& uri, binary_t& content) { return_t ret = errorcode_t::success; critical_section_guard guard(_lock); _cache_map.insert(std::make_pair(uri, content)); return ret; } -return_t html_documents::loadfile(std::string const& uri, binary_t& content) { +return_t html_documents::loadfile(const std::string& uri, binary_t& content) { return_t ret = errorcode_t::success; content.clear(); @@ -154,7 +154,7 @@ return_t html_documents::loadfile(std::string const& uri, binary_t& content) { return ret; } -return_t html_documents::get_content_type(std::string const& uri, std::string& content_type) { +return_t html_documents::get_content_type(const std::string& uri, std::string& content_type) { return_t ret = errorcode_t::success; critical_section_guard guard(_lock); diff --git a/sdk/net/http/html_documents.hpp b/sdk/net/http/html_documents.hpp index 049967ea..4144dd78 100644 --- a/sdk/net/http/html_documents.hpp +++ b/sdk/net/http/html_documents.hpp @@ -33,7 +33,7 @@ namespace net { class html_documents { public: html_documents(); - html_documents(std::string const& root_uri, std::string const& directory); + html_documents(const std::string& root_uri, const std::string& directory); bool test(); @@ -44,19 +44,19 @@ class html_documents { * .add_content_type(".html", "text/html") * .set_default_document("index.html); */ - html_documents& add_documents_root(std::string const& root_uri, std::string const& directory); - html_documents& add_content_type(std::string const& dot_ext, std::string const& content_type); - html_documents& set_default_document(std::string const& document); + html_documents& add_documents_root(const std::string& root_uri, const std::string& directory); + html_documents& add_content_type(const std::string& dot_ext, const std::string& content_type); + html_documents& set_default_document(const std::string& document); - return_t load(std::string const& uri, std::string& content_type, binary_t& content); - return_t handler(std::string const& uri, network_session* session, http_request* request, http_response* response); + return_t load(const std::string& uri, std::string& content_type, binary_t& content); + return_t handler(const std::string& uri, network_session* session, http_request* request, http_response* response); protected: - bool map(std::string const& uri, std::string& local); - return_t search_cache(std::string const& uri, binary_t& content); - return_t insert_cache(std::string const& uri, binary_t& content); - return_t loadfile(std::string const& uri, binary_t& content); - return_t get_content_type(std::string const& uri, std::string& content_type); + bool map(const std::string& uri, std::string& local); + return_t search_cache(const std::string& uri, binary_t& content); + return_t insert_cache(const std::string& uri, binary_t& content); + return_t loadfile(const std::string& uri, binary_t& content); + return_t get_content_type(const std::string& uri, std::string& content_type); private: critical_section _lock; diff --git a/sdk/net/http/http2/hpack.cpp b/sdk/net/http/http2/hpack.cpp index 2ff699ca..d0687c42 100644 --- a/sdk/net/http/http2/hpack.cpp +++ b/sdk/net/http/http2/hpack.cpp @@ -34,7 +34,7 @@ hpack& hpack::set_encode_flags(uint32 flags) { return *this; } -hpack& hpack::encode_header(std::string const& name, std::string const& value) { +hpack& hpack::encode_header(const std::string& name, const std::string& value) { if (_session) { (*_encoder).encode_header(_session, _bin, name, value, _flags); } @@ -155,7 +155,7 @@ hpack_encoder& hpack_encoder::encode_string(binary_t& target, uint32 flags, cons return *this; } -hpack_encoder& hpack_encoder::encode_string(binary_t& target, uint32 flags, std::string const& value) { +hpack_encoder& hpack_encoder::encode_string(binary_t& target, uint32 flags, const std::string& value) { return encode_string(target, flags, value.c_str(), value.size()); } @@ -231,7 +231,7 @@ hpack_encoder& hpack_encoder::encode_indexed_name(binary_t& target, uint32 flags return *this; } -hpack_encoder& hpack_encoder::encode_indexed_name(binary_t& target, uint32 flags, uint8 index, std::string const& value) { +hpack_encoder& hpack_encoder::encode_indexed_name(binary_t& target, uint32 flags, uint8 index, const std::string& value) { return encode_indexed_name(target, flags, index, value.c_str(), value.size()); } @@ -287,7 +287,7 @@ hpack_encoder& hpack_encoder::encode_name_value(binary_t& target, uint32 flags, return *this; } -hpack_encoder& hpack_encoder::encode_name_value(binary_t& target, uint32 flags, std::string const& name, std::string const& value) { +hpack_encoder& hpack_encoder::encode_name_value(binary_t& target, uint32 flags, const std::string& name, const std::string& value) { return encode_name_value(target, flags, name.c_str(), value.c_str()); } @@ -372,7 +372,7 @@ return_t hpack_encoder::decode_string(const byte_t* p, size_t& pos, uint8 flags, return ret; } -match_result_t hpack_encoder::match(hpack_session* session, std::string const& name, std::string const& value, size_t& index) { +match_result_t hpack_encoder::match(hpack_session* session, const std::string& name, const std::string& value, size_t& index) { match_result_t state = match_result_t::not_matched; index = 0; @@ -438,7 +438,7 @@ return_t hpack_encoder::select(hpack_session* session, uint32 flags, size_t inde return ret; } -return_t hpack_encoder::insert(hpack_session* session, std::string const& name, std::string const& value) { +return_t hpack_encoder::insert(hpack_session* session, const std::string& name, const std::string& value) { // RFC 7541 Figure 1: Index Address Space // // <---------- Index Address Space ----------> @@ -465,7 +465,7 @@ return_t hpack_encoder::insert(hpack_session* session, std::string const& name, return ret; } -hpack_encoder& hpack_encoder::encode_header(hpack_session* session, binary_t& target, std::string const& name, std::string const& value, uint32 flags) { +hpack_encoder& hpack_encoder::encode_header(hpack_session* session, binary_t& target, const std::string& name, const std::string& value, uint32 flags) { match_result_t state = match_result_t::not_matched; if (session) { size_t index = 0; @@ -580,7 +580,7 @@ void hpack_session::for_each(std::function v); protected: - match_result_t match(std::string const& name, std::string const& value, size_t& index); - return_t insert(std::string const& name, std::string const& value); + match_result_t match(const std::string& name, const std::string& value, size_t& index); + return_t insert(const std::string& name, const std::string& value); return_t select(uint32 flags, size_t index, std::string& name, std::string& value); private: diff --git a/sdk/net/http/http2/http2_frame.cpp b/sdk/net/http/http2/http2_frame.cpp index 29c86d5d..b5eeaef5 100644 --- a/sdk/net/http/http2/http2_frame.cpp +++ b/sdk/net/http/http2/http2_frame.cpp @@ -49,7 +49,7 @@ http2_frame_header::http2_frame_header() : _payload_size(0), _type(0), _flags(0) http2_frame_header::http2_frame_header(h2_frame_t type) : _payload_size(0), _type(type), _flags(0), _stream_id(0), _hpack_encoder(nullptr), _hpack_session(nullptr) {} -http2_frame_header::http2_frame_header(http2_frame_header_t const& header) { read(&header, sizeof(http2_frame_header_t)); } +http2_frame_header::http2_frame_header(const http2_frame_header_t& header) { read(&header, sizeof(http2_frame_header_t)); } http2_frame_header::http2_frame_header(const http2_frame_header& rhs) { _payload_size = rhs._payload_size; @@ -181,7 +181,7 @@ void http2_frame_header::dump(stream_t* s) { s->printf("\n"); s->printf("> %s [ ", constexpr_frame_flags); - resource->for_each_frame_flag_names(get_type(), get_flags(), [&](uint8 flag, std::string const& name) -> void { s->printf("%s ", name.c_str()); }); + resource->for_each_frame_flag_names(get_type(), get_flags(), [&](uint8 flag, const std::string& name) -> void { s->printf("%s ", name.c_str()); }); s->printf("]\n"); } diff --git a/sdk/net/http/http2/http2_frame.hpp b/sdk/net/http/http2/http2_frame.hpp index 13f6f2e1..d9cd3942 100644 --- a/sdk/net/http/http2/http2_frame.hpp +++ b/sdk/net/http/http2/http2_frame.hpp @@ -20,10 +20,12 @@ namespace hotplace { namespace net { -// studying ... - -// RFC 7540 4. HTTP Frames -// RFC 7540 11.2. Frame Type Registry +/** + * @brief frame type + * @see + * RFC 7540 4. HTTP Frames + * RFC 7540 11.2. Frame Type Registry + */ enum h2_frame_t { h2_frame_data = 0x0, // RFC 7540 6.1. DATA h2_frame_headers = 0x1, // RFC 7540 6.2. HEADERS @@ -37,7 +39,11 @@ enum h2_frame_t { h2_frame_continuation = 0x9, // RFC 7540 6.10. CONTINUATION }; -// RFC 7540 6. Frame Definitions +/** + * @brief frame flag + * @see + * RFC 7540 6. Frame Definitions + */ enum h2_flag_t { h2_flag_end_stream = 0x1, // DATA, HEADERS h2_flag_end_headers = 0x4, // HEADERS, PUSH_PROMISE, CONTINUATION @@ -47,19 +53,27 @@ enum h2_flag_t { h2_flag_ack = 0x1, // SETTINGS, PING }; -// RFC 7540 6.5.2. Defined Settings Parameters -// RFC 7540 11.3. Settings Registry +/** + * @brief settings frame parameters + * @see + * RFC 7540 6.5.2. Defined Settings Parameters + * RFC 7540 11.3. Settings Registry + */ enum h2_settings_param_t { - h2_settings_header_table_size = 0x1, // SETTINGS - h2_settings_enable_push = 0x2, // SETTINGS - h2_settings_max_concurrent_streams = 0x3, // SETTINGS - h2_settings_initial_window_size = 0x4, // SETTINGS - h2_settings_max_frame_size = 0x5, // SETTINGS - h2_settings_max_header_list_size = 0x6, // SETTINGS + h2_settings_header_table_size = 0x1, + h2_settings_enable_push = 0x2, + h2_settings_max_concurrent_streams = 0x3, + h2_settings_initial_window_size = 0x4, + h2_settings_max_frame_size = 0x5, + h2_settings_max_header_list_size = 0x6, }; -// RFC 7540 7. Error Codes -// RFC 7540 11.4. Error Code Registry +/** + * @brief error codes + * @see + * RFC 7540 7. Error Codes + * RFC 7540 11.4. Error Code Registry + */ enum h2_errorcodes_t { h2_no_error = 0x0, h2_protocol_error = 0x1, @@ -79,7 +93,11 @@ enum h2_errorcodes_t { #pragma pack(push, 1) -// RFC 7540 6. Frame Definitionsz +/** + * @brief frame + * @see + * RFC 7540 6. Frame Definitionsz + */ typedef struct _http2_frame_header_t { byte_t len[3]; // length (24), 2^14, SETTINGS_MAX_FRAME_SIZE 2^24-1 uint8 type; // type (8) @@ -92,24 +110,13 @@ typedef struct _http2_setting_t { uint32 value; } http2_setting_t; -typedef struct _http2_priority_t { - uint32 dependency; - uint8 weight; -} http2_priority_t; - -typedef struct _http2_goaway_t { - uint32 last_id; - uint32 errorcode; - byte_t* debug; -} http2_goaway_t; - #pragma pack(pop) class http2_frame_header { public: http2_frame_header(); http2_frame_header(h2_frame_t type); - http2_frame_header(http2_frame_header_t const& header); + http2_frame_header(const http2_frame_header_t& header); http2_frame_header(const http2_frame_header& rhs); uint32 get_frame_size(); @@ -146,8 +153,12 @@ class http2_frame_header { hpack_session* _hpack_session; }; -// RFC 7540 6.1. DATA -// RFC 7540 Figure 6: DATA Frame Payload +/** + * @brief data frame + * @see + * RFC 7540 6.1. DATA + * RFC 7540 Figure 6: DATA Frame Payload + */ class http2_frame_data : public http2_frame_header { public: http2_frame_data(); @@ -164,7 +175,11 @@ class http2_frame_data : public http2_frame_header { binary_t _data; }; -// RFC 7540 6.2 HEADERS +/** + * @brief headers frame + * @see + * RFC 7540 6.2 HEADERS + */ class http2_frame_headers : public http2_frame_header { public: http2_frame_headers(); @@ -184,8 +199,12 @@ class http2_frame_headers : public http2_frame_header { binary_t _fragment; }; -// RFC 7540 6.3. PRIORITY -// RFC 7540 Figure 8: PRIORITY Frame Payload +/** + * @brief priority frame + * @see + * RFC 7540 6.3. PRIORITY + * RFC 7540 Figure 8: PRIORITY Frame Payload + */ class http2_frame_priority : public http2_frame_header { public: http2_frame_priority(); @@ -201,8 +220,12 @@ class http2_frame_priority : public http2_frame_header { uint8 _weight; }; -// RFC 7540 6.4. RST_STREAM -// RFC 7540 Figure 9: RST_STREAM Frame Payload +/** + * @brief reset_stream (RS) frame + * @see + * RFC 7540 6.4. RST_STREAM + * RFC 7540 Figure 9: RST_STREAM Frame Payload + */ class http2_frame_rst_stream : public http2_frame_header { public: http2_frame_rst_stream(); @@ -216,7 +239,11 @@ class http2_frame_rst_stream : public http2_frame_header { uint32 _errorcode; }; -// RFC 7540 6.5. SETTINGS +/** + * @brief settings frame + * @see + * RFC 7540 6.5. SETTINGS + */ class http2_frame_settings : public http2_frame_header { public: http2_frame_settings(); @@ -234,7 +261,11 @@ class http2_frame_settings : public http2_frame_header { h2_setting_map_t _settings; }; -// RFC 7540 6.6. PUSH_PROMISE +/** + * @brief push_promise (PP) frame + * @see + * RFC 7540 6.6. PUSH_PROMISE + */ class http2_frame_push_promise : public http2_frame_header { public: http2_frame_push_promise(); @@ -252,7 +283,11 @@ class http2_frame_push_promise : public http2_frame_header { binary_t _fragment; }; -// RFC 7540 6.7. PING +/** + * @brief ping frame + * @see + * RFC 7540 6.7. PING + */ class http2_frame_ping : public http2_frame_header { public: http2_frame_ping(); @@ -266,7 +301,11 @@ class http2_frame_ping : public http2_frame_header { uint64 _opaque; }; -// RFC 7540 6.8. GOAWAY +/** + * @brief goaway frame + * @see + * RFC 7540 6.8. GOAWAY + */ class http2_frame_goaway : public http2_frame_header { public: http2_frame_goaway(); @@ -285,7 +324,11 @@ class http2_frame_goaway : public http2_frame_header { binary_t _debug; }; -// RFC 7540 6.9. WINDOW_UPDATE +/** + * @brief window_update frame + * @see + * RFC 7540 6.9. WINDOW_UPDATE + */ class http2_frame_window_update : public http2_frame_header { public: http2_frame_window_update(); @@ -299,7 +342,11 @@ class http2_frame_window_update : public http2_frame_header { uint32 _increment; }; -// RFC 7540 6.10. CONTINUATION +/** + * @brief continuation frame + * @see + * RFC 7540 6.10. CONTINUATION + */ class http2_frame_continuation : public http2_frame_header { public: http2_frame_continuation(); diff --git a/sdk/net/http/http2/http2_protocol.cpp b/sdk/net/http/http2/http2_protocol.cpp index 6ccbd113..16fa1f9a 100644 --- a/sdk/net/http/http2/http2_protocol.cpp +++ b/sdk/net/http/http2/http2_protocol.cpp @@ -19,7 +19,7 @@ namespace hotplace { using namespace io; namespace net { -http2_protocol::http2_protocol() {} +http2_protocol::http2_protocol() : network_protocol() {} http2_protocol::~http2_protocol() {} diff --git a/sdk/net/http/http_authentication_provider.cpp b/sdk/net/http/http_authentication_provider.cpp index d4b36b4e..ae2261f7 100644 --- a/sdk/net/http/http_authentication_provider.cpp +++ b/sdk/net/http/http_authentication_provider.cpp @@ -19,7 +19,7 @@ using namespace crypto; using namespace io; namespace net { -http_authenticate_provider::http_authenticate_provider(std::string const& realm) : _realm(realm) { _shared.make_share(this); } +http_authenticate_provider::http_authenticate_provider(const std::string& realm) : _realm(realm) { _shared.make_share(this); } std::string http_authenticate_provider::get_challenge(http_request* request) { std::string token_auth; diff --git a/sdk/net/http/http_authentication_provider.hpp b/sdk/net/http/http_authentication_provider.hpp index 9f743c82..9a604228 100644 --- a/sdk/net/http/http_authentication_provider.hpp +++ b/sdk/net/http/http_authentication_provider.hpp @@ -47,7 +47,7 @@ class http_authentication_resolver; */ class http_authenticate_provider { public: - http_authenticate_provider(std::string const& realm); + http_authenticate_provider(const std::string& realm); /** * @brief try diff --git a/sdk/net/http/http_authentication_resolver.cpp b/sdk/net/http/http_authentication_resolver.cpp index e77e1d2b..cea6c1bd 100644 --- a/sdk/net/http/http_authentication_resolver.cpp +++ b/sdk/net/http/http_authentication_resolver.cpp @@ -132,19 +132,19 @@ bool http_authentication_resolver::custom_authenticate(http_authenticate_provide return ret_value; } -basic_credentials& http_authentication_resolver::get_basic_credentials(std::string const& realm) { +basic_credentials& http_authentication_resolver::get_basic_credentials(const std::string& realm) { basic_credentials dummy; realm_basic_credentials_pib_t pib = _realm_basic_credentials.insert(std::make_pair(realm, dummy)); return pib.first->second; } -digest_credentials& http_authentication_resolver::get_digest_credentials(std::string const& realm) { +digest_credentials& http_authentication_resolver::get_digest_credentials(const std::string& realm) { digest_credentials dummy; realm_digest_credentials_pib_t pib = _realm_digest_credentials.insert(std::make_pair(realm, dummy)); return pib.first->second; } -bearer_credentials& http_authentication_resolver::get_bearer_credentials(std::string const& realm) { +bearer_credentials& http_authentication_resolver::get_bearer_credentials(const std::string& realm) { bearer_credentials dummy; realm_bearer_credentials_pib_t pib = _realm_bearer_credentials.insert(std::make_pair(realm, dummy)); return pib.first->second; diff --git a/sdk/net/http/http_authentication_resolver.hpp b/sdk/net/http/http_authentication_resolver.hpp index 52b32dfe..301fede7 100644 --- a/sdk/net/http/http_authentication_resolver.hpp +++ b/sdk/net/http/http_authentication_resolver.hpp @@ -109,9 +109,9 @@ class http_authentication_resolver { */ bool custom_authenticate(http_authenticate_provider* provider, network_session* session, http_request* request, http_response* response); - basic_credentials& get_basic_credentials(std::string const& realm); - digest_credentials& get_digest_credentials(std::string const& realm); - bearer_credentials& get_bearer_credentials(std::string const& realm); + basic_credentials& get_basic_credentials(const std::string& realm); + digest_credentials& get_digest_credentials(const std::string& realm); + bearer_credentials& get_bearer_credentials(const std::string& realm); oauth2_credentials& get_oauth2_credentials(); custom_credentials& get_custom_credentials(); diff --git a/sdk/net/http/http_client.cpp b/sdk/net/http/http_client.cpp index a09a0d15..7a06e668 100644 --- a/sdk/net/http/http_client.cpp +++ b/sdk/net/http/http_client.cpp @@ -62,7 +62,7 @@ tcp_client_socket* http_client::try_connect() { return client; } -http_client& http_client::request(std::string const& url, http_response** response) { +http_client& http_client::request(const std::string& url, http_response** response) { url_info_t url_info; split_url(url.c_str(), &url_info); @@ -75,7 +75,7 @@ http_client& http_client::request(std::string const& url, http_response** respon http_client& http_client::request(http_request& request, http_response** response) { return do_request_and_response(_url_info, request, response); } -http_client& http_client::do_request_and_response(url_info_t const& url_info, http_request& request, http_response** response) { +http_client& http_client::do_request_and_response(const url_info_t& url_info, http_request& request, http_response** response) { return_t ret = errorcode_t::success; tcp_client_socket* client = nullptr; http_response* resp = nullptr; @@ -147,14 +147,14 @@ http_client& http_client::close() { return *this; } -http_client& http_client::set_url(std::string const& url) { +http_client& http_client::set_url(const std::string& url) { url_info_t url_info; split_url(url.c_str(), &url_info); return set_url(url_info); } -http_client& http_client::set_url(url_info_t const& url_info) { +http_client& http_client::set_url(const url_info_t& url_info) { if ((_url_info.scheme != url_info.scheme) || (_url_info.host != url_info.host) || (_url_info.port != url_info.port)) { close(); } diff --git a/sdk/net/http/http_client.hpp b/sdk/net/http/http_client.hpp index f1e6c794..69f7601c 100644 --- a/sdk/net/http/http_client.hpp +++ b/sdk/net/http/http_client.hpp @@ -55,17 +55,17 @@ class http_client { http_client(); ~http_client(); - http_client& set_url(std::string const& url); - http_client& set_url(url_info_t const& url_info); + http_client& set_url(const std::string& url); + http_client& set_url(const url_info_t& url_info); http_client& set_ttl(uint32 milliseconds); - http_client& request(std::string const& url, http_response** response); + http_client& request(const std::string& url, http_response** response); http_client& request(http_request& request, http_response** response); http_client& close(); protected: tcp_client_socket* try_connect(); - http_client& do_request_and_response(url_info_t const& url_info, http_request& request, http_response** response); + http_client& do_request_and_response(const url_info_t& url_info, http_request& request, http_response** response); private: socket_t _socket; diff --git a/sdk/net/http/http_header.cpp b/sdk/net/http/http_header.cpp index 24fb5213..a087a8d8 100644 --- a/sdk/net/http/http_header.cpp +++ b/sdk/net/http/http_header.cpp @@ -46,7 +46,7 @@ http_header& http_header::add(const char* header, const char* value) { return *this; } -http_header& http_header::add(std::string const& header, std::string const& value) { return add(header.c_str(), value.c_str()); } +http_header& http_header::add(const std::string& header, const std::string& value) { return add(header.c_str(), value.c_str()); } http_header& http_header::clear() { critical_section_guard guard(_lock); @@ -149,7 +149,7 @@ return_t http_header::get_headers(std::string& contents) { return ret; } -return_t http_header::to_keyvalue(std::string const& value, key_value& kv) { +return_t http_header::to_keyvalue(const std::string& value, key_value& kv) { return_t ret = errorcode_t::success; std::string token; @@ -179,7 +179,7 @@ return_t http_header::to_keyvalue(std::string const& value, key_value& kv) { return ret; } -http_header& http_header::operator=(http_header const& object) { +http_header& http_header::operator=(const http_header& object) { critical_section_guard guard(_lock); _names = object._names; _headers = object._headers; diff --git a/sdk/net/http/http_header.hpp b/sdk/net/http/http_header.hpp index aa081ef0..512e47af 100644 --- a/sdk/net/http/http_header.hpp +++ b/sdk/net/http/http_header.hpp @@ -50,7 +50,7 @@ class http_header { * @param std::string value [IN] * @return *this */ - http_header& add(std::string const& header, std::string const& value); + http_header& add(const std::string& header, const std::string& value); /** * @brief clear @@ -60,7 +60,7 @@ class http_header { /** * @brief conversion - * @param std::string const& value [in] + * @param const std::string& value [in] * @param key_value& kv [out] * @return error code (see error.hpp) * @sample @@ -78,7 +78,7 @@ class http_header { * std::string nc = kv.get("nc"); * std::string cnonce = kv.get("cnonce"); */ - static return_t to_keyvalue(std::string const& value, key_value& kv); + static return_t to_keyvalue(const std::string& value, key_value& kv); /** * @brief read a header @@ -121,7 +121,7 @@ class http_header { */ return_t get_headers(std::string& contents); - http_header& operator=(http_header const& object); + http_header& operator=(const http_header& object); protected: typedef std::list http_header_list_t; diff --git a/sdk/net/http/http_request.cpp b/sdk/net/http/http_request.cpp index 00f4648e..9c7c2eb4 100644 --- a/sdk/net/http/http_request.cpp +++ b/sdk/net/http/http_request.cpp @@ -142,9 +142,9 @@ return_t http_request::open(const char* request, uint32 flags) { return ret; } -return_t http_request::open(basic_stream const& request, uint32 flags) { return open(request.c_str(), request.size(), flags); } +return_t http_request::open(const basic_stream& request, uint32 flags) { return open(request.c_str(), request.size(), flags); } -return_t http_request::open(std::string const& request, uint32 flags) { return open(request.c_str(), request.size(), flags); } +return_t http_request::open(const std::string& request, uint32 flags) { return open(request.c_str(), request.size(), flags); } return_t http_request::close() { return_t ret = errorcode_t::success; @@ -161,7 +161,7 @@ http_uri& http_request::get_http_uri() { return _uri; } const char* http_request::get_method() { return _method.c_str(); } -http_request& http_request::compose(http_method_t method, std::string const& uri, std::string const& body) { +http_request& http_request::compose(http_method_t method, const std::string& uri, const std::string& body) { http_resource* resource = http_resource::get_instance(); basic_stream stream; diff --git a/sdk/net/http/http_request.hpp b/sdk/net/http/http_request.hpp index 61424595..c360e0d9 100644 --- a/sdk/net/http/http_request.hpp +++ b/sdk/net/http/http_request.hpp @@ -48,8 +48,8 @@ class http_request { */ return_t open(const char* request, size_t size_request, uint32 flags = 0); return_t open(const char* request, uint32 flags = 0); - return_t open(basic_stream const& request, uint32 flags = 0); - return_t open(std::string const& request, uint32 flags = 0); + return_t open(const basic_stream& request, uint32 flags = 0); + return_t open(const std::string& request, uint32 flags = 0); /** * @brief close * @return error code (see error.hpp) @@ -76,15 +76,15 @@ class http_request { /** * @brief compose * @param http_method_t method [in] - * @param std::string const& uri [in] - * @param std::string const& body [inopt] + * @param const std::string& uri [in] + * @param const std::string& body [inopt] * @example * request.get_http_header() * .clear() * .add("User-Agent", "client"); * request.compose(200, "text/plain", "hello world"); */ - http_request& compose(http_method_t method, std::string const& uri, std::string const& body = std::string("")); + http_request& compose(http_method_t method, const std::string& uri, const std::string& body = std::string("")); /** * @brief load * @param basic_stream& stream [out] diff --git a/sdk/net/http/http_resource.cpp b/sdk/net/http/http_resource.cpp index a6d83e5e..d4710b02 100644 --- a/sdk/net/http/http_resource.cpp +++ b/sdk/net/http/http_resource.cpp @@ -142,7 +142,7 @@ std::string http_resource::get_frame_flag(uint8 flag) { return flag_name; } -void http_resource::for_each_frame_flag_names(uint8 type, uint8 flags, std::function func) { +void http_resource::for_each_frame_flag_names(uint8 type, uint8 flags, std::function func) { if (flags && func) { switch (type) { case h2_frame_t::h2_frame_settings: diff --git a/sdk/net/http/http_resource.hpp b/sdk/net/http/http_resource.hpp index c5d96b81..8984d08f 100644 --- a/sdk/net/http/http_resource.hpp +++ b/sdk/net/http/http_resource.hpp @@ -52,7 +52,7 @@ class http_resource { * @brief frame flag */ std::string get_frame_flag(uint8 flag); - void for_each_frame_flag_names(uint8 type, uint8 flags, std::function func); + void for_each_frame_flag_names(uint8 type, uint8 flags, std::function func); /** * @brief RFC 7541 Appendix A. Static Table Definition diff --git a/sdk/net/http/http_response.cpp b/sdk/net/http/http_response.cpp index bb403c95..4122de64 100644 --- a/sdk/net/http/http_response.cpp +++ b/sdk/net/http/http_response.cpp @@ -137,9 +137,9 @@ return_t http_response::open(const char* response) { return ret; } -return_t http_response::open(basic_stream const& response) { return open(response.c_str(), response.size()); } +return_t http_response::open(const basic_stream& response) { return open(response.c_str(), response.size()); } -return_t http_response::open(std::string const& response) { return open(response.c_str(), response.size()); } +return_t http_response::open(const std::string& response) { return open(response.c_str(), response.size()); } return_t http_response::close() { return_t ret = errorcode_t::success; @@ -172,7 +172,7 @@ http_response& http_response::compose(int status_code, const char* content_type, return *this; } -http_response& http_response::compose(int status_code, std::string const& content_type, const char* content, ...) { +http_response& http_response::compose(int status_code, const std::string& content_type, const char* content, ...) { close(); _content_type = content_type; @@ -265,7 +265,7 @@ http_response& http_response::get_response(basic_stream& bs) { std::string http_response::get_version() { return "HTTP/1.1"; } -http_response& http_response::operator=(http_response const& object) { +http_response& http_response::operator=(const http_response& object) { _header = object._header; _request = object._request; _content_type = object._content_type; diff --git a/sdk/net/http/http_response.hpp b/sdk/net/http/http_response.hpp index 6715695f..f9e3411f 100644 --- a/sdk/net/http/http_response.hpp +++ b/sdk/net/http/http_response.hpp @@ -46,8 +46,8 @@ class http_response { */ return_t open(const char* response, size_t size_response); return_t open(const char* response); - return_t open(basic_stream const& response); - return_t open(std::string const& response); + return_t open(const basic_stream& response); + return_t open(const std::string& response); /* * * @brief close * @return error code (see error.hpp) @@ -59,7 +59,7 @@ class http_response { */ http_response& compose(int status_code); http_response& compose(int status_code, const char* content_type, const char* content, ...); - http_response& compose(int status_code, std::string const& content_type, const char* content, ...); + http_response& compose(int status_code, const std::string& content_type, const char* content, ...); /** * @brief respond * @example @@ -98,7 +98,7 @@ class http_response { virtual std::string get_version(); - http_response& operator=(http_response const& object); + http_response& operator=(const http_response& object); void addref(); void release(); diff --git a/sdk/net/http/http_router.cpp b/sdk/net/http/http_router.cpp index f9428ff2..796c78e2 100644 --- a/sdk/net/http/http_router.cpp +++ b/sdk/net/http/http_router.cpp @@ -43,7 +43,7 @@ http_router& http_router::add(const char* uri, http_request_function_t handler, return *this; } -http_router& http_router::add(std::string const& uri, http_request_handler_t handler, http_authenticate_provider* auth_provider, bool upref) { +http_router& http_router::add(const std::string& uri, http_request_handler_t handler, http_authenticate_provider* auth_provider, bool upref) { critical_section_guard guard(_lock); http_router_t route; @@ -62,7 +62,7 @@ http_router& http_router::add(std::string const& uri, http_request_handler_t han return *this; } -http_router& http_router::add(std::string const& uri, http_request_function_t handler, http_authenticate_provider* auth_provider, bool upref) { +http_router& http_router::add(const std::string& uri, http_request_function_t handler, http_authenticate_provider* auth_provider, bool upref) { critical_section_guard guard(_lock); http_router_t route; diff --git a/sdk/net/http/http_router.hpp b/sdk/net/http/http_router.hpp index eb283252..078f4917 100644 --- a/sdk/net/http/http_router.hpp +++ b/sdk/net/http/http_router.hpp @@ -45,8 +45,8 @@ class http_router { */ http_router& add(const char* uri, http_request_handler_t handler, http_authenticate_provider* auth_provider = nullptr, bool upref = false); http_router& add(const char* uri, http_request_function_t handler, http_authenticate_provider* auth_provider = nullptr, bool upref = false); - http_router& add(std::string const& uri, http_request_handler_t handler, http_authenticate_provider* auth_provider = nullptr, bool upref = false); - http_router& add(std::string const& uri, http_request_function_t handler, http_authenticate_provider* auth_provider = nullptr, bool upref = false); + http_router& add(const std::string& uri, http_request_handler_t handler, http_authenticate_provider* auth_provider = nullptr, bool upref = false); + http_router& add(const std::string& uri, http_request_function_t handler, http_authenticate_provider* auth_provider = nullptr, bool upref = false); /** * @brief register a handler * @sample diff --git a/sdk/net/http/http_server.cpp b/sdk/net/http/http_server.cpp index 49ffd0a2..de2a07a3 100644 --- a/sdk/net/http/http_server.cpp +++ b/sdk/net/http/http_server.cpp @@ -61,7 +61,7 @@ return_t http_server::accept_handler(socket_t socket, sockaddr_storage_t* client return ret; } -return_t http_server::startup_tls(std::string const& server_cert, std::string const& server_key, std::string const& cipher_list, int verify_peer) { +return_t http_server::startup_tls(const std::string& server_cert, const std::string& server_key, const std::string& cipher_list, int verify_peer) { return_t ret = errorcode_t::success; __try2 { __try_new_catch(_cert, new x509cert(server_cert.c_str(), server_key.c_str()), ret, __leave2); diff --git a/sdk/net/http/http_server.hpp b/sdk/net/http/http_server.hpp index 75407392..49e64d83 100644 --- a/sdk/net/http/http_server.hpp +++ b/sdk/net/http/http_server.hpp @@ -60,7 +60,7 @@ class http_server { static return_t accept_handler(socket_t socket, sockaddr_storage_t* client_addr, CALLBACK_CONTROL* control, void* parameter); - return_t startup_tls(std::string const& server_cert, std::string const& server_key, std::string const& cipher_list, int verify_peer); + return_t startup_tls(const std::string& server_cert, const std::string& server_key, const std::string& cipher_list, int verify_peer); return_t shutdown_tls(); return_t startup_server(uint16 tls, uint16 family, uint16 port, http_server_handler_t handler); return_t shutdown_server(); diff --git a/sdk/net/http/http_server_builder.cpp b/sdk/net/http/http_server_builder.cpp index 47f70679..af46bc16 100644 --- a/sdk/net/http/http_server_builder.cpp +++ b/sdk/net/http/http_server_builder.cpp @@ -53,13 +53,13 @@ http_server_builder& http_server_builder::set_port_https(uint16 port) { return *this; } -http_server_builder& http_server_builder::set_tls_certificate(std::string const& server_cert, std::string const& server_key) { +http_server_builder& http_server_builder::set_tls_certificate(const std::string& server_cert, const std::string& server_key) { _server_cert = server_cert; _server_key = server_key; return *this; } -http_server_builder& http_server_builder::set_tls_cipher_list(std::string const& cipher_list) { +http_server_builder& http_server_builder::set_tls_cipher_list(const std::string& cipher_list) { _tls_cipher_list = cipher_list; return *this; } diff --git a/sdk/net/http/http_server_builder.hpp b/sdk/net/http/http_server_builder.hpp index 29d79e3d..5bb2f425 100644 --- a/sdk/net/http/http_server_builder.hpp +++ b/sdk/net/http/http_server_builder.hpp @@ -52,8 +52,8 @@ class http_server_builder { http_server_builder& enable_https(bool enable); http_server_builder& set_port_https(uint16 port = 443); - http_server_builder& set_tls_certificate(std::string const& server_cert, std::string const& server_key); - http_server_builder& set_tls_cipher_list(std::string const& cipher_list); + http_server_builder& set_tls_certificate(const std::string& server_cert, const std::string& server_key); + http_server_builder& set_tls_cipher_list(const std::string& cipher_list); http_server_builder& set_tls_verify_peer(uint16 value); http_server_builder& enable_ipv4(bool enable); diff --git a/sdk/net/http/http_uri.cpp b/sdk/net/http/http_uri.cpp index a4d650d1..fa73abbc 100644 --- a/sdk/net/http/http_uri.cpp +++ b/sdk/net/http/http_uri.cpp @@ -30,7 +30,7 @@ http_uri::~http_uri() { // do nothing } -return_t http_uri::open(std::string const& uri) { return open(uri.c_str()); } +return_t http_uri::open(const std::string& uri) { return open(uri.c_str()); } return_t http_uri::open(const char* uri) { return_t ret = errorcode_t::success; @@ -81,7 +81,7 @@ return_t http_uri::set_query(const char* query) { return ret; } -return_t http_uri::set_query(std::string const& query) { +return_t http_uri::set_query(const std::string& query) { return_t ret = errorcode_t::success; ret = to_keyvalue(query, _query_kv); return ret; @@ -108,7 +108,7 @@ const char* http_uri::get_query() { return ret_value; } -return_t http_uri::query(std::string const& key, std::string& value) { +return_t http_uri::query(const std::string& key, std::string& value) { return_t ret = errorcode_t::success; ret = _query_kv.query(key, value); return ret; @@ -116,7 +116,7 @@ return_t http_uri::query(std::string const& key, std::string& value) { size_t http_uri::countof_query() { return _query_kv.size(); } -return_t http_uri::to_keyvalue(std::string const& value, key_value& kv) { +return_t http_uri::to_keyvalue(const std::string& value, key_value& kv) { return_t ret = errorcode_t::success; std::string input; diff --git a/sdk/net/http/http_uri.hpp b/sdk/net/http/http_uri.hpp index 96a0e5b8..3c5653c4 100644 --- a/sdk/net/http/http_uri.hpp +++ b/sdk/net/http/http_uri.hpp @@ -36,10 +36,10 @@ class http_uri { /** * @brief open - * @param std::string const& uri [in] + * @param const std::string& uri [in] * @return error code (see error.hpp) */ - return_t open(std::string const& uri); + return_t open(const std::string& uri); return_t open(const char* uri); /** * @brief close @@ -47,7 +47,7 @@ class http_uri { void close(); return_t set_query(const char* query); - return_t set_query(std::string const& query); + return_t set_query(const std::string& query); /** * @brief URI @@ -57,11 +57,11 @@ class http_uri { const char* get_query(); /** * @brief read a param - * @param std::string const& key [in] + * @param const std::string& key [in] * @param std::string& value [out] * @return error code (see error.hpp) */ - return_t query(std::string const& key, std::string& value); + return_t query(const std::string& key, std::string& value); /** * @brief count of query * @remarks @@ -70,7 +70,7 @@ class http_uri { /* * @brief conversion - * @param std::string const& value [in] + * @param const std::string& value [in] * @param key_value& kv [out] * @return error code (see error.hpp) * @sample @@ -78,13 +78,13 @@ class http_uri { * http_uri::to_keyvalue(input, kv); * std::string client_id = kv.get("client_id"); */ - static return_t to_keyvalue(std::string const& value, key_value& kv); + static return_t to_keyvalue(const std::string& value, key_value& kv); /** * @brief keyvalue of query * @example * uri.get_query_keyvalue().foreach( - * [&](std::string const& key, std::string const& value, void* param) -> void { + * [&](const std::string& key, const std::string& value, void* param) -> void { * std::cout << key << " : " << value << std::endl; * } * ); diff --git a/sdk/net/server/network_protocol.hpp b/sdk/net/server/network_protocol.hpp index 1c593120..b168aaa9 100644 --- a/sdk/net/server/network_protocol.hpp +++ b/sdk/net/server/network_protocol.hpp @@ -36,7 +36,7 @@ enum protocol_constraints_t { enum protocol_id_t { proto_http = 2068, // RFC 2068, 2616 - proto_http2 = 7540, // RFC 7540 + proto_http2 = 7540, // RFC 7540, 9113 }; /** diff --git a/sdk/odbc/basic/odbc_query.hpp b/sdk/odbc/basic/odbc_query.hpp index 7643e9c5..c25e1983 100644 --- a/sdk/odbc/basic/odbc_query.hpp +++ b/sdk/odbc/basic/odbc_query.hpp @@ -53,7 +53,7 @@ class odbc_query { * std::string f, d; * pField->get_field_name(f); * pField->as_string(d); - * std::cout << " " << f.c_str() << " : " << d.c_str() << " " << std::endl; + * std::cout << " " << f << " : " << d << " " << std::endl; * } * } * rs->release (); diff --git a/test/base/sample.cpp b/test/base/sample.cpp index 304e8765..529394eb 100644 --- a/test/base/sample.cpp +++ b/test/base/sample.cpp @@ -97,7 +97,7 @@ void test_sharedinstance2() { void dump_data(const char* text, void* ptr, size_t size) { basic_stream bs; dump_memory((byte_t*)ptr, size, &bs, 16, 2); - std::cout << (text ? text : "") << std::endl << bs.c_str() << std::endl; + std::cout << (text ? text : "") << std::endl << bs << std::endl; } void test_convert_endian() { @@ -205,7 +205,7 @@ void test_btree() { bt.insert("t_btree"); printf("members in [ "); - bt.for_each([](std::string const& s) -> void { printf("%s ", s.c_str()); }); + bt.for_each([](const std::string& s) -> void { printf("%s ", s.c_str()); }); printf("]\n"); _test_case.assert(3 == bt.size(), __FUNCTION__, "t_btree"); @@ -216,12 +216,12 @@ void test_btree() { uint32 key; std::string value; - basedata(uint32 k, std::string const& v) : key(k), value(v) {} + basedata(uint32 k, const std::string& v) : key(k), value(v) {} basedata(const basedata& rhs) : key(rhs.key), value(rhs.value) {} }; // 1 2 3 ... struct testdata1 : basedata { - testdata1(uint32 k, std::string const& v) : basedata(k, v) {} + testdata1(uint32 k, const std::string& v) : basedata(k, v) {} testdata1(const testdata1& rhs) : basedata(rhs) {} bool operator<(const testdata1& rhs) const { @@ -237,7 +237,7 @@ void test_btree() { }; // a b c ... struct testdata2 : basedata { - testdata2(uint32 k, std::string const& v) : basedata(k, v) {} + testdata2(uint32 k, const std::string& v) : basedata(k, v) {} testdata2(const testdata2& rhs) : basedata(rhs) {} bool operator<(const testdata2& rhs) const { @@ -262,7 +262,7 @@ void test_btree() { bt.insert(testdata1(5, "five")); printf("members in [ "); - bt.for_each([](struct testdata1 const& t) -> void { printf("%u %s ", t.key, t.value.c_str()); }); + bt.for_each([](const struct testdata1& t) -> void { printf("%u %s ", t.key, t.value.c_str()); }); printf("]\n"); _test_case.assert(5 == bt.size(), __FUNCTION__, "t_btree #1"); @@ -277,7 +277,7 @@ void test_btree() { bt.insert(testdata2(5, "five")); printf("members in [ "); - bt.for_each([](struct testdata2 const& t) -> void { printf("%u %s ", t.key, t.value.c_str()); }); + bt.for_each([](const struct testdata2& t) -> void { printf("%u %s ", t.key, t.value.c_str()); }); printf("]\n"); _test_case.assert(5 == bt.size(), __FUNCTION__, "t_btree #2"); @@ -309,7 +309,7 @@ void test_btree() { _test_case.assert(15 == bt.size(), __FUNCTION__, "t_btree insert and update"); printf("members in [\n"); - bt.for_each([](testdata const& t) -> void { printf("%c %02x %zi\n", isprint(t.symbol) ? t.symbol : '?', t.symbol, t.weight); }); + bt.for_each([](const testdata& t) -> void { printf("%c %02x %zi\n", isprint(t.symbol) ? t.symbol : '?', t.symbol, t.weight); }); printf("]\n"); } } diff --git a/test/cbor/sample.cpp b/test/cbor/sample.cpp index 4389174c..09d53959 100644 --- a/test/cbor/sample.cpp +++ b/test/cbor/sample.cpp @@ -42,7 +42,7 @@ void encode_test(variant& vt, binary_t& bin, std::string expect) { base16_encode(bin, hex); - if (0 == stricmp(hex.c_str(), expect.c_str())) { + if (hex == expect) { // match } else { ret = errorcode_t::mismatch; @@ -51,8 +51,8 @@ void encode_test(variant& vt, binary_t& bin, std::string expect) { basic_stream bs; dump_memory(bin, &bs); - std::cout << "encoded " << hex.c_str() << std::endl; - std::cout << bs.c_str() << std::endl; + std::cout << "encoded " << hex << std::endl; + std::cout << bs << std::endl; } _test_case.test(ret, __FUNCTION__, "encoded %s expect %s", hex.c_str(), expect.c_str()); @@ -80,8 +80,8 @@ void cbor_test(cbor_object* root, const char* expected) { base16_encode(bin, concise); - std::cout << "diagnostic " << diagnostic.c_str() << std::endl; - std::cout << "concise " << concise.c_str() << std::endl; + std::cout << "diagnostic " << diagnostic << std::endl; + std::cout << "concise " << concise << std::endl; if (stricmp(concise.c_str(), expected)) { ret = errorcode_t::mismatch; @@ -217,7 +217,7 @@ void test_cbor_tstr(const char* value, const char* expect) { encode_test(vt, bin, expect); } -void test_cbor_bstr(binary_t const& value, const char* expect) { +void test_cbor_bstr(const binary_t& value, const char* expect) { cbor_data* cbor = new cbor_data(value); cbor_test(cbor, expect); @@ -232,7 +232,7 @@ void test_cbor_tstr_tag(const char* value, cbor_tag_t tag, const char* expect) { cbor->release(); } -void test_cbor_bstr_tag(binary_t const& value, cbor_tag_t tag, const char* expect) { +void test_cbor_bstr_tag(const binary_t& value, cbor_tag_t tag, const char* expect) { cbor_data* cbor = new cbor_data(value); cbor->tag(tag); @@ -728,7 +728,7 @@ void whatsthis(int argc, char** argv) { dump_memory(what, &bs, 16, 2); std::cout << "what u want to know" << std::endl << "< " << option.content << std::endl - << "> " << diagnostic.c_str() << std::endl + << "> " << diagnostic << std::endl << "> dump" << std::endl << bs.c_str() << std::endl; } diff --git a/test/cmdline/sample.cpp b/test/cmdline/sample.cpp index 5f04b12a..d4d717eb 100644 --- a/test/cmdline/sample.cpp +++ b/test/cmdline/sample.cpp @@ -44,8 +44,8 @@ void test1(int argc, char** argv) { } OPTION opt = cmdline.value(); - std::cout << "infile " << opt.infile.c_str() << std::endl; - std::cout << "outfile " << opt.outfile.c_str() << std::endl; + std::cout << "infile " << opt.infile << std::endl; + std::cout << "outfile " << opt.outfile << std::endl; std::cout << "keygen " << opt.keygen << std::endl; } @@ -70,8 +70,8 @@ void test_cmdline(cmdline_t