Coverage Report

Created: 2025-03-18 06:55

/src/gnutls/lib/nettle/int/ecdsa-compute-k.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2019 Red Hat, Inc.
3
 *
4
 * Author: Daiki Ueno
5
 *
6
 * This file is part of GNUTLS.
7
 *
8
 * The GNUTLS library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public License
10
 * as published by the Free Software Foundation; either version 2.1 of
11
 * the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful, but
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>
20
 *
21
 */
22
23
#if HAVE_CONFIG_H
24
#include "config.h"
25
#endif
26
27
#include "ecdsa-compute-k.h"
28
29
#include "dsa-compute-k.h"
30
#include "gnutls_int.h"
31
32
int _gnutls_ecc_curve_to_dsa_q(mpz_t q, gnutls_ecc_curve_t curve)
33
0
{
34
0
  switch (curve) {
35
0
#ifdef ENABLE_NON_SUITEB_CURVES
36
0
  case GNUTLS_ECC_CURVE_SECP192R1:
37
0
    mpz_set_str(q,
38
0
          "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836"
39
0
          "146BC9B1B4D22831",
40
0
          16);
41
0
    return 0;
42
0
  case GNUTLS_ECC_CURVE_SECP224R1:
43
0
    mpz_set_str(q,
44
0
          "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2"
45
0
          "E0B8F03E13DD29455C5C2A3D",
46
0
          16);
47
0
    return 0;
48
0
#endif
49
0
  case GNUTLS_ECC_CURVE_SECP256R1:
50
0
    mpz_set_str(q,
51
0
          "FFFFFFFF00000000FFFFFFFFFFFFFFFF"
52
0
          "BCE6FAADA7179E84F3B9CAC2FC632551",
53
0
          16);
54
0
    return 0;
55
0
  case GNUTLS_ECC_CURVE_SECP384R1:
56
0
    mpz_set_str(q,
57
0
          "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
58
0
          "FFFFFFFFFFFFFFFFC7634D81F4372DDF"
59
0
          "581A0DB248B0A77AECEC196ACCC52973",
60
0
          16);
61
0
    return 0;
62
0
  case GNUTLS_ECC_CURVE_SECP521R1:
63
0
    mpz_set_str(q,
64
0
          "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
65
0
          "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
66
0
          "FFA51868783BF2F966B7FCC0148F709A"
67
0
          "5D03BB5C9B8899C47AEBB6FB71E91386"
68
0
          "409",
69
0
          16);
70
0
    return 0;
71
0
  default:
72
0
    return gnutls_assert_val(
73
0
      GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM);
74
0
  }
75
0
}