diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-crypto.c | 144 |
1 files changed, 107 insertions, 37 deletions
diff --git a/src/core/wee-crypto.c b/src/core/wee-crypto.c index 3b86f5def..77d1629c9 100644 --- a/src/core/wee-crypto.c +++ b/src/core/wee-crypto.c @@ -42,9 +42,29 @@ char *weecrypto_hash_algo_string[] = { "crc32", "md5", "sha1", - "sha224", "sha256", "sha384", "sha512", + "sha224", + "sha256", + "sha384", + "sha512", #if GCRYPT_VERSION_NUMBER >= 0x010700 - "sha3-224", "sha3-256", "sha3-384", "sha3-512", + "sha3-224", + "sha3-256", + "sha3-384", + "sha3-512", +#endif +#if GCRYPT_VERSION_NUMBER >= 0x010800 + "blake2b-160", + "blake2b-256", + "blake2b-384", + "blake2b-512", + "blake2s-128", + "blake2s-160", + "blake2s-224", + "blake2s-256", +#endif +#if GCRYPT_VERSION_NUMBER >= 0x010904 + "sha512-224", + "sha512-256", #endif NULL, }; @@ -52,9 +72,29 @@ int weecrypto_hash_algo[] = { GCRY_MD_CRC32, GCRY_MD_MD5, GCRY_MD_SHA1, - GCRY_MD_SHA224, GCRY_MD_SHA256, GCRY_MD_SHA384, GCRY_MD_SHA512, + GCRY_MD_SHA224, + GCRY_MD_SHA256, + GCRY_MD_SHA384, + GCRY_MD_SHA512, #if GCRYPT_VERSION_NUMBER >= 0x010700 - GCRY_MD_SHA3_224, GCRY_MD_SHA3_256, GCRY_MD_SHA3_384, GCRY_MD_SHA3_512, + GCRY_MD_SHA3_224, + GCRY_MD_SHA3_256, + GCRY_MD_SHA3_384, + GCRY_MD_SHA3_512, +#endif +#if GCRYPT_VERSION_NUMBER >= 0x010800 + GCRY_MD_BLAKE2B_160, + GCRY_MD_BLAKE2B_256, + GCRY_MD_BLAKE2B_384, + GCRY_MD_BLAKE2B_512, + GCRY_MD_BLAKE2S_128, + GCRY_MD_BLAKE2S_160, + GCRY_MD_BLAKE2S_224, + GCRY_MD_BLAKE2S_256, +#endif +#if GCRYPT_VERSION_NUMBER >= 0x010904 + GCRY_MD_SHA512_224, + GCRY_MD_SHA512_256, #endif }; @@ -85,17 +125,27 @@ weecrypto_get_hash_algo (const char *hash_algo) * * The hash size depends on the algorithm, common ones are: * - * GCRY_MD_CRC32 32 bits == 4 bytes - * GCRY_MD_MD5 128 bits == 16 bytes - * GCRY_MD_SHA1 160 bits == 20 bytes - * GCRY_MD_SHA224 224 bits == 28 bytes - * GCRY_MD_SHA256 256 bits == 32 bytes - * GCRY_MD_SHA384 384 bits == 48 bytes - * GCRY_MD_SHA512 512 bits == 64 bytes - * GCRY_MD_SHA3_224 224 bits == 28 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_256 256 bits == 32 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_384 384 bits == 48 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_512 512 bits == 64 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_CRC32 32 bits == 4 bytes + * GCRY_MD_MD5 128 bits == 16 bytes + * GCRY_MD_SHA1 160 bits == 20 bytes + * GCRY_MD_SHA224 224 bits == 28 bytes + * GCRY_MD_SHA256 256 bits == 32 bytes + * GCRY_MD_SHA384 384 bits == 48 bytes + * GCRY_MD_SHA512 512 bits == 64 bytes + * GCRY_MD_SHA512_256 256 bits == 32 bytes (libgcrypt ≥ 1.9.4) + * GCRY_MD_SHA512_224 224 bits == 28 bytes (libgcrypt ≥ 1.9.4) + * GCRY_MD_SHA3_224 224 bits == 28 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_256 256 bits == 32 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_384 384 bits == 48 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_512 512 bits == 64 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_BLAKE2B_160 160 bits == 20 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_256 256 bits == 32 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_384 384 bits == 48 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_512 512 bits == 64 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_128 128 bits == 16 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_160 160 bits == 20 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_224 224 bits == 28 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_256 256 bits == 32 bytes (libgcrypt ≥ 1.8.0) * * The result hash is stored in "hash" (the buffer must be large enough). * @@ -165,17 +215,27 @@ hash_end: * * The hash size depends on the algorithm, common ones are: * - * GCRY_MD_CRC32 32 bits == 4 bytes - * GCRY_MD_MD5 128 bits == 16 bytes - * GCRY_MD_SHA1 160 bits == 20 bytes - * GCRY_MD_SHA224 224 bits == 28 bytes - * GCRY_MD_SHA256 256 bits == 32 bytes - * GCRY_MD_SHA384 384 bits == 48 bytes - * GCRY_MD_SHA512 512 bits == 64 bytes - * GCRY_MD_SHA3_224 224 bits == 28 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_256 256 bits == 32 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_384 384 bits == 48 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_512 512 bits == 64 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_CRC32 32 bits == 4 bytes + * GCRY_MD_MD5 128 bits == 16 bytes + * GCRY_MD_SHA1 160 bits == 20 bytes + * GCRY_MD_SHA224 224 bits == 28 bytes + * GCRY_MD_SHA256 256 bits == 32 bytes + * GCRY_MD_SHA384 384 bits == 48 bytes + * GCRY_MD_SHA512 512 bits == 64 bytes + * GCRY_MD_SHA512_224 224 bits == 28 bytes (libgcrypt ≥ 1.9.4) + * GCRY_MD_SHA512_256 256 bits == 32 bytes (libgcrypt ≥ 1.9.4) + * GCRY_MD_SHA3_224 224 bits == 28 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_256 256 bits == 32 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_384 384 bits == 48 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_512 512 bits == 64 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_BLAKE2B_160 160 bits == 20 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_256 256 bits == 32 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_384 384 bits == 48 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_512 512 bits == 64 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_128 128 bits == 16 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_160 160 bits == 20 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_224 224 bits == 28 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_256 256 bits == 32 bytes (libgcrypt ≥ 1.8.0) * * The result hash is stored in "hash" (the buffer must be large enough). * @@ -322,17 +382,27 @@ hash_pbkdf2_end: * * The hash size depends on the algorithm, common ones are: * - * GCRY_MD_CRC32 32 bits == 4 bytes - * GCRY_MD_MD5 128 bits == 16 bytes - * GCRY_MD_SHA1 160 bits == 20 bytes - * GCRY_MD_SHA224 224 bits == 28 bytes - * GCRY_MD_SHA256 256 bits == 32 bytes - * GCRY_MD_SHA384 384 bits == 48 bytes - * GCRY_MD_SHA512 512 bits == 64 bytes - * GCRY_MD_SHA3_224 224 bits == 28 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_256 256 bits == 32 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_384 384 bits == 48 bytes (libgcrypt ≥ 1.7.0) - * GCRY_MD_SHA3_512 512 bits == 64 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_CRC32 32 bits == 4 bytes + * GCRY_MD_MD5 128 bits == 16 bytes + * GCRY_MD_SHA1 160 bits == 20 bytes + * GCRY_MD_SHA224 224 bits == 28 bytes + * GCRY_MD_SHA256 256 bits == 32 bytes + * GCRY_MD_SHA384 384 bits == 48 bytes + * GCRY_MD_SHA512 512 bits == 64 bytes + * GCRY_MD_SHA512_224 224 bits == 28 bytes (libgcrypt ≥ 1.9.4) + * GCRY_MD_SHA512_256 256 bits == 32 bytes (libgcrypt ≥ 1.9.4) + * GCRY_MD_SHA3_224 224 bits == 28 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_256 256 bits == 32 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_384 384 bits == 48 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_SHA3_512 512 bits == 64 bytes (libgcrypt ≥ 1.7.0) + * GCRY_MD_BLAKE2B_160 160 bits == 20 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_256 256 bits == 32 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_384 384 bits == 48 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2B_512 512 bits == 64 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_128 128 bits == 16 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_160 160 bits == 20 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_224 224 bits == 28 bytes (libgcrypt ≥ 1.8.0) + * GCRY_MD_BLAKE2S_256 256 bits == 32 bytes (libgcrypt ≥ 1.8.0) * * The result hash is stored in "hash" (the buffer must be large enough). * |