hash_serialize_002.phpt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. --TEST--
  2. Hash: serialize()/unserialize() with HASH_HMAC
  3. --FILE--
  4. <?php
  5. $algos = hash_algos();
  6. $non_crypto = ["adler32", "crc32", "crc32b", "crc32c", "fnv132", "fnv1a32", "fnv164", "fnv1a64", "joaat", "murmur3a", "murmur3c", "murmur3f", "xxh32", "xxh64", "xxh3", "xxh128"];
  7. $key = "This is the key that I have";
  8. foreach ($algos as $algo) {
  9. if (in_array($algo, $non_crypto)) {
  10. continue;
  11. }
  12. var_dump($algo);
  13. $ctx0 = hash_init($algo, HASH_HMAC, $key);
  14. try {
  15. $serial = serialize($ctx0);
  16. assert(is_string($serial));
  17. } catch (Throwable $e) {
  18. echo $e->getMessage(), "\n";
  19. }
  20. }
  21. echo "Done\n";
  22. ?>
  23. --EXPECT--
  24. string(3) "md2"
  25. HashContext with HASH_HMAC option cannot be serialized
  26. string(3) "md4"
  27. HashContext with HASH_HMAC option cannot be serialized
  28. string(3) "md5"
  29. HashContext with HASH_HMAC option cannot be serialized
  30. string(4) "sha1"
  31. HashContext with HASH_HMAC option cannot be serialized
  32. string(6) "sha224"
  33. HashContext with HASH_HMAC option cannot be serialized
  34. string(6) "sha256"
  35. HashContext with HASH_HMAC option cannot be serialized
  36. string(6) "sha384"
  37. HashContext with HASH_HMAC option cannot be serialized
  38. string(10) "sha512/224"
  39. HashContext with HASH_HMAC option cannot be serialized
  40. string(10) "sha512/256"
  41. HashContext with HASH_HMAC option cannot be serialized
  42. string(6) "sha512"
  43. HashContext with HASH_HMAC option cannot be serialized
  44. string(8) "sha3-224"
  45. HashContext with HASH_HMAC option cannot be serialized
  46. string(8) "sha3-256"
  47. HashContext with HASH_HMAC option cannot be serialized
  48. string(8) "sha3-384"
  49. HashContext with HASH_HMAC option cannot be serialized
  50. string(8) "sha3-512"
  51. HashContext with HASH_HMAC option cannot be serialized
  52. string(9) "ripemd128"
  53. HashContext with HASH_HMAC option cannot be serialized
  54. string(9) "ripemd160"
  55. HashContext with HASH_HMAC option cannot be serialized
  56. string(9) "ripemd256"
  57. HashContext with HASH_HMAC option cannot be serialized
  58. string(9) "ripemd320"
  59. HashContext with HASH_HMAC option cannot be serialized
  60. string(9) "whirlpool"
  61. HashContext with HASH_HMAC option cannot be serialized
  62. string(10) "tiger128,3"
  63. HashContext with HASH_HMAC option cannot be serialized
  64. string(10) "tiger160,3"
  65. HashContext with HASH_HMAC option cannot be serialized
  66. string(10) "tiger192,3"
  67. HashContext with HASH_HMAC option cannot be serialized
  68. string(10) "tiger128,4"
  69. HashContext with HASH_HMAC option cannot be serialized
  70. string(10) "tiger160,4"
  71. HashContext with HASH_HMAC option cannot be serialized
  72. string(10) "tiger192,4"
  73. HashContext with HASH_HMAC option cannot be serialized
  74. string(6) "snefru"
  75. HashContext with HASH_HMAC option cannot be serialized
  76. string(9) "snefru256"
  77. HashContext with HASH_HMAC option cannot be serialized
  78. string(4) "gost"
  79. HashContext with HASH_HMAC option cannot be serialized
  80. string(11) "gost-crypto"
  81. HashContext with HASH_HMAC option cannot be serialized
  82. string(10) "haval128,3"
  83. HashContext with HASH_HMAC option cannot be serialized
  84. string(10) "haval160,3"
  85. HashContext with HASH_HMAC option cannot be serialized
  86. string(10) "haval192,3"
  87. HashContext with HASH_HMAC option cannot be serialized
  88. string(10) "haval224,3"
  89. HashContext with HASH_HMAC option cannot be serialized
  90. string(10) "haval256,3"
  91. HashContext with HASH_HMAC option cannot be serialized
  92. string(10) "haval128,4"
  93. HashContext with HASH_HMAC option cannot be serialized
  94. string(10) "haval160,4"
  95. HashContext with HASH_HMAC option cannot be serialized
  96. string(10) "haval192,4"
  97. HashContext with HASH_HMAC option cannot be serialized
  98. string(10) "haval224,4"
  99. HashContext with HASH_HMAC option cannot be serialized
  100. string(10) "haval256,4"
  101. HashContext with HASH_HMAC option cannot be serialized
  102. string(10) "haval128,5"
  103. HashContext with HASH_HMAC option cannot be serialized
  104. string(10) "haval160,5"
  105. HashContext with HASH_HMAC option cannot be serialized
  106. string(10) "haval192,5"
  107. HashContext with HASH_HMAC option cannot be serialized
  108. string(10) "haval224,5"
  109. HashContext with HASH_HMAC option cannot be serialized
  110. string(10) "haval256,5"
  111. HashContext with HASH_HMAC option cannot be serialized
  112. Done