@derec-alliance/react-native 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -7
- package/android/src/main/jniLibs/arm64-v8a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/x86_64/libderec_library.a +0 -0
- package/cpp/Primitives.cpp +38 -9
- package/cpp/Primitives.h +5 -3
- package/cpp/ProtocolHost.cpp +4 -5
- package/cpp/StoreCallbacks.cpp +31 -43
- package/cpp/derec_ffi.h +98 -33
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +98 -33
- package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +98 -33
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/errors.d.ts +8 -3
- package/lib/errors.js +6 -0
- package/lib/messages.js +5 -3
- package/lib/primitives.d.ts +12 -2
- package/lib/primitives.js +17 -2
- package/lib/protocol.d.ts +9 -5
- package/lib/protocol.js +9 -5
- package/lib/types.d.ts +194 -46
- package/lib/types.js +4 -1
- package/package.json +4 -17
- package/schema/derec_descriptor.bin +0 -0
- package/schema/proto/committedderecshare.proto +93 -0
- package/schema/proto/communicationinfo.proto +104 -0
- package/schema/proto/contact.proto +266 -0
- package/schema/proto/derecmessage.proto +248 -0
- package/schema/proto/derecsecret.proto +163 -0
- package/schema/proto/derectransport.proto +38 -0
- package/schema/proto/error.proto +68 -0
- package/schema/proto/getshare.proto +184 -0
- package/schema/proto/pair.proto +284 -0
- package/schema/proto/parameterrange.proto +36 -0
- package/schema/proto/prepair.proto +164 -0
- package/schema/proto/result.proto +194 -0
- package/schema/proto/secretidsversions.proto +199 -0
- package/schema/proto/storeshare.proto +242 -0
- package/schema/proto/transportprotocol.proto +112 -0
- package/schema/proto/unpair.proto +132 -0
- package/schema/proto/updatechannelinfo.proto +100 -0
- package/schema/proto/verify.proto +160 -0
- package/src/errors.ts +12 -1
- package/src/messages.ts +5 -3
- package/src/primitives.ts +23 -2
- package/src/protocol.ts +10 -6
- package/src/types.ts +185 -43
package/cpp/derec_ffi.h
CHANGED
|
@@ -106,6 +106,8 @@
|
|
|
106
106
|
|
|
107
107
|
#define DEREC_CATEGORY_STATE_STORE 15
|
|
108
108
|
|
|
109
|
+
#define DEREC_CATEGORY_TRANSPORT 16
|
|
110
|
+
|
|
109
111
|
#define DEREC_CODE_OK 0
|
|
110
112
|
|
|
111
113
|
#define DEREC_CODE_NON_OK_STATUS 1
|
|
@@ -180,6 +182,13 @@
|
|
|
180
182
|
*/
|
|
181
183
|
#define DEREC_CODE_REPLICA_ID_CONFLICT 16
|
|
182
184
|
|
|
185
|
+
/**
|
|
186
|
+
* `derec_protocol_verify_fingerprint`: the fingerprint compared out of band
|
|
187
|
+
* does not match the channel key — a possible man-in-the-middle. A `Pending`
|
|
188
|
+
* pairing has been revoked; pair again. `DEREC_CATEGORY_PAIRING`.
|
|
189
|
+
*/
|
|
190
|
+
#define DEREC_CODE_FINGERPRINT_MISMATCH 17
|
|
191
|
+
|
|
183
192
|
#define DEREC_CODE_ENCRYPTION 20
|
|
184
193
|
|
|
185
194
|
#define DEREC_CODE_KEYGEN 21
|
|
@@ -229,6 +238,24 @@
|
|
|
229
238
|
*/
|
|
230
239
|
#define DEREC_CODE_INCOMPATIBLE_PARAMETER_RANGE 47
|
|
231
240
|
|
|
241
|
+
/**
|
|
242
|
+
* The fingerprint nonce in a `PairResponseMessage` does not open the
|
|
243
|
+
* commitment the contact creator published with its keys. Surfaced as
|
|
244
|
+
* [`DEREC_CATEGORY_PAIRING`]; the pairing does not complete. Either the
|
|
245
|
+
* response or the keys did not come from the party that made the
|
|
246
|
+
* commitment, so applications can treat it as a possible
|
|
247
|
+
* man-in-the-middle.
|
|
248
|
+
*/
|
|
249
|
+
#define DEREC_CODE_FINGERPRINT_COMMITMENT_MISMATCH 48
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The pairing outlived `Timeouts::pairing`: the scanner refuses a contact
|
|
253
|
+
* older than it, and the contact's creator refuses to accept a request
|
|
254
|
+
* that arrives after it. Surfaced as [`DEREC_CATEGORY_PAIRING`]; nothing is
|
|
255
|
+
* sent to the peer, and a fresh contact starts a new pairing.
|
|
256
|
+
*/
|
|
257
|
+
#define DEREC_CODE_PAIRING_EXPIRED 49
|
|
258
|
+
|
|
232
259
|
#define DEREC_CODE_EMPTY_CHANNELS 60
|
|
233
260
|
|
|
234
261
|
#define DEREC_CODE_DUPLICATE_CHANNEL_ID 61
|
|
@@ -243,6 +270,8 @@
|
|
|
243
270
|
|
|
244
271
|
#define DEREC_CODE_TOO_MANY_SUBSHARES 66
|
|
245
272
|
|
|
273
|
+
#define DEREC_CODE_INVALID_KEEP_VERSION 67
|
|
274
|
+
|
|
246
275
|
#define DEREC_CODE_EMPTY_RESPONSES 80
|
|
247
276
|
|
|
248
277
|
#define DEREC_CODE_EMPTY_COMMITTED_DEREC_SHARE 81
|
|
@@ -293,6 +322,13 @@
|
|
|
293
322
|
*/
|
|
294
323
|
#define DEREC_CODE_NO_USABLE_ENDPOINT 121
|
|
295
324
|
|
|
325
|
+
/**
|
|
326
|
+
* The application's transport delivered a message to none of the peer's
|
|
327
|
+
* endpoints: the `send` callback returned non-zero.
|
|
328
|
+
* `DEREC_CATEGORY_TRANSPORT`.
|
|
329
|
+
*/
|
|
330
|
+
#define DEREC_CODE_TRANSPORT_SEND_FAILED 123
|
|
331
|
+
|
|
296
332
|
/**
|
|
297
333
|
* Return codes for [`crate::interop::ffi::protocol::stores::ShareStoreCallbacks::save`]
|
|
298
334
|
* and `ShareStoreCallbacks::record_verification`: `0` is success, each of
|
|
@@ -475,6 +511,14 @@ typedef struct DeRecError {
|
|
|
475
511
|
* Valid when `code == DEREC_CODE_VERSION_MISMATCH`.
|
|
476
512
|
*/
|
|
477
513
|
uint32_t got;
|
|
514
|
+
/**
|
|
515
|
+
* Whether `channel_id` is set: the error names the channel it is about.
|
|
516
|
+
*/
|
|
517
|
+
bool has_channel_id;
|
|
518
|
+
/**
|
|
519
|
+
* The channel the error is about. Valid when `has_channel_id`.
|
|
520
|
+
*/
|
|
521
|
+
uint64_t channel_id;
|
|
478
522
|
} DeRecError;
|
|
479
523
|
|
|
480
524
|
typedef struct DeRecBuffer {
|
|
@@ -538,6 +582,20 @@ typedef struct ReadTraceIdResult {
|
|
|
538
582
|
uint64_t trace_id;
|
|
539
583
|
} ReadTraceIdResult;
|
|
540
584
|
|
|
585
|
+
typedef struct MessageIdResult {
|
|
586
|
+
struct DeRecError error;
|
|
587
|
+
/**
|
|
588
|
+
* SHA-256 of the envelope's encrypted `message` field (32 bytes). Empty
|
|
589
|
+
* on error.
|
|
590
|
+
*/
|
|
591
|
+
struct DeRecBuffer id;
|
|
592
|
+
/**
|
|
593
|
+
* The envelope's send time, in seconds since the Unix epoch. Zero on
|
|
594
|
+
* error.
|
|
595
|
+
*/
|
|
596
|
+
uint64_t timestamp;
|
|
597
|
+
} MessageIdResult;
|
|
598
|
+
|
|
541
599
|
/**
|
|
542
600
|
* Result of a message JSON codec call. `bytes` is UTF-8 JSON for
|
|
543
601
|
* [`derec_decode_message_json`] and protobuf wire bytes for
|
|
@@ -704,6 +762,12 @@ typedef struct ProcessPrePairResponseMessageResult {
|
|
|
704
762
|
* Nonce echoed from the original `ContactMessage`. Zero on failure.
|
|
705
763
|
*/
|
|
706
764
|
uint64_t nonce;
|
|
765
|
+
/**
|
|
766
|
+
* The creator's 32-byte commitment to its fingerprint nonce. Carry it
|
|
767
|
+
* into the contact the pair request is built from, in
|
|
768
|
+
* `fingerprint_commitment`, alongside the two keys.
|
|
769
|
+
*/
|
|
770
|
+
struct DeRecBuffer fingerprint_commitment;
|
|
707
771
|
} ProcessPrePairResponseMessageResult;
|
|
708
772
|
|
|
709
773
|
typedef struct PairingFingerprintResult {
|
|
@@ -865,10 +929,9 @@ typedef struct SecretStoreCallbacks {
|
|
|
865
929
|
* is none, and absent or `null` reads as none. Store them as given and return
|
|
866
930
|
* them unchanged.
|
|
867
931
|
*
|
|
868
|
-
* `
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
* means `null`.
|
|
932
|
+
* `keep_version` writes the application's answer to `out_version`: the one
|
|
933
|
+
* version, other than `version`, every helper keeps, or `0` to keep no
|
|
934
|
+
* other version. Any non-zero return code is a backend failure.
|
|
872
935
|
*
|
|
873
936
|
* `save` and `record_verification` share a return-code convention: `0` is
|
|
874
937
|
* success; `3`/`4`/`10` (the
|
|
@@ -920,11 +983,10 @@ typedef struct ShareStoreCallbacks {
|
|
|
920
983
|
uint64_t channel_id,
|
|
921
984
|
const uint8_t *versions_json_ptr,
|
|
922
985
|
size_t versions_json_len);
|
|
923
|
-
int32_t (*
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
size_t *out_len);
|
|
986
|
+
int32_t (*keep_version)(void *user_data,
|
|
987
|
+
uint64_t secret_id,
|
|
988
|
+
uint32_t version,
|
|
989
|
+
uint32_t *out_version);
|
|
928
990
|
int32_t (*record_verification)(void *user_data,
|
|
929
991
|
uint64_t secret_id,
|
|
930
992
|
uint64_t channel_id,
|
|
@@ -1406,6 +1468,19 @@ struct ApplyTraceIdResult apply_trace_id_to_envelope(const uint8_t *envelope_ptr
|
|
|
1406
1468
|
struct ReadTraceIdResult read_trace_id_from_envelope(const uint8_t *envelope_ptr,
|
|
1407
1469
|
size_t envelope_len);
|
|
1408
1470
|
|
|
1471
|
+
/**
|
|
1472
|
+
* Identify an envelope for replay and reflection detection: the same `id`
|
|
1473
|
+
* for every copy of one message, whatever its unauthenticated cleartext
|
|
1474
|
+
* fields say, and a different one for every other message.
|
|
1475
|
+
*
|
|
1476
|
+
* Mirrors [`crate::derec_message::message_id`].
|
|
1477
|
+
*
|
|
1478
|
+
* # Safety
|
|
1479
|
+
*
|
|
1480
|
+
* `envelope_ptr` must point to a readable byte range of length `envelope_len`.
|
|
1481
|
+
*/
|
|
1482
|
+
struct MessageIdResult message_id_from_envelope(const uint8_t *envelope_ptr, size_t envelope_len);
|
|
1483
|
+
|
|
1409
1484
|
/**
|
|
1410
1485
|
* Releases the owned strings carried by a [`DeRecError`]. After
|
|
1411
1486
|
* returning, `error.message` and `error.peer_memo` are both null —
|
|
@@ -1781,6 +1856,8 @@ struct ProcessPrePairResponseMessageResult process_pre_pair_response_message(con
|
|
|
1781
1856
|
* "inbound_message_secs": 300,
|
|
1782
1857
|
* "sharing_round_secs": 60,
|
|
1783
1858
|
* "unpair_ack_secs": 60,
|
|
1859
|
+
* "get_share_response_secs": 300,
|
|
1860
|
+
* "pairing_secs": 30,
|
|
1784
1861
|
* "expired_channels": { "enabled": true, "timeout_in_secs": 300 }
|
|
1785
1862
|
* },
|
|
1786
1863
|
* "unsafe_connection": false,
|
|
@@ -2111,34 +2188,23 @@ struct DeRecProtocolFingerprintResult derec_protocol_get_fingerprint(struct DeRe
|
|
|
2111
2188
|
* Verify a fingerprint against the channel's locally-derived one. See
|
|
2112
2189
|
* [`crate::protocol::DeRecProtocol::verify_fingerprint`].
|
|
2113
2190
|
*
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2117
|
-
*
|
|
2118
|
-
*
|
|
2119
|
-
*
|
|
2120
|
-
* verdict; treating `out_matched == 0` as "definitely not matched"
|
|
2121
|
-
* is safe only after confirming the envelope reports
|
|
2122
|
-
* [`DEREC_CATEGORY_OK`](crate::interop::ffi::error::DEREC_CATEGORY_OK).
|
|
2123
|
-
*
|
|
2124
|
-
* The fail-closed write happens immediately after the null-pointer
|
|
2125
|
-
* check, so a caller that allocates the output on the stack and
|
|
2126
|
-
* reads it without checking the error envelope still gets `0`,
|
|
2127
|
-
* never a stale `1` from uninitialized memory. This neutralizes
|
|
2128
|
-
* the "sloppy caller skips the error envelope and reads stale
|
|
2129
|
-
* stack" footgun on the MITM-protection gate.
|
|
2191
|
+
* Success means the comparison matched and the channel is confirmed. Every
|
|
2192
|
+
* other outcome is an error envelope; a mismatch is
|
|
2193
|
+
* [`DEREC_CODE_FINGERPRINT_MISMATCH`](crate::interop::ffi::error::DEREC_CODE_FINGERPRINT_MISMATCH),
|
|
2194
|
+
* after which a `Pending` pairing has been revoked. There is no verdict to
|
|
2195
|
+
* read apart from the envelope, so a caller cannot mistake a failure for a
|
|
2196
|
+
* match.
|
|
2130
2197
|
*
|
|
2131
2198
|
* # Safety
|
|
2132
2199
|
*
|
|
2133
|
-
* `handle`
|
|
2134
|
-
*
|
|
2135
|
-
*
|
|
2136
|
-
*
|
|
2200
|
+
* `handle` must be a valid pointer. `fingerprint_ptr` must be a valid
|
|
2201
|
+
* pointer to a NUL-terminated C string. Concurrent calls on the same handle
|
|
2202
|
+
* from different threads are safe: the handle's internal mutex serializes
|
|
2203
|
+
* them.
|
|
2137
2204
|
*/
|
|
2138
2205
|
struct DeRecError derec_protocol_verify_fingerprint(struct DeRecProtocolHandle *handle,
|
|
2139
2206
|
uint64_t channel_id,
|
|
2140
|
-
const char *fingerprint_ptr
|
|
2141
|
-
uint32_t *out_matched);
|
|
2207
|
+
const char *fingerprint_ptr);
|
|
2142
2208
|
|
|
2143
2209
|
/**
|
|
2144
2210
|
* Generate an out-of-band contact message used to bootstrap pairing.
|
|
@@ -2310,8 +2376,7 @@ struct ProduceStoreShareRequestMessageResult produce_store_share_request_message
|
|
|
2310
2376
|
uint64_t secret_id,
|
|
2311
2377
|
const uint8_t *committed_share_ptr,
|
|
2312
2378
|
size_t committed_share_len,
|
|
2313
|
-
|
|
2314
|
-
size_t keep_list_len,
|
|
2379
|
+
uint32_t keep_version,
|
|
2315
2380
|
const uint8_t *description_ptr,
|
|
2316
2381
|
size_t description_len,
|
|
2317
2382
|
const uint8_t *shared_key_ptr,
|
|
@@ -106,6 +106,8 @@
|
|
|
106
106
|
|
|
107
107
|
#define DEREC_CATEGORY_STATE_STORE 15
|
|
108
108
|
|
|
109
|
+
#define DEREC_CATEGORY_TRANSPORT 16
|
|
110
|
+
|
|
109
111
|
#define DEREC_CODE_OK 0
|
|
110
112
|
|
|
111
113
|
#define DEREC_CODE_NON_OK_STATUS 1
|
|
@@ -180,6 +182,13 @@
|
|
|
180
182
|
*/
|
|
181
183
|
#define DEREC_CODE_REPLICA_ID_CONFLICT 16
|
|
182
184
|
|
|
185
|
+
/**
|
|
186
|
+
* `derec_protocol_verify_fingerprint`: the fingerprint compared out of band
|
|
187
|
+
* does not match the channel key — a possible man-in-the-middle. A `Pending`
|
|
188
|
+
* pairing has been revoked; pair again. `DEREC_CATEGORY_PAIRING`.
|
|
189
|
+
*/
|
|
190
|
+
#define DEREC_CODE_FINGERPRINT_MISMATCH 17
|
|
191
|
+
|
|
183
192
|
#define DEREC_CODE_ENCRYPTION 20
|
|
184
193
|
|
|
185
194
|
#define DEREC_CODE_KEYGEN 21
|
|
@@ -229,6 +238,24 @@
|
|
|
229
238
|
*/
|
|
230
239
|
#define DEREC_CODE_INCOMPATIBLE_PARAMETER_RANGE 47
|
|
231
240
|
|
|
241
|
+
/**
|
|
242
|
+
* The fingerprint nonce in a `PairResponseMessage` does not open the
|
|
243
|
+
* commitment the contact creator published with its keys. Surfaced as
|
|
244
|
+
* [`DEREC_CATEGORY_PAIRING`]; the pairing does not complete. Either the
|
|
245
|
+
* response or the keys did not come from the party that made the
|
|
246
|
+
* commitment, so applications can treat it as a possible
|
|
247
|
+
* man-in-the-middle.
|
|
248
|
+
*/
|
|
249
|
+
#define DEREC_CODE_FINGERPRINT_COMMITMENT_MISMATCH 48
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The pairing outlived `Timeouts::pairing`: the scanner refuses a contact
|
|
253
|
+
* older than it, and the contact's creator refuses to accept a request
|
|
254
|
+
* that arrives after it. Surfaced as [`DEREC_CATEGORY_PAIRING`]; nothing is
|
|
255
|
+
* sent to the peer, and a fresh contact starts a new pairing.
|
|
256
|
+
*/
|
|
257
|
+
#define DEREC_CODE_PAIRING_EXPIRED 49
|
|
258
|
+
|
|
232
259
|
#define DEREC_CODE_EMPTY_CHANNELS 60
|
|
233
260
|
|
|
234
261
|
#define DEREC_CODE_DUPLICATE_CHANNEL_ID 61
|
|
@@ -243,6 +270,8 @@
|
|
|
243
270
|
|
|
244
271
|
#define DEREC_CODE_TOO_MANY_SUBSHARES 66
|
|
245
272
|
|
|
273
|
+
#define DEREC_CODE_INVALID_KEEP_VERSION 67
|
|
274
|
+
|
|
246
275
|
#define DEREC_CODE_EMPTY_RESPONSES 80
|
|
247
276
|
|
|
248
277
|
#define DEREC_CODE_EMPTY_COMMITTED_DEREC_SHARE 81
|
|
@@ -293,6 +322,13 @@
|
|
|
293
322
|
*/
|
|
294
323
|
#define DEREC_CODE_NO_USABLE_ENDPOINT 121
|
|
295
324
|
|
|
325
|
+
/**
|
|
326
|
+
* The application's transport delivered a message to none of the peer's
|
|
327
|
+
* endpoints: the `send` callback returned non-zero.
|
|
328
|
+
* `DEREC_CATEGORY_TRANSPORT`.
|
|
329
|
+
*/
|
|
330
|
+
#define DEREC_CODE_TRANSPORT_SEND_FAILED 123
|
|
331
|
+
|
|
296
332
|
/**
|
|
297
333
|
* Return codes for [`crate::interop::ffi::protocol::stores::ShareStoreCallbacks::save`]
|
|
298
334
|
* and `ShareStoreCallbacks::record_verification`: `0` is success, each of
|
|
@@ -475,6 +511,14 @@ typedef struct DeRecError {
|
|
|
475
511
|
* Valid when `code == DEREC_CODE_VERSION_MISMATCH`.
|
|
476
512
|
*/
|
|
477
513
|
uint32_t got;
|
|
514
|
+
/**
|
|
515
|
+
* Whether `channel_id` is set: the error names the channel it is about.
|
|
516
|
+
*/
|
|
517
|
+
bool has_channel_id;
|
|
518
|
+
/**
|
|
519
|
+
* The channel the error is about. Valid when `has_channel_id`.
|
|
520
|
+
*/
|
|
521
|
+
uint64_t channel_id;
|
|
478
522
|
} DeRecError;
|
|
479
523
|
|
|
480
524
|
typedef struct DeRecBuffer {
|
|
@@ -538,6 +582,20 @@ typedef struct ReadTraceIdResult {
|
|
|
538
582
|
uint64_t trace_id;
|
|
539
583
|
} ReadTraceIdResult;
|
|
540
584
|
|
|
585
|
+
typedef struct MessageIdResult {
|
|
586
|
+
struct DeRecError error;
|
|
587
|
+
/**
|
|
588
|
+
* SHA-256 of the envelope's encrypted `message` field (32 bytes). Empty
|
|
589
|
+
* on error.
|
|
590
|
+
*/
|
|
591
|
+
struct DeRecBuffer id;
|
|
592
|
+
/**
|
|
593
|
+
* The envelope's send time, in seconds since the Unix epoch. Zero on
|
|
594
|
+
* error.
|
|
595
|
+
*/
|
|
596
|
+
uint64_t timestamp;
|
|
597
|
+
} MessageIdResult;
|
|
598
|
+
|
|
541
599
|
/**
|
|
542
600
|
* Result of a message JSON codec call. `bytes` is UTF-8 JSON for
|
|
543
601
|
* [`derec_decode_message_json`] and protobuf wire bytes for
|
|
@@ -704,6 +762,12 @@ typedef struct ProcessPrePairResponseMessageResult {
|
|
|
704
762
|
* Nonce echoed from the original `ContactMessage`. Zero on failure.
|
|
705
763
|
*/
|
|
706
764
|
uint64_t nonce;
|
|
765
|
+
/**
|
|
766
|
+
* The creator's 32-byte commitment to its fingerprint nonce. Carry it
|
|
767
|
+
* into the contact the pair request is built from, in
|
|
768
|
+
* `fingerprint_commitment`, alongside the two keys.
|
|
769
|
+
*/
|
|
770
|
+
struct DeRecBuffer fingerprint_commitment;
|
|
707
771
|
} ProcessPrePairResponseMessageResult;
|
|
708
772
|
|
|
709
773
|
typedef struct PairingFingerprintResult {
|
|
@@ -865,10 +929,9 @@ typedef struct SecretStoreCallbacks {
|
|
|
865
929
|
* is none, and absent or `null` reads as none. Store them as given and return
|
|
866
930
|
* them unchanged.
|
|
867
931
|
*
|
|
868
|
-
* `
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
* means `null`.
|
|
932
|
+
* `keep_version` writes the application's answer to `out_version`: the one
|
|
933
|
+
* version, other than `version`, every helper keeps, or `0` to keep no
|
|
934
|
+
* other version. Any non-zero return code is a backend failure.
|
|
872
935
|
*
|
|
873
936
|
* `save` and `record_verification` share a return-code convention: `0` is
|
|
874
937
|
* success; `3`/`4`/`10` (the
|
|
@@ -920,11 +983,10 @@ typedef struct ShareStoreCallbacks {
|
|
|
920
983
|
uint64_t channel_id,
|
|
921
984
|
const uint8_t *versions_json_ptr,
|
|
922
985
|
size_t versions_json_len);
|
|
923
|
-
int32_t (*
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
size_t *out_len);
|
|
986
|
+
int32_t (*keep_version)(void *user_data,
|
|
987
|
+
uint64_t secret_id,
|
|
988
|
+
uint32_t version,
|
|
989
|
+
uint32_t *out_version);
|
|
928
990
|
int32_t (*record_verification)(void *user_data,
|
|
929
991
|
uint64_t secret_id,
|
|
930
992
|
uint64_t channel_id,
|
|
@@ -1406,6 +1468,19 @@ struct ApplyTraceIdResult apply_trace_id_to_envelope(const uint8_t *envelope_ptr
|
|
|
1406
1468
|
struct ReadTraceIdResult read_trace_id_from_envelope(const uint8_t *envelope_ptr,
|
|
1407
1469
|
size_t envelope_len);
|
|
1408
1470
|
|
|
1471
|
+
/**
|
|
1472
|
+
* Identify an envelope for replay and reflection detection: the same `id`
|
|
1473
|
+
* for every copy of one message, whatever its unauthenticated cleartext
|
|
1474
|
+
* fields say, and a different one for every other message.
|
|
1475
|
+
*
|
|
1476
|
+
* Mirrors [`crate::derec_message::message_id`].
|
|
1477
|
+
*
|
|
1478
|
+
* # Safety
|
|
1479
|
+
*
|
|
1480
|
+
* `envelope_ptr` must point to a readable byte range of length `envelope_len`.
|
|
1481
|
+
*/
|
|
1482
|
+
struct MessageIdResult message_id_from_envelope(const uint8_t *envelope_ptr, size_t envelope_len);
|
|
1483
|
+
|
|
1409
1484
|
/**
|
|
1410
1485
|
* Releases the owned strings carried by a [`DeRecError`]. After
|
|
1411
1486
|
* returning, `error.message` and `error.peer_memo` are both null —
|
|
@@ -1781,6 +1856,8 @@ struct ProcessPrePairResponseMessageResult process_pre_pair_response_message(con
|
|
|
1781
1856
|
* "inbound_message_secs": 300,
|
|
1782
1857
|
* "sharing_round_secs": 60,
|
|
1783
1858
|
* "unpair_ack_secs": 60,
|
|
1859
|
+
* "get_share_response_secs": 300,
|
|
1860
|
+
* "pairing_secs": 30,
|
|
1784
1861
|
* "expired_channels": { "enabled": true, "timeout_in_secs": 300 }
|
|
1785
1862
|
* },
|
|
1786
1863
|
* "unsafe_connection": false,
|
|
@@ -2111,34 +2188,23 @@ struct DeRecProtocolFingerprintResult derec_protocol_get_fingerprint(struct DeRe
|
|
|
2111
2188
|
* Verify a fingerprint against the channel's locally-derived one. See
|
|
2112
2189
|
* [`crate::protocol::DeRecProtocol::verify_fingerprint`].
|
|
2113
2190
|
*
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2117
|
-
*
|
|
2118
|
-
*
|
|
2119
|
-
*
|
|
2120
|
-
* verdict; treating `out_matched == 0` as "definitely not matched"
|
|
2121
|
-
* is safe only after confirming the envelope reports
|
|
2122
|
-
* [`DEREC_CATEGORY_OK`](crate::interop::ffi::error::DEREC_CATEGORY_OK).
|
|
2123
|
-
*
|
|
2124
|
-
* The fail-closed write happens immediately after the null-pointer
|
|
2125
|
-
* check, so a caller that allocates the output on the stack and
|
|
2126
|
-
* reads it without checking the error envelope still gets `0`,
|
|
2127
|
-
* never a stale `1` from uninitialized memory. This neutralizes
|
|
2128
|
-
* the "sloppy caller skips the error envelope and reads stale
|
|
2129
|
-
* stack" footgun on the MITM-protection gate.
|
|
2191
|
+
* Success means the comparison matched and the channel is confirmed. Every
|
|
2192
|
+
* other outcome is an error envelope; a mismatch is
|
|
2193
|
+
* [`DEREC_CODE_FINGERPRINT_MISMATCH`](crate::interop::ffi::error::DEREC_CODE_FINGERPRINT_MISMATCH),
|
|
2194
|
+
* after which a `Pending` pairing has been revoked. There is no verdict to
|
|
2195
|
+
* read apart from the envelope, so a caller cannot mistake a failure for a
|
|
2196
|
+
* match.
|
|
2130
2197
|
*
|
|
2131
2198
|
* # Safety
|
|
2132
2199
|
*
|
|
2133
|
-
* `handle`
|
|
2134
|
-
*
|
|
2135
|
-
*
|
|
2136
|
-
*
|
|
2200
|
+
* `handle` must be a valid pointer. `fingerprint_ptr` must be a valid
|
|
2201
|
+
* pointer to a NUL-terminated C string. Concurrent calls on the same handle
|
|
2202
|
+
* from different threads are safe: the handle's internal mutex serializes
|
|
2203
|
+
* them.
|
|
2137
2204
|
*/
|
|
2138
2205
|
struct DeRecError derec_protocol_verify_fingerprint(struct DeRecProtocolHandle *handle,
|
|
2139
2206
|
uint64_t channel_id,
|
|
2140
|
-
const char *fingerprint_ptr
|
|
2141
|
-
uint32_t *out_matched);
|
|
2207
|
+
const char *fingerprint_ptr);
|
|
2142
2208
|
|
|
2143
2209
|
/**
|
|
2144
2210
|
* Generate an out-of-band contact message used to bootstrap pairing.
|
|
@@ -2310,8 +2376,7 @@ struct ProduceStoreShareRequestMessageResult produce_store_share_request_message
|
|
|
2310
2376
|
uint64_t secret_id,
|
|
2311
2377
|
const uint8_t *committed_share_ptr,
|
|
2312
2378
|
size_t committed_share_len,
|
|
2313
|
-
|
|
2314
|
-
size_t keep_list_len,
|
|
2379
|
+
uint32_t keep_version,
|
|
2315
2380
|
const uint8_t *description_ptr,
|
|
2316
2381
|
size_t description_len,
|
|
2317
2382
|
const uint8_t *shared_key_ptr,
|
|
Binary file
|