Coverage Report

Created: 2026-08-13 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dropbear/src/crypto_desc.c
Line
Count
Source
1
#include "includes.h"
2
#include "dbutil.h"
3
#include "crypto_desc.h"
4
#include "ltc_prng.h"
5
#include "ecc.h"
6
#include "dbrandom.h"
7
8
#if DROPBEAR_LTC_PRNG
9
  int dropbear_ltc_prng = -1;
10
#endif
11
12
/* Wrapper for libtommath */
13
3.85k
static mp_err dropbear_rand_source(void* out, size_t size) {
14
3.85k
  genrandom((unsigned char*)out, (unsigned int)size);
15
3.85k
  return MP_OKAY;
16
3.85k
}
17
18
19
/* Register the compiled in ciphers.
20
 * This should be run before using any of the ciphers/hashes */
21
35
void crypto_init() {
22
23
35
  const struct ltc_cipher_descriptor *regciphers[] = {
24
35
#if DROPBEAR_AES
25
35
    &aes_desc,
26
35
#endif
27
#if DROPBEAR_3DES
28
    &des3_desc,
29
#endif
30
35
    NULL
31
35
  };
32
33
35
  const struct ltc_hash_descriptor *reghashes[] = {
34
#if DROPBEAR_SHA1_HMAC
35
    &sha1_desc,
36
#endif
37
35
#if DROPBEAR_SHA256
38
35
    &sha256_desc,
39
35
#endif
40
35
#if DROPBEAR_SHA384
41
35
    &sha384_desc,
42
35
#endif
43
35
#if DROPBEAR_SHA512
44
35
    &sha512_desc,
45
35
#endif
46
35
    NULL
47
35
  };
48
35
  int i;
49
50
70
  for (i = 0; regciphers[i] != NULL; i++) {
51
35
    if (register_cipher(regciphers[i]) == -1) {
52
0
      dropbear_exit("Error registering crypto");
53
0
    }
54
35
  }
55
56
140
  for (i = 0; reghashes[i] != NULL; i++) {
57
105
    if (register_hash(reghashes[i]) == -1) {
58
0
      dropbear_exit("Error registering crypto");
59
0
    }
60
105
  }
61
62
35
#if DROPBEAR_LTC_PRNG
63
35
  dropbear_ltc_prng = register_prng(&dropbear_prng_desc);
64
35
  if (dropbear_ltc_prng == -1) {
65
0
    dropbear_exit("Error registering crypto");
66
0
  }
67
35
#endif
68
69
35
  mp_rand_source(dropbear_rand_source);
70
71
35
#if DROPBEAR_ECC
72
35
  ltc_mp = ltm_desc;
73
35
  dropbear_ecc_fill_dp();
74
35
#endif
75
35
}
76