aboutsummaryrefslogtreecommitdiff
path: root/src/common/Cryptography
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Cryptography')
-rw-r--r--src/common/Cryptography/AES.h5
-rw-r--r--src/common/Cryptography/ARC4.h5
-rw-r--r--src/common/Cryptography/Argon2.h25
-rw-r--r--src/common/Cryptography/CryptoGenerics.h10
-rw-r--r--src/common/Cryptography/TOTP.h19
5 files changed, 23 insertions, 41 deletions
diff --git a/src/common/Cryptography/AES.h b/src/common/Cryptography/AES.h
index e559be75a16..b7ff64c11d0 100644
--- a/src/common/Cryptography/AES.h
+++ b/src/common/Cryptography/AES.h
@@ -22,9 +22,7 @@
#include <array>
#include <openssl/evp.h>
-namespace Trinity
-{
-namespace Crypto
+namespace Trinity::Crypto
{
class TC_COMMON_API AES
{
@@ -50,6 +48,5 @@ namespace Crypto
bool _encrypting;
};
}
-}
#endif // Trinity_AES_h__
diff --git a/src/common/Cryptography/ARC4.h b/src/common/Cryptography/ARC4.h
index 8d5b89787e9..5ce2db5aa3b 100644
--- a/src/common/Cryptography/ARC4.h
+++ b/src/common/Cryptography/ARC4.h
@@ -22,9 +22,7 @@
#include <array>
#include <openssl/evp.h>
-namespace Trinity
-{
-namespace Crypto
+namespace Trinity::Crypto
{
class TC_COMMON_API ARC4
{
@@ -43,6 +41,5 @@ namespace Crypto
EVP_CIPHER_CTX* _ctx;
};
}
-}
#endif
diff --git a/src/common/Cryptography/Argon2.h b/src/common/Cryptography/Argon2.h
index 06f1c6398aa..2c1d44d10d7 100644
--- a/src/common/Cryptography/Argon2.h
+++ b/src/common/Cryptography/Argon2.h
@@ -23,22 +23,19 @@
#include "Optional.h"
#include <string>
-namespace Trinity
+namespace Trinity::Crypto
{
-namespace Crypto
-{
-struct TC_COMMON_API Argon2
-{
- static constexpr uint32 HASH_LEN = 16; // 128 bits, in bytes
- static constexpr uint32 ENCODED_HASH_LEN = 100; // in chars
- static constexpr uint32 DEFAULT_ITERATIONS = 10; // determined by dice roll, guaranteed to be secure (not really)
- static constexpr uint32 DEFAULT_MEMORY_COST = (1u << 17); // 2^17 kibibytes is 2^7 mebibytes is ~100MB
- static constexpr uint32 PARALLELISM = 1; // we don't support threaded hashing
+ struct TC_COMMON_API Argon2
+ {
+ static constexpr uint32 HASH_LEN = 16; // 128 bits, in bytes
+ static constexpr uint32 ENCODED_HASH_LEN = 100; // in chars
+ static constexpr uint32 DEFAULT_ITERATIONS = 10; // determined by dice roll, guaranteed to be secure (not really)
+ static constexpr uint32 DEFAULT_MEMORY_COST = (1u << 17); // 2^17 kibibytes is 2^7 mebibytes is ~100MB
+ static constexpr uint32 PARALLELISM = 1; // we don't support threaded hashing
- static Optional<std::string> Hash(std::string const& password, BigNumber const& salt, uint32 nIterations = DEFAULT_ITERATIONS, uint32 kibMemoryCost = DEFAULT_MEMORY_COST);
- static bool Verify(std::string const& password, std::string const& hash);
-};
-}
+ static Optional<std::string> Hash(std::string const& password, BigNumber const& salt, uint32 nIterations = DEFAULT_ITERATIONS, uint32 kibMemoryCost = DEFAULT_MEMORY_COST);
+ static bool Verify(std::string const& password, std::string const& hash);
+ };
}
#endif
diff --git a/src/common/Cryptography/CryptoGenerics.h b/src/common/Cryptography/CryptoGenerics.h
index affa11bf79d..75ad443b32a 100644
--- a/src/common/Cryptography/CryptoGenerics.h
+++ b/src/common/Cryptography/CryptoGenerics.h
@@ -25,9 +25,7 @@
#include <iterator>
#include <vector>
-namespace Trinity
-{
-namespace Impl
+namespace Trinity::Impl
{
struct CryptoGenericsImpl
{
@@ -57,11 +55,8 @@ namespace Impl
}
};
}
-}
-namespace Trinity
-{
-namespace Crypto
+namespace Trinity::Crypto
{
template <typename Cipher>
void AEEncryptWithRandomIV(std::vector<uint8>& data, typename Cipher::Key const& key)
@@ -112,6 +107,5 @@ namespace Crypto
return AEDecrypt<Cipher>(data, key.ToByteArray<Cipher::KEY_SIZE_BYTES>());
}
}
-}
#endif
diff --git a/src/common/Cryptography/TOTP.h b/src/common/Cryptography/TOTP.h
index 02e5b9adffc..0aba8ff867e 100644
--- a/src/common/Cryptography/TOTP.h
+++ b/src/common/Cryptography/TOTP.h
@@ -22,19 +22,16 @@
#include <ctime>
#include <vector>
-namespace Trinity
+namespace Trinity::Crypto
{
-namespace Crypto
-{
-struct TC_COMMON_API TOTP
-{
- static constexpr std::size_t RECOMMENDED_SECRET_LENGTH = 20;
- using Secret = std::vector<uint8>;
+ struct TC_COMMON_API TOTP
+ {
+ static constexpr size_t RECOMMENDED_SECRET_LENGTH = 20;
+ using Secret = std::vector<uint8>;
- static uint32 GenerateToken(Secret const& key, time_t timestamp);
- static bool ValidateToken(Secret const& key, uint32 token);
-};
-}
+ static uint32 GenerateToken(Secret const& key, time_t timestamp);
+ static bool ValidateToken(Secret const& key, uint32 token);
+ };
}
#endif