Enforce key-ids fit in a positive signed 32-bit int

This commit is contained in:
Ravi Khadiwala
2026-04-27 18:55:10 -05:00
committed by Chris Eager
parent de5cb3370d
commit b441fde213
2 changed files with 4 additions and 4 deletions
@@ -5,7 +5,7 @@
package org.whispersystems.textsecuregcm.storage;
public class KeyIdUtil {
public static final long MAX_KEY_ID = (1L << 32) - 1;
public static final long MAX_KEY_ID = (1L << 31) - 1;
public static final long MIN_KEY_ID = 0;
private KeyIdUtil(){}
@@ -41,7 +41,7 @@ message EcPreKey {
// A locally-unique identifier for this key, which will be provided by
// peers using this key to encrypt messages so the private key can be looked
// up.
uint32 key_id = 1;
int32 key_id = 1 [(require.range).min = 0];
// The public key, serialized in libsignal's elliptic-curve public key format.
bytes public_key = 2 [(require.nonEmpty) = true];
@@ -51,7 +51,7 @@ message EcSignedPreKey {
// A locally-unique identifier for this key, which will be provided by
// peers using this key to encrypt messages so the private key can be looked
// up.
uint32 key_id = 1;
int32 key_id = 1 [(require.range).min = 0];
// The public key, serialized in libsignal's elliptic-curve public key format.
bytes public_key = 2 [(require.nonEmpty) = true];
@@ -64,7 +64,7 @@ message EcSignedPreKey {
message KemSignedPreKey {
// An locally-unique identifier for this key, which will be provided by peers
// using this key to encrypt messages so the private key can be looked up.
uint32 key_id = 1;
int32 key_id = 1 [(require.range).min = 0];
// The public key, serialized in libsignal's Kyber1024 public key format.
bytes public_key = 2 [(require.nonEmpty) = true];