mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 20:43:02 +01:00
Added sha3 support for the built-in function CRYPT_HASH()
Added support for sha3_224, sha3_256, sha3_384, sha3_512 for the built-in CRYPT_HASH() function
This commit is contained in:
parent
47e621b115
commit
167d28f188
@ -371,7 +371,7 @@ Function:
|
|||||||
Format:
|
Format:
|
||||||
CRYPT_HASH( <any value> USING <algorithm> )
|
CRYPT_HASH( <any value> USING <algorithm> )
|
||||||
|
|
||||||
algorithm ::= { MD5 | SHA1 | SHA256 | SHA512 }
|
algorithm ::= { MD5 | SHA1 | SHA256 | SHA512 | SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 }
|
||||||
|
|
||||||
Important:
|
Important:
|
||||||
- This function returns VARCHAR strings with OCTETS charset with length depended on algorithm.
|
- This function returns VARCHAR strings with OCTETS charset with length depended on algorithm.
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#define LTC_NO_HASHES
|
#define LTC_NO_HASHES
|
||||||
#define LTC_MD5
|
#define LTC_MD5
|
||||||
#define LTC_SHA1
|
#define LTC_SHA1
|
||||||
|
#define LTC_SHA3
|
||||||
#define LTC_SHA256
|
#define LTC_SHA256
|
||||||
#define LTC_SHA512
|
#define LTC_SHA512
|
||||||
#define LTC_HASH_HELPERS
|
#define LTC_HASH_HELPERS
|
||||||
|
@ -401,6 +401,30 @@ namespace Firebird
|
|||||||
Sha1HashContext(MemoryPool& pool);
|
Sha1HashContext(MemoryPool& pool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Sha3_512_HashContext final : public LibTomCryptHashContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sha3_512_HashContext(MemoryPool& pool);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Sha3_384_HashContext final : public LibTomCryptHashContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sha3_384_HashContext(MemoryPool& pool);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Sha3_256_HashContext final : public LibTomCryptHashContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sha3_256_HashContext(MemoryPool& pool);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Sha3_224_HashContext final : public LibTomCryptHashContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sha3_224_HashContext(MemoryPool& pool);
|
||||||
|
};
|
||||||
|
|
||||||
class Sha256HashContext final : public LibTomCryptHashContext
|
class Sha256HashContext final : public LibTomCryptHashContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -87,6 +87,33 @@ Sha1HashContext::Sha1HashContext(MemoryPool& pool)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LibTomCryptHashContext::Descriptor sha3_512_Descriptor{&sha3_512_desc};
|
||||||
|
|
||||||
|
Sha3_512_HashContext::Sha3_512_HashContext(MemoryPool& pool)
|
||||||
|
: LibTomCryptHashContext(pool, &sha3_512_Descriptor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static LibTomCryptHashContext::Descriptor sha3_384_Descriptor{&sha3_384_desc};
|
||||||
|
|
||||||
|
Sha3_384_HashContext::Sha3_384_HashContext(MemoryPool& pool)
|
||||||
|
: LibTomCryptHashContext(pool, &sha3_384_Descriptor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static LibTomCryptHashContext::Descriptor sha3_256_Descriptor{&sha3_256_desc};
|
||||||
|
|
||||||
|
Sha3_256_HashContext::Sha3_256_HashContext(MemoryPool& pool)
|
||||||
|
: LibTomCryptHashContext(pool, &sha3_256_Descriptor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static LibTomCryptHashContext::Descriptor sha3_224_Descriptor{&sha3_224_desc};
|
||||||
|
|
||||||
|
Sha3_224_HashContext::Sha3_224_HashContext(MemoryPool& pool)
|
||||||
|
: LibTomCryptHashContext(pool, &sha3_224_Descriptor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static LibTomCryptHashContext::Descriptor sha256Descriptor{&sha256_desc};
|
static LibTomCryptHashContext::Descriptor sha256Descriptor{&sha256_desc};
|
||||||
|
|
||||||
|
@ -163,6 +163,10 @@ static const HashAlgorithmDescriptor* cryptHashAlgorithmDescriptors[] = {
|
|||||||
HashAlgorithmDescriptorFactory<Sha1HashContext>::getInstance("SHA1", 20),
|
HashAlgorithmDescriptorFactory<Sha1HashContext>::getInstance("SHA1", 20),
|
||||||
HashAlgorithmDescriptorFactory<Sha256HashContext>::getInstance("SHA256", 32),
|
HashAlgorithmDescriptorFactory<Sha256HashContext>::getInstance("SHA256", 32),
|
||||||
HashAlgorithmDescriptorFactory<Sha512HashContext>::getInstance("SHA512", 64),
|
HashAlgorithmDescriptorFactory<Sha512HashContext>::getInstance("SHA512", 64),
|
||||||
|
HashAlgorithmDescriptorFactory<Sha3_512_HashContext>::getInstance("SHA3_512", 64),
|
||||||
|
HashAlgorithmDescriptorFactory<Sha3_384_HashContext>::getInstance("SHA3_384", 48),
|
||||||
|
HashAlgorithmDescriptorFactory<Sha3_256_HashContext>::getInstance("SHA3_256", 32),
|
||||||
|
HashAlgorithmDescriptorFactory<Sha3_224_HashContext>::getInstance("SHA3_224", 28),
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2964,6 +2968,10 @@ public:
|
|||||||
|
|
||||||
registerHash(md5_desc);
|
registerHash(md5_desc);
|
||||||
registerHash(sha1_desc);
|
registerHash(sha1_desc);
|
||||||
|
registerHash(sha3_512_desc);
|
||||||
|
registerHash(sha3_384_desc);
|
||||||
|
registerHash(sha3_256_desc);
|
||||||
|
registerHash(sha3_224_desc);
|
||||||
registerHash(sha256_desc);
|
registerHash(sha256_desc);
|
||||||
registerHash(sha512_desc);
|
registerHash(sha512_desc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user