1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
In clang/libcxx 19, treatment of std::char_traits was tightened
down - e.g. no generic (std::char_traits<unsigned char> etc) traits
are not implemented anymore - which resulted in fallout in HEAD
after the import of llvm/libcxx 19.
jkim@ collected the neccessary patches from
https://github.com/rnpgp/rnp/commit/20419f739f632fb30666650544f0055e8d4f1afa
https://github.com/rnpgp/sexpp/commit/46744a14ffc235330bb99cebfaf294829c31bba4
--- comm/third_party/rnp/src/lib/types.h.orig 2024-10-25 23:29:32 UTC
+++ comm/third_party/rnp/src/lib/types.h
@@ -95,9 +95,6 @@ class id_str_pair {
static int lookup(const id_str_pair pair[],
const std::vector<uint8_t> &bytes,
int notfound = 0);
- static int lookup(const id_str_pair pair[],
- const std::basic_string<uint8_t> &bytes,
- int notfound = 0);
};
/** pgp_fingerprint_t */
--- comm/third_party/rnp/src/lib/utils.cpp.orig 2024-10-25 23:29:32 UTC
+++ comm/third_party/rnp/src/lib/utils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
+ * Copyright (c) 2021, 2024 [Ribose Inc](https://www.ribose.com).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,21 +53,6 @@ id_str_pair::lookup(const id_str_pair pair[], const st
int
id_str_pair::lookup(const id_str_pair pair[], const std::vector<uint8_t> &bytes, int notfound)
-{
- while (pair && pair->str) {
- if ((strlen(pair->str) == bytes.size()) &&
- !memcmp(pair->str, bytes.data(), bytes.size())) {
- return pair->id;
- }
- pair++;
- }
- return notfound;
-}
-
-int
-id_str_pair::lookup(const id_str_pair pair[],
- const std::basic_string<uint8_t> &bytes,
- int notfound)
{
while (pair && pair->str) {
if ((strlen(pair->str) == bytes.size()) &&
--- comm/third_party/rnp/src/librekey/key_store_g10.cpp.orig 2024-10-25 23:29:32 UTC
+++ comm/third_party/rnp/src/librekey/key_store_g10.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2022, [Ribose Inc](https://www.ribose.com).
+ * Copyright (c) 2017-2024, [Ribose Inc](https://www.ribose.com).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -312,12 +312,12 @@ read_curve(const sexp_list_t *list, const std::string
const auto &bytes = data->get_string();
pgp_curve_t curve = static_cast<pgp_curve_t>(
- id_str_pair::lookup(g10_curve_aliases, data->get_string(), PGP_CURVE_UNKNOWN));
+ id_str_pair::lookup(g10_curve_aliases, (const char *) bytes.data(), PGP_CURVE_UNKNOWN));
if (curve != PGP_CURVE_UNKNOWN) {
key.curve = curve;
return true;
}
- RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (char *) bytes.data());
+ RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (const char *) bytes.data());
return false;
}
@@ -806,7 +806,7 @@ g23_parse_seckey(pgp_key_pkt_t &seckey,
auto & alg_bt = alg_s_exp->sexp_string_at(0)->get_string();
pgp_pubkey_alg_t alg = static_cast<pgp_pubkey_alg_t>(
- id_str_pair::lookup(g10_alg_aliases, alg_bt.c_str(), PGP_PKA_NOTHING));
+ id_str_pair::lookup(g10_alg_aliases, (const char *) alg_bt.data(), PGP_PKA_NOTHING));
if (alg == PGP_PKA_NOTHING) {
RNP_LOG(
"Unsupported algorithm: '%.*s'", (int) alg_bt.size(), (const char *) alg_bt.data());
--- comm/third_party/rnp/src/libsexpp/include/sexpp/sexp.h.orig 2024-10-25 23:29:32.000000000 +0000
+++ comm/third_party/rnp/src/libsexpp/include/sexpp/sexp.h 2024-10-27 06:14:59.238155000 +0000
@@ -44,8 +44,93 @@
#include "sexp-public.h"
#include "sexp-error.h"
+// We are implementing char traits for octet_t with trhe following restrictions
+// -- limit visibility so that other traits for unsigned char are still possible
+// -- create template specializatio in std workspace (use workspace specialization
+// is not specified and causes issues at least with gcc 4.8
+
namespace sexp {
+using octet_t = uint8_t;
+} // namespace sexp
+namespace std {
+
+template <> struct char_traits<sexp::octet_t> {
+ typedef sexp::octet_t char_type;
+ typedef int int_type;
+ typedef std::streampos pos_type;
+ typedef std::streamoff off_type;
+ typedef mbstate_t state_type;
+
+ static void assign(char_type &__c1, const char_type &__c2) noexcept { __c1 = __c2; }
+
+ static constexpr bool eq(const char_type &__c1, const char_type &__c2) noexcept
+ {
+ return __c1 == __c2;
+ }
+
+ static constexpr bool lt(const char_type &__c1, const char_type &__c2) noexcept
+ {
+ return __c1 < __c2;
+ }
+
+ static int compare(const char_type *__s1, const char_type *__s2, size_t __n)
+ {
+ return memcmp(__s1, __s2, __n);
+ }
+
+ static size_t length(const char_type *__s)
+ {
+ return strlen(reinterpret_cast<const char *>(__s));
+ }
+
+ static const char_type *find(const char_type *__s, size_t __n, const char_type &__a)
+ {
+ return static_cast<const char_type *>(memchr(__s, __a, __n));
+ }
+
+ static char_type *move(char_type *__s1, const char_type *__s2, size_t __n)
+ {
+ return static_cast<char_type *>(memmove(__s1, __s2, __n));
+ }
+
+ static char_type *copy(char_type *__s1, const char_type *__s2, size_t __n)
+ {
+ return static_cast<char_type *>(memcpy(__s1, __s2, __n));
+ }
+
+ static char_type *assign(char_type *__s, size_t __n, char_type __a)
+ {
+ return static_cast<char_type *>(memset(__s, __a, __n));
+ }
+
+ static constexpr char_type to_char_type(const int_type &__c) noexcept
+ {
+ return static_cast<char_type>(__c);
+ }
+
+ // To keep both the byte 0xff and the eof symbol 0xffffffff
+ // from ending up as 0xffffffff.
+ static constexpr int_type to_int_type(const char_type &__c) noexcept
+ {
+ return static_cast<int_type>(static_cast<unsigned char>(__c));
+ }
+
+ static constexpr bool eq_int_type(const int_type &__c1, const int_type &__c2) noexcept
+ {
+ return __c1 == __c2;
+ }
+
+ static constexpr int_type eof() noexcept { return static_cast<int_type>(0xFFFFFFFF); }
+
+ static constexpr int_type not_eof(const int_type &__c) noexcept
+ {
+ return (__c == eof()) ? 0 : __c;
+ }
+};
+} // namespace std
+
+namespace sexp {
/*
* SEXP octet_t definitions
* We maintain some presumable redundancy with ctype
@@ -99,14 +184,14 @@ class sexp_input_stream_t;
* SEXP simple string
*/
-typedef uint8_t octet_t;
+using octet_traits = std::char_traits<octet_t>;
+using octet_string = std::basic_string<octet_t, octet_traits>;
-class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public std::basic_string<octet_t>,
- private sexp_char_defs_t {
+class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public octet_string, private sexp_char_defs_t {
public:
sexp_simple_string_t(void) = default;
- sexp_simple_string_t(const octet_t *dt) : std::basic_string<octet_t>{dt} {}
- sexp_simple_string_t(const octet_t *bt, size_t ln) : std::basic_string<octet_t>{bt, ln} {}
+ sexp_simple_string_t(const octet_t *dt) : octet_string{dt} {}
+ sexp_simple_string_t(const octet_t *bt, size_t ln) : octet_string{bt, ln} {}
sexp_simple_string_t &append(int c)
{
(*this) += (octet_t)(c & 0xFF);
|