randombit / botan

@@ -13,64 +13,6 @@
Loading
13 13
14 14
namespace Botan {
15 15
16 -
/*
17 -
PGP stores the iteration count as a single byte
18 -
Thus it can only actually take on one of 256 values, based on the
19 -
formula in RFC 4880 section 3.6.1.3
20 -
*/
21 -
static const uint32_t OPENPGP_S2K_ITERS[256] = {
22 -
   1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600,
23 -
   1664, 1728, 1792, 1856, 1920, 1984, 2048, 2176, 2304, 2432,
24 -
   2560, 2688, 2816, 2944, 3072, 3200, 3328, 3456, 3584, 3712,
25 -
   3840, 3968, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888,
26 -
   6144, 6400, 6656, 6912, 7168, 7424, 7680, 7936, 8192, 8704,
27 -
   9216, 9728, 10240, 10752, 11264, 11776, 12288, 12800, 13312,
28 -
   13824, 14336, 14848, 15360, 15872, 16384, 17408, 18432, 19456,
29 -
   20480, 21504, 22528, 23552, 24576, 25600, 26624, 27648, 28672,
30 -
   29696, 30720, 31744, 32768, 34816, 36864, 38912, 40960, 43008,
31 -
   45056, 47104, 49152, 51200, 53248, 55296, 57344, 59392, 61440,
32 -
   63488, 65536, 69632, 73728, 77824, 81920, 86016, 90112, 94208,
33 -
   98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976,
34 -
   131072, 139264, 147456, 155648, 163840, 172032, 180224, 188416,
35 -
   196608, 204800, 212992, 221184, 229376, 237568, 245760, 253952,
36 -
   262144, 278528, 294912, 311296, 327680, 344064, 360448, 376832,
37 -
   393216, 409600, 425984, 442368, 458752, 475136, 491520, 507904,
38 -
   524288, 557056, 589824, 622592, 655360, 688128, 720896, 753664,
39 -
   786432, 819200, 851968, 884736, 917504, 950272, 983040, 1015808,
40 -
   1048576, 1114112, 1179648, 1245184, 1310720, 1376256, 1441792,
41 -
   1507328, 1572864, 1638400, 1703936, 1769472, 1835008, 1900544,
42 -
   1966080, 2031616, 2097152, 2228224, 2359296, 2490368, 2621440,
43 -
   2752512, 2883584, 3014656, 3145728, 3276800, 3407872, 3538944,
44 -
   3670016, 3801088, 3932160, 4063232, 4194304, 4456448, 4718592,
45 -
   4980736, 5242880, 5505024, 5767168, 6029312, 6291456, 6553600,
46 -
   6815744, 7077888, 7340032, 7602176, 7864320, 8126464, 8388608,
47 -
   8912896, 9437184, 9961472, 10485760, 11010048, 11534336,
48 -
   12058624, 12582912, 13107200, 13631488, 14155776, 14680064,
49 -
   15204352, 15728640, 16252928, 16777216, 17825792, 18874368,
50 -
   19922944, 20971520, 22020096, 23068672, 24117248, 25165824,
51 -
   26214400, 27262976, 28311552, 29360128, 30408704, 31457280,
52 -
   32505856, 33554432, 35651584, 37748736, 39845888, 41943040,
53 -
   44040192, 46137344, 48234496, 50331648, 52428800, 54525952,
54 -
   56623104, 58720256, 60817408, 62914560, 65011712 };
55 -
56 -
uint8_t RFC4880_encode_count(size_t desired_iterations)
57 -
   {
58 -
   if(desired_iterations <= OPENPGP_S2K_ITERS[0])
59 -
      return 0;
60 -
61 -
   if(desired_iterations >= OPENPGP_S2K_ITERS[255])
62 -
      return 255;
63 -
64 -
   auto i = std::lower_bound(OPENPGP_S2K_ITERS, OPENPGP_S2K_ITERS + 256, desired_iterations);
65 -
66 -
   return static_cast<uint8_t>(i - OPENPGP_S2K_ITERS);
67 -
   }
68 -
69 -
size_t RFC4880_decode_count(uint8_t iter)
70 -
   {
71 -
   return OPENPGP_S2K_ITERS[iter];
72 -
   }
73 -
74 16
namespace {
75 17
76 18
void pgp_s2k(HashFunction& hash,

@@ -0,0 +1,74 @@
Loading
1 +
/*
2 +
* (C) 2021 Jack Lloyd
3 +
*
4 +
* Botan is released under the Simplified BSD License (see license.txt)
5 +
*/
6 +
7 +
#include <botan/rfc4880.h>
8 +
#include <algorithm>
9 +
10 +
namespace Botan {
11 +
12 +
namespace {
13 +
14 +
/*
15 +
PGP stores the iteration count as a single byte
16 +
Thus it can only actually take on one of 256 values, based on the
17 +
formula in RFC 4880 section 3.6.1.3
18 +
*/
19 +
static const uint32_t OPENPGP_S2K_ITERS[256] = {
20 +
   1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600,
21 +
   1664, 1728, 1792, 1856, 1920, 1984, 2048, 2176, 2304, 2432,
22 +
   2560, 2688, 2816, 2944, 3072, 3200, 3328, 3456, 3584, 3712,
23 +
   3840, 3968, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888,
24 +
   6144, 6400, 6656, 6912, 7168, 7424, 7680, 7936, 8192, 8704,
25 +
   9216, 9728, 10240, 10752, 11264, 11776, 12288, 12800, 13312,
26 +
   13824, 14336, 14848, 15360, 15872, 16384, 17408, 18432, 19456,
27 +
   20480, 21504, 22528, 23552, 24576, 25600, 26624, 27648, 28672,
28 +
   29696, 30720, 31744, 32768, 34816, 36864, 38912, 40960, 43008,
29 +
   45056, 47104, 49152, 51200, 53248, 55296, 57344, 59392, 61440,
30 +
   63488, 65536, 69632, 73728, 77824, 81920, 86016, 90112, 94208,
31 +
   98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976,
32 +
   131072, 139264, 147456, 155648, 163840, 172032, 180224, 188416,
33 +
   196608, 204800, 212992, 221184, 229376, 237568, 245760, 253952,
34 +
   262144, 278528, 294912, 311296, 327680, 344064, 360448, 376832,
35 +
   393216, 409600, 425984, 442368, 458752, 475136, 491520, 507904,
36 +
   524288, 557056, 589824, 622592, 655360, 688128, 720896, 753664,
37 +
   786432, 819200, 851968, 884736, 917504, 950272, 983040, 1015808,
38 +
   1048576, 1114112, 1179648, 1245184, 1310720, 1376256, 1441792,
39 +
   1507328, 1572864, 1638400, 1703936, 1769472, 1835008, 1900544,
40 +
   1966080, 2031616, 2097152, 2228224, 2359296, 2490368, 2621440,
41 +
   2752512, 2883584, 3014656, 3145728, 3276800, 3407872, 3538944,
42 +
   3670016, 3801088, 3932160, 4063232, 4194304, 4456448, 4718592,
43 +
   4980736, 5242880, 5505024, 5767168, 6029312, 6291456, 6553600,
44 +
   6815744, 7077888, 7340032, 7602176, 7864320, 8126464, 8388608,
45 +
   8912896, 9437184, 9961472, 10485760, 11010048, 11534336,
46 +
   12058624, 12582912, 13107200, 13631488, 14155776, 14680064,
47 +
   15204352, 15728640, 16252928, 16777216, 17825792, 18874368,
48 +
   19922944, 20971520, 22020096, 23068672, 24117248, 25165824,
49 +
   26214400, 27262976, 28311552, 29360128, 30408704, 31457280,
50 +
   32505856, 33554432, 35651584, 37748736, 39845888, 41943040,
51 +
   44040192, 46137344, 48234496, 50331648, 52428800, 54525952,
52 +
   56623104, 58720256, 60817408, 62914560, 65011712 };
53 +
54 +
}
55 +
56 +
uint8_t RFC4880_encode_count(size_t desired_iterations)
57 +
   {
58 +
   if(desired_iterations <= OPENPGP_S2K_ITERS[0])
59 +
      return 0;
60 +
61 +
   if(desired_iterations >= OPENPGP_S2K_ITERS[255])
62 +
      return 255;
63 +
64 +
   auto i = std::lower_bound(OPENPGP_S2K_ITERS, OPENPGP_S2K_ITERS + 256, desired_iterations);
65 +
66 +
   return static_cast<uint8_t>(i - OPENPGP_S2K_ITERS);
67 +
   }
68 +
69 +
size_t RFC4880_decode_count(uint8_t iter)
70 +
   {
71 +
   return OPENPGP_S2K_ITERS[iter];
72 +
   }
73 +
74 +
}

@@ -4,6 +4,7 @@
Loading
4 4
* Botan is released under the Simplified BSD License (see license.txt)
5 5
*/
6 6
7 +
#include <botan/argon2fmt.h>
7 8
#include <botan/argon2.h>
8 9
#include <botan/rng.h>
9 10
#include <botan/base64.h>

@@ -14,8 +14,8 @@
Loading
14 14
   #include <botan/passhash9.h>
15 15
#endif
16 16
17 -
#if defined(BOTAN_HAS_ARGON2)
18 -
   #include <botan/argon2.h>
17 +
#if defined(BOTAN_HAS_ARGON2_FMT)
18 +
   #include <botan/argon2fmt.h>
19 19
   #include "test_rng.h"
20 20
#endif
21 21
@@ -81,7 +81,7 @@
Loading
81 81
82 82
#endif
83 83
84 -
#if defined(BOTAN_HAS_ARGON2)
84 +
#if defined(BOTAN_HAS_ARGON2_FMT)
85 85
class Argon2_Tests final : public Text_Based_Test
86 86
   {
87 87
   public:
Files Coverage
src 92.39%
Project Totals (565 files) 92.39%
1
---
2

3
# Documentation
4
# https://github.com/codecov/support/wiki/Codecov-Yaml#full-yaml
5
#
6
# Validate this file
7
# curl --data-binary @codecov.yml https://codecov.io/validate
8

9
coverage:
10
  status:
11
    project:
12
      default:
13
        # Random seeds in tests lead to a +/-0.05% coverage span even for PRs
14
        # that do not change source code
15
        threshold: 0.05
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading