You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

catena.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  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. #ifndef SRC_LIBCRYPTOBOX_CATENA_CATENA_H_
  17. #define SRC_LIBCRYPTOBOX_CATENA_CATENA_H_
  18. /* Modes */
  19. #define PASSWORD_HASHING_MODE 0
  20. #define KEY_DERIVATION_MODE 1
  21. #define REGULAR 0
  22. #define CLIENT 1
  23. #define CATENA_HLEN 64
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. int catena(const uint8_t *pwd, const uint32_t pwdlen,
  28. const uint8_t *salt, const uint8_t saltlen,
  29. const uint8_t *data, const uint32_t datalen,
  30. const uint8_t lambda, const uint8_t min_garlic,
  31. const uint8_t garlic, const uint8_t hashlen, uint8_t *hash);
  32. /**
  33. * Simple interface for catena PBKDF
  34. * @param pwd password
  35. * @param pwdlen length of password
  36. * @param salt salt
  37. * @param saltlen length of salt
  38. * @param data additional data
  39. * @param datalen length of additional data
  40. * @param hash output hash
  41. * @return 0 if hash is generated, -1 in case of error
  42. */
  43. int simple_catena(const uint8_t *pwd, const uint32_t pwdlen,
  44. const uint8_t *salt, const uint8_t saltlen,
  45. const uint8_t *data, const uint32_t datalen,
  46. uint8_t hash[CATENA_HLEN]);
  47. /**
  48. * Run a quick test on catena implementation
  49. */
  50. int catena_test(void);
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif /* SRC_LIBCRYPTOBOX_CATENA_CATENA_H_ */