Make sure prekey ids are non-zero

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-09 10:09:36 -05:00
committed by GitHub
parent 40b4b32db4
commit 07c3db0a21
2 changed files with 6 additions and 6 deletions

View File

@@ -2653,7 +2653,7 @@ export class SignalProtocolStore extends EventEmitter {
[pni]: registrationId,
}),
(async () => {
const newId = wrappingAdd24(signedPreKey.id(), 1);
const newId = Math.max(1, wrappingAdd24(signedPreKey.id(), 1));
log.warn(`${logId}: Updating next signed pre key id to ${newId}`);
await itemStorage.put(SIGNED_PRE_KEY_ID_KEY[ServiceIdKind.PNI], newId);
})(),
@@ -2671,7 +2671,7 @@ export class SignalProtocolStore extends EventEmitter {
if (!lastResortKyberPreKey) {
return;
}
const newId = wrappingAdd24(lastResortKyberPreKey.id(), 1);
const newId = Math.max(1, wrappingAdd24(lastResortKyberPreKey.id(), 1));
log.warn(`${logId}: Updating next kyber pre key id to ${newId}`);
await itemStorage.put(KYBER_KEY_ID_KEY[ServiceIdKind.PNI], newId);
})(),

View File

@@ -477,7 +477,7 @@ export default class AccountManager extends EventTarget {
signalProtocolStore.storePreKeys(ourServiceId, toSave),
itemStorage.put(
PRE_KEY_ID_KEY[serviceIdKind],
wrappingAdd24(startId, count)
Math.max(1, wrappingAdd24(startId, count))
),
]);
@@ -529,7 +529,7 @@ export default class AccountManager extends EventTarget {
signalProtocolStore.storeKyberPreKeys(ourServiceId, toSave),
itemStorage.put(
KYBER_KEY_ID_KEY[serviceIdKind],
wrappingAdd24(startId, count)
Math.max(1, wrappingAdd24(startId, count))
),
]);
@@ -689,7 +689,7 @@ export default class AccountManager extends EventTarget {
await itemStorage.put(
SIGNED_PRE_KEY_ID_KEY[serviceIdKind],
wrappingAdd24(signedKeyId, 1)
Math.max(1, wrappingAdd24(signedKeyId, 1))
);
return key;
@@ -761,7 +761,7 @@ export default class AccountManager extends EventTarget {
await itemStorage.put(
KYBER_KEY_ID_KEY[serviceIdKind],
wrappingAdd24(kyberKeyId, 1)
Math.max(1, wrappingAdd24(kyberKeyId, 1))
);
return record;