token_info.h 630 B

1234567891011121314151617181920212223242526
  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. #define TOTP_TOKEN_DIGITS_MAX_COUNT 8
  6. typedef struct {
  7. uint8_t* token;
  8. size_t token_length;
  9. char* name;
  10. TokenHashAlgo algo;
  11. TokenDigitsCount digits;
  12. } TokenInfo;
  13. TokenInfo* token_info_alloc();
  14. void token_info_free(TokenInfo* token_info);
  15. bool token_info_set_secret(
  16. TokenInfo* token_info,
  17. const char* base32_token_secret,
  18. size_t token_secret_length,
  19. const uint8_t* iv);
  20. uint8_t token_info_get_digits_count(const TokenInfo* token_info);