core: add support of CRC32 algorithm in hash functions

v2.8-utf8proc
Sébastien Helleu 2020-02-29 21:12:13 +01:00
parent 410a5b341f
commit 7449bc8827
8 changed files with 17 additions and 0 deletions

View File

@ -2090,6 +2090,7 @@ Supported hash algorithms:
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Value | Algorithm | Hash size | Output (binary) | Notes
| `+crc32+` | CRC32 | 32 bits | 4 bytes | Not a hash algorithm in the cryptographic sense.
| `+md5+` | MD5 | 128 bits | 16 bytes | *Weak*, not recommended for cryptography usage.
| `+sha1+` | SHA-1 | 160 bits | 20 bytes | *Weak*, not recommended for cryptography usage.
| `+sha224+` | SHA-224 | 224 bits | 28 bytes |
@ -2141,6 +2142,7 @@ Supported hash algorithms:
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Value | Algorithm | Hash size | Output (string) | Notes
| `+crc32+` | CRC32 | 32 bits | 8 hex chars | Not a hash algorithm in the cryptographic sense.
| `+md5+` | MD5 | 128 bits | 32 hex chars | *Weak*, not recommended for cryptography usage.
| `+sha1+` | SHA-1 | 160 bits | 40 hex chars | *Weak*, not recommended for cryptography usage.
| `+sha224+` | SHA-224 | 224 bits | 56 hex chars |

View File

@ -2128,6 +2128,7 @@ Algorithmes de hachage supportés :
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Valeur | Algorithme | Taille du haché | Sortie (binaire) | Notes
| `+crc32+` | CRC32 | 32 bits | 4 octets | Pas un algorithme de hachage au sens cryptographique.
| `+md5+` | MD5 | 128 bits | 16 octets | *Faible*, non recommandé pour un usage cryptographique.
| `+sha1+` | SHA-1 | 160 bits | 20 octets | *Faible*, non recommandé pour un usage cryptographique.
| `+sha224+` | SHA-224 | 224 bits | 28 octets |
@ -2179,6 +2180,7 @@ Algorithmes de hachage supportés :
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Valeur | Algorithme | Taille du haché | Sortie (chaîne) | Notes
| `+crc32+` | CRC32 | 32 bits | 8 caractères hexa | Pas un algorithme de hachage au sens cryptographique.
| `+md5+` | MD5 | 128 bits | 32 caractères hexa | *Faible*, non recommandé pour un usage cryptographique.
| `+sha1+` | SHA-1 | 160 bits | 40 caractères hexa | *Faible*, non recommandé pour un usage cryptographique.
| `+sha224+` | SHA-224 | 224 bits | 56 caractères hexa |

View File

@ -2182,6 +2182,7 @@ Supported hash algorithms:
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Value | Algorithm | Hash size | Output (binary) | Notes
| `+crc32+` | CRC32 | 32 bits | 4 bytes | Not a hash algorithm in the cryptographic sense.
| `+md5+` | MD5 | 128 bits | 16 bytes | *Weak*, not recommended for cryptography usage.
| `+sha1+` | SHA-1 | 160 bits | 20 bytes | *Weak*, not recommended for cryptography usage.
| `+sha224+` | SHA-224 | 224 bits | 28 bytes |
@ -2234,6 +2235,7 @@ Supported hash algorithms:
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Value | Algorithm | Hash size | Output (string) | Notes
| `+crc32+` | CRC32 | 32 bits | 8 hex chars | Not a hash algorithm in the cryptographic sense.
| `+md5+` | MD5 | 128 bits | 32 hex chars | *Weak*, not recommended for cryptography usage.
| `+sha1+` | SHA-1 | 160 bits | 40 hex chars | *Weak*, not recommended for cryptography usage.
| `+sha224+` | SHA-224 | 224 bits | 56 hex chars |

View File

@ -2104,6 +2104,7 @@ Supported hash algorithms:
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Value | Algorithm | Hash size | Output (binary) | Notes
| `+crc32+` | CRC32 | 32 bits | 4 bytes | Not a hash algorithm in the cryptographic sense.
| `+md5+` | MD5 | 128 bits | 16 bytes | *Weak*, not recommended for cryptography usage.
| `+sha1+` | SHA-1 | 160 bits | 20 bytes | *Weak*, not recommended for cryptography usage.
| `+sha224+` | SHA-224 | 224 bits | 28 bytes |
@ -2156,6 +2157,7 @@ Supported hash algorithms:
[width="100%",cols="4,4,4,5,12",options="header"]
|===
| Value | Algorithm | Hash size | Output (string) | Notes
| `+crc32+` | CRC32 | 32 bits | 8 hex chars | Not a hash algorithm in the cryptographic sense.
| `+md5+` | MD5 | 128 bits | 32 hex chars | *Weak*, not recommended for cryptography usage.
| `+sha1+` | SHA-1 | 160 bits | 40 hex chars | *Weak*, not recommended for cryptography usage.
| `+sha224+` | SHA-224 | 224 bits | 56 hex chars |

View File

@ -66,6 +66,7 @@
c - '0')
char *string_hash_algo_string[] = {
"crc32",
"md5",
"sha1",
"sha224", "sha256", "sha384", "sha512",
@ -73,6 +74,7 @@ char *string_hash_algo_string[] = {
NULL,
};
int string_hash_algo[] = {
GCRY_MD_CRC32,
GCRY_MD_MD5,
GCRY_MD_SHA1,
GCRY_MD_SHA224, GCRY_MD_SHA256, GCRY_MD_SHA384, GCRY_MD_SHA512,

View File

@ -120,6 +120,9 @@ TEST(CoreSecure, Hash)
WEE_CHECK_HASH_BIN(NULL, "test", 0, 0);
WEE_CHECK_HASH_HEX(NULL, "test", 0, 0);
WEE_CHECK_HASH_BIN(DATA_HASH_CRC32, data, length, GCRY_MD_CRC32);
WEE_CHECK_HASH_HEX(DATA_HASH_CRC32, data, length, GCRY_MD_CRC32);
WEE_CHECK_HASH_BIN(DATA_HASH_MD5, data, length, GCRY_MD_MD5);
WEE_CHECK_HASH_HEX(DATA_HASH_MD5, data, length, GCRY_MD_MD5);

View File

@ -1978,6 +1978,9 @@ TEST(CoreString, Hash)
WEE_CHECK_HASH_BIN(NULL, DATA_HASH, length, "not_an_algo");
WEE_CHECK_HASH_HEX(NULL, DATA_HASH, length, "not_an_algo");
WEE_CHECK_HASH_BIN(DATA_HASH_CRC32, data, length, "crc32");
WEE_CHECK_HASH_HEX(DATA_HASH_CRC32, data, length, "crc32");
WEE_CHECK_HASH_BIN(DATA_HASH_MD5, data, length, "md5");
WEE_CHECK_HASH_HEX(DATA_HASH_MD5, data, length, "md5");

View File

@ -21,6 +21,7 @@
#define WEECHAT_TEST_UNIT_CORE_H
#define DATA_HASH "this is a test of hash function"
#define DATA_HASH_CRC32 "ef26fe3e"
#define DATA_HASH_MD5 "1197d121af621ac6a63cb8ef6b5dfa30"
#define DATA_HASH_SHA1 "799d818061175b400dc5aaeb14b8d32cdef32ff0"
#define DATA_HASH_SHA224 "637d21f3ba3f4e9fa9fb889dc990b31a658cb37b4aefb5144" \