token_info.h 581 B

123456789101112131415161718192021222324
  1. #pragma once
  2. #include <inttypes.h>
  3. typedef enum { SHA1, SHA256, SHA512 } TokenHashAlgo;
  4. typedef enum { TOTP_6_DIGITS, TOTP_8_DIGITS } TokenDigitsCount;
  5. typedef struct {
  6. uint8_t* token;
  7. uint8_t token_length;
  8. char* name;
  9. TokenHashAlgo algo;
  10. TokenDigitsCount digits;
  11. } TokenInfo;
  12. TokenInfo* token_info_alloc();
  13. void token_info_free(TokenInfo* token_info);
  14. bool token_info_set_secret(
  15. TokenInfo* token_info,
  16. const char* base32_token_secret,
  17. uint8_t token_secret_length,
  18. uint8_t* iv);
  19. uint8_t token_info_get_digits_count(TokenInfo* token_info);