mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 17:32:32 +00:00
error processing for RAND_bytes, style issue
This commit is contained in:
parent
2f38e7bc5c
commit
f966d69791
@ -210,7 +210,7 @@ void AuthenticationData::setPasswordHashBinary(const Digest & hash)
|
|||||||
throw Exception("setPasswordHashBinary(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED);
|
throw Exception("setPasswordHashBinary(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthenticationData::setSalt(String salt_)
|
void AuthenticationData::setSalt(String salt_)
|
||||||
{
|
{
|
||||||
if (type != AuthenticationType::SHA256_PASSWORD)
|
if (type != AuthenticationType::SHA256_PASSWORD)
|
||||||
throw Exception("setSalt(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED);
|
throw Exception("setSalt(): authentication type " + toString(type) + " not supported", ErrorCodes::NOT_IMPLEMENTED);
|
||||||
|
@ -21,10 +21,17 @@
|
|||||||
#if USE_SSL
|
#if USE_SSL
|
||||||
# include <openssl/crypto.h>
|
# include <openssl/crypto.h>
|
||||||
# include <openssl/rand.h>
|
# include <openssl/rand.h>
|
||||||
|
# include <openssl/err.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace ErrorCodes
|
||||||
|
{
|
||||||
|
extern const int OPENSSL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
bool parseRenameTo(IParserBase::Pos & pos, Expected & expected, String & new_name)
|
bool parseRenameTo(IParserBase::Pos & pos, Expected & expected, String & new_name)
|
||||||
@ -166,7 +173,9 @@ namespace
|
|||||||
///generate and add salt here
|
///generate and add salt here
|
||||||
///random generator FIPS complaint
|
///random generator FIPS complaint
|
||||||
uint8_t key[32];
|
uint8_t key[32];
|
||||||
RAND_bytes(key, sizeof(key));
|
if (RAND_bytes(key, sizeof(key)) != 1)
|
||||||
|
throw Exception(ErrorCodes::OPENSSL_ERROR, "Cannot generate salt for password. OpenSSL error code: {}", ERR_get_error());
|
||||||
|
|
||||||
String salt;
|
String salt;
|
||||||
salt.resize(sizeof(key) * 2);
|
salt.resize(sizeof(key) * 2);
|
||||||
char * buf_pos = salt.data();
|
char * buf_pos = salt.data();
|
||||||
|
Loading…
Reference in New Issue
Block a user