1
0

hash.inc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (C) 2014 Mellnik
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. // Hash Plugin 0.0.4
  17. #if defined _hash_included
  18. #endinput
  19. #endif
  20. #define _hash_included
  21. #define PBKDF2_LENGTH 128
  22. #define MD5_LENGTH 32
  23. #define SHA1_LENGTH 40
  24. #define SHA256_LENGTH 64
  25. #define SHA384_LENGTH 96
  26. #define SHA512_LENGTH 128
  27. #define SHA3_LENGTH 128
  28. #define WHIRLPOOL_LENGTH 128
  29. #define RIPEMD160_LENGTH 40
  30. #define RIPEMD256_LENGTH 64
  31. #define RIPEMD320_LENGTH 80
  32. // Hashing
  33. native sha256(const key[], hash[], len = sizeof(hash));
  34. native sha384(const key[], hash[], len = sizeof(hash));
  35. native sha512(const key[], hash[], len = sizeof(hash));
  36. native sha3(const key[], hash[], len = sizeof(hash));
  37. native whirlpool(const key[], hash[], len = sizeof(hash));
  38. native ripemd160(const key[], hash[], len = sizeof(hash));
  39. native ripemd256(const key[], hash[], len = sizeof(hash));
  40. native ripemd320(const key[], hash[], len = sizeof(hash));
  41. // PBKDF2
  42. native hash_generate(const key[], iterations, const callback[], const format[], {Float,_}:...);
  43. native hash_retrieve(hash[], salt[], hlen = sizeof(hash), slen = sizeof(salt));
  44. native hash_validate(const key[], const hash[], const salt[], iterations, const callback[], const format[], {Float,_}:...);
  45. native hash_is_equal();
  46. native hash_unprocessed();
  47. native hash_exec_time();
  48. native hash_thread_limit(threads);
  49. // Non-cryptographic algorithms
  50. native base64_encode(const input[], output[], len = sizeof(output));
  51. native base64_decode(const input[], output[], len = sizeof(output));
  52. native hex_encode(const input[], output[], len = sizeof(output));
  53. native hex_decode(const input[], output[], len = sizeof(output));
  54. // Pseudo random generators
  55. native random_int(min, max);
  56. native random_string(length, output[], len = sizeof(output));
  57. // Checksums
  58. native md5sum(const file[], sum[], len = sizeof(sum));
  59. native sha1sum(const file[], sum[], len = sizeof(sum));
  60. native sha256sum(const file[], sum[], len = sizeof(sum));
  61. native sha384sum(const file[], sum[], len = sizeof(sum));
  62. native sha512sum(const file[], sum[], len = sizeof(sum));
  63. native wpsum(const file[], sum[], len = sizeof(sum));
  64. // Length-constant comparison
  65. native slow_equals(const a[], const b[]);