Coverage Report

Created: 2026-06-07 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tdengine/source/libs/totp/src/totp.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15
#define _DEFAULT_SOURCE
16
#include <stdio.h>
17
#include <stdint.h>
18
#include <string.h>
19
20
// formatTotp formats the TOTP code with leading zeros to match the specified digit length.
21
0
int taosFormatTotp(int32_t totp, int digits, char *buffer, size_t size) {
22
0
  return snprintf(buffer, size, "%0*d", digits, totp);
23
0
}
24
25
#ifndef TD_ENTERPRISE
26
27
0
int32_t taosGenerateTotpCode(const uint8_t *secret, size_t secretLen, int digits) {
28
0
  return 0;
29
0
}
30
31
0
int taosVerifyTotpCode(const uint8_t *secret, size_t secretLen, int32_t userCode, int digits, int window) {
32
0
  return 1;
33
0
}
34
35
0
int taosGenerateTotpSecret(const char *seed, size_t seedLen, uint8_t *secret, size_t secretLen) {
36
0
  memset(secret, 0, secretLen);
37
0
  return secretLen;
38
0
}
39
40
#endif // TD_ENTERPRISE