crypt_genhash_impl.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. /**
  19. @file include/crypt_genhash_impl.h
  20. */
  21. #ifndef CRYPT_HASHGEN_IMPL_H
  22. #define CRYPT_HASHGEN_IMPL_H
  23. #define ROUNDS_DEFAULT 5000
  24. #define ROUNDS_MIN 1000
  25. #define ROUNDS_MAX ROUNDS_DEFAULT
  26. #define MIXCHARS 32
  27. #define CRYPT_SALT_LENGTH 20
  28. #define CRYPT_MAGIC_LENGTH 3
  29. #define CRYPT_PARAM_LENGTH 13
  30. #define SHA256_HASH_LENGTH 43
  31. #define CRYPT_MAX_PASSWORD_SIZE \
  32. (CRYPT_SALT_LENGTH + SHA256_HASH_LENGTH + CRYPT_MAGIC_LENGTH + \
  33. CRYPT_PARAM_LENGTH)
  34. #define MAX_PLAINTEXT_LENGTH 256
  35. #include <stddef.h>
  36. #include "my_macros.h"
  37. int extract_user_salt(const char **salt_begin, const char **salt_end);
  38. char *my_crypt_genhash(char *ctbuffer, size_t ctbufflen, const char *plaintext,
  39. size_t plaintext_len, const char *switchsalt,
  40. const char **params, unsigned int *num_rounds = NULL);
  41. void generate_user_salt(char *buffer, int buffer_len);
  42. void xor_string(char *to, int to_len, char *pattern, int pattern_len);
  43. #endif