mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Add bindingId to public certificate.
PiperOrigin-RevId: 878755661
This commit is contained in:
committed by
Copybara-Service
parent
38e660e37a
commit
a2ec10a07e
@@ -188,7 +188,7 @@ NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate(
|
||||
return NearbyShareDecryptedPublicCertificate(
|
||||
not_before, not_after, std::move(secret_key), std::move(public_key),
|
||||
std::move(id), std::move(unencrypted_metadata),
|
||||
public_certificate.for_self_share());
|
||||
public_certificate.for_self_share(), public_certificate.binding_id());
|
||||
}
|
||||
|
||||
NearbyShareDecryptedPublicCertificate::NearbyShareDecryptedPublicCertificate(
|
||||
@@ -196,14 +196,15 @@ NearbyShareDecryptedPublicCertificate::NearbyShareDecryptedPublicCertificate(
|
||||
std::unique_ptr<crypto::SymmetricKey> secret_key,
|
||||
std::vector<uint8_t> public_key, std::vector<uint8_t> id,
|
||||
nearby::sharing::proto::EncryptedMetadata unencrypted_metadata,
|
||||
bool for_self_share)
|
||||
bool for_self_share, std::string binding_id)
|
||||
: not_before_(not_before),
|
||||
not_after_(not_after),
|
||||
secret_key_(std::move(secret_key)),
|
||||
public_key_(std::move(public_key)),
|
||||
id_(std::move(id)),
|
||||
unencrypted_metadata_(std::move(unencrypted_metadata)),
|
||||
for_self_share_(for_self_share) {}
|
||||
for_self_share_(for_self_share),
|
||||
binding_id_(std::move(binding_id)) {}
|
||||
|
||||
NearbyShareDecryptedPublicCertificate::NearbyShareDecryptedPublicCertificate(
|
||||
const NearbyShareDecryptedPublicCertificate& other) {
|
||||
@@ -223,6 +224,7 @@ NearbyShareDecryptedPublicCertificate::operator=(
|
||||
id_ = other.id_;
|
||||
unencrypted_metadata_ = other.unencrypted_metadata_;
|
||||
for_self_share_ = other.for_self_share_;
|
||||
binding_id_ = other.binding_id_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/time/time.h"
|
||||
@@ -68,6 +69,8 @@ class NearbyShareDecryptedPublicCertificate {
|
||||
|
||||
bool for_self_share() const { return for_self_share_; }
|
||||
|
||||
const std::string& binding_id() const { return binding_id_; }
|
||||
|
||||
// Verifies the |signature| of the signed |payload| using |public_key_|.
|
||||
// Returns true if verification was successful.
|
||||
bool VerifySignature(absl::Span<const uint8_t> payload,
|
||||
@@ -85,7 +88,7 @@ class NearbyShareDecryptedPublicCertificate {
|
||||
std::unique_ptr<crypto::SymmetricKey> secret_key,
|
||||
std::vector<uint8_t> public_key, std::vector<uint8_t> id,
|
||||
nearby::sharing::proto::EncryptedMetadata unencrypted_metadata,
|
||||
bool for_self_share);
|
||||
bool for_self_share, std::string binding_id);
|
||||
|
||||
// The start and end times of the certificate's validity period. To avoid
|
||||
// issues with clock skew, these times may be offset compared to the
|
||||
@@ -111,6 +114,10 @@ class NearbyShareDecryptedPublicCertificate {
|
||||
// Indicates if this public certificate is from another device owned by the
|
||||
// same user.
|
||||
bool for_self_share_ = false;
|
||||
|
||||
// The binding id of device pair binding. If multiple bindings exist
|
||||
// between two devices, it will return the newest binding_id.
|
||||
std::string binding_id_;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
|
||||
@@ -50,6 +50,7 @@ TEST(NearbyShareDecryptedPublicCertificateTest, Decrypt) {
|
||||
PublicCertificate proto_cert =
|
||||
GetNearbyShareTestPublicCertificate(kTestPublicCertificateVisibility);
|
||||
proto_cert.set_for_self_share(true);
|
||||
proto_cert.set_binding_id("binding_id");
|
||||
|
||||
std::optional<NearbyShareDecryptedPublicCertificate> cert =
|
||||
NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate(
|
||||
@@ -65,6 +66,7 @@ TEST(NearbyShareDecryptedPublicCertificateTest, Decrypt) {
|
||||
EXPECT_EQ(GetNearbyShareTestMetadata().SerializeAsString(),
|
||||
cert->unencrypted_metadata().SerializeAsString());
|
||||
EXPECT_EQ(proto_cert.for_self_share(), cert->for_self_share());
|
||||
EXPECT_EQ(proto_cert.binding_id(), cert->binding_id());
|
||||
}
|
||||
|
||||
TEST(NearbyShareDecryptedPublicCertificateTest, Decrypt_IncorrectKeyFailure) {
|
||||
|
||||
@@ -27,7 +27,7 @@ option optimize_for = LITE_RUNTIME;
|
||||
// How a Certificate is distributed is determined by who is on a user's contact
|
||||
// list. For example, if Will adds Ryan to his contact list, Ryan will have a
|
||||
// ShareTarget with Will's Certificate attached to it.
|
||||
// NextId=11
|
||||
// NextId=13
|
||||
message PublicCertificate {
|
||||
// The secret (symmetric) identifier used when identifying the ShareTarget's
|
||||
// BLE advertisement.
|
||||
@@ -66,6 +66,12 @@ message PublicCertificate {
|
||||
// Indicates if this public certificate corresponds to a device owned by the
|
||||
// current user.
|
||||
bool for_self_share = 10;
|
||||
|
||||
reserved 11;
|
||||
|
||||
// The binding id of device pair binding. If multiple bindings exist
|
||||
// between two devices, it will return the newest binding_id.
|
||||
string binding_id = 12;
|
||||
}
|
||||
|
||||
// A member of a contact list. This is not inlined on the recommendation of
|
||||
@@ -159,4 +165,6 @@ message Device {
|
||||
// The public certificates generated and uploaded from local device, to be
|
||||
// shared with contacts.
|
||||
repeated PublicCertificate public_certificates = 4;
|
||||
|
||||
reserved 5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user