mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
update SocialBackupValidator
This commit is contained in:
@@ -47,16 +47,11 @@ class SocialBackupValidator extends BdfMessageValidator {
|
|||||||
|
|
||||||
private BdfMessageContext validateShardMessage(BdfList body)
|
private BdfMessageContext validateShardMessage(BdfList body)
|
||||||
throws FormatException {
|
throws FormatException {
|
||||||
// Message type, secret ID, num shards, threshold, shard
|
// Message type, secret ID, shard
|
||||||
checkSize(body, 5);
|
checkSize(body, 3);
|
||||||
byte[] secretId = body.getRaw(1);
|
byte[] secretId = body.getRaw(1);
|
||||||
checkLength(secretId, SECRET_ID_BYTES);
|
checkLength(secretId, SECRET_ID_BYTES);
|
||||||
int numShards = body.getLong(2).intValue();
|
byte[] shard = body.getRaw(2);
|
||||||
if (numShards < 2) throw new FormatException();
|
|
||||||
int threshold = body.getLong(3).intValue();
|
|
||||||
if (threshold < 2) throw new FormatException();
|
|
||||||
if (threshold > numShards) throw new FormatException();
|
|
||||||
byte[] shard = body.getRaw(4);
|
|
||||||
checkLength(shard, 1, MAX_SHARD_BYTES);
|
checkLength(shard, 1, MAX_SHARD_BYTES);
|
||||||
BdfDictionary meta = BdfDictionary.of(
|
BdfDictionary meta = BdfDictionary.of(
|
||||||
new BdfEntry(MSG_KEY_MESSAGE_TYPE, SHARD.getValue()),
|
new BdfEntry(MSG_KEY_MESSAGE_TYPE, SHARD.getValue()),
|
||||||
|
|||||||
Reference in New Issue
Block a user