summaryrefslogtreecommitdiff
path: root/ext/hash/tests/hash_serialize_002.phpt
blob: 15ecf94c1e5ec2f0226bb37b396506536e3aefc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
--TEST--
Hash: serialize()/unserialize() with HASH_HMAC
--FILE--
<?php

$algos = hash_algos();
$non_crypto = ["adler32", "crc32", "crc32b", "crc32c", "fnv132", "fnv1a32", "fnv164", "fnv1a64", "joaat", "murmur3a", "murmur3c", "murmur3f", "xxh32", "xxh64", "xxh3", "xxh128"];
$key = "This is the key that I have";

foreach ($algos as $algo) {
    if (in_array($algo, $non_crypto)) {
        continue;
    }

    var_dump($algo);
    $ctx0 = hash_init($algo, HASH_HMAC, $key);
    try {
        $serial = serialize($ctx0);
        assert(is_string($serial));
    } catch (Throwable $e) {
        echo $e->getMessage(), "\n";
    }
}

echo "Done\n";
?>
--EXPECT--
string(3) "md2"
HashContext with HASH_HMAC option cannot be serialized
string(3) "md4"
HashContext with HASH_HMAC option cannot be serialized
string(3) "md5"
HashContext with HASH_HMAC option cannot be serialized
string(4) "sha1"
HashContext with HASH_HMAC option cannot be serialized
string(6) "sha224"
HashContext with HASH_HMAC option cannot be serialized
string(6) "sha256"
HashContext with HASH_HMAC option cannot be serialized
string(6) "sha384"
HashContext with HASH_HMAC option cannot be serialized
string(10) "sha512/224"
HashContext with HASH_HMAC option cannot be serialized
string(10) "sha512/256"
HashContext with HASH_HMAC option cannot be serialized
string(6) "sha512"
HashContext with HASH_HMAC option cannot be serialized
string(8) "sha3-224"
HashContext with HASH_HMAC option cannot be serialized
string(8) "sha3-256"
HashContext with HASH_HMAC option cannot be serialized
string(8) "sha3-384"
HashContext with HASH_HMAC option cannot be serialized
string(8) "sha3-512"
HashContext with HASH_HMAC option cannot be serialized
string(9) "ripemd128"
HashContext with HASH_HMAC option cannot be serialized
string(9) "ripemd160"
HashContext with HASH_HMAC option cannot be serialized
string(9) "ripemd256"
HashContext with HASH_HMAC option cannot be serialized
string(9) "ripemd320"
HashContext with HASH_HMAC option cannot be serialized
string(9) "whirlpool"
HashContext with HASH_HMAC option cannot be serialized
string(10) "tiger128,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "tiger160,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "tiger192,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "tiger128,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "tiger160,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "tiger192,4"
HashContext with HASH_HMAC option cannot be serialized
string(6) "snefru"
HashContext with HASH_HMAC option cannot be serialized
string(9) "snefru256"
HashContext with HASH_HMAC option cannot be serialized
string(4) "gost"
HashContext with HASH_HMAC option cannot be serialized
string(11) "gost-crypto"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval128,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval160,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval192,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval224,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval256,3"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval128,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval160,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval192,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval224,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval256,4"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval128,5"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval160,5"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval192,5"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval224,5"
HashContext with HASH_HMAC option cannot be serialized
string(10) "haval256,5"
HashContext with HASH_HMAC option cannot be serialized
Done