Move credentials related proto from Prensence to internal

Replace PresenceIdentityType with proto

PiperOrigin-RevId: 467294239
This commit is contained in:
Xin He
2022-08-12 14:18:34 -07:00
committed by Copybara-Service
parent 2327ab219c
commit 123a2cfd18
21 changed files with 108 additions and 97 deletions
+1 -1
View File
@@ -76,8 +76,8 @@ cc_library(
"//internal/platform:base",
"//internal/platform:cancellation_flag",
"//internal/platform:uuid",
"//internal/proto:credential_cc_proto",
"//presence:credential",
"//presence/proto:credential_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/strings",
],
@@ -21,25 +21,26 @@
#include <vector>
#include "internal/platform/exception.h"
#include "internal/proto/credential.pb.h"
#include "presence/presence_identity.h"
#include "presence/proto/credential.pb.h"
namespace location {
namespace nearby {
namespace api {
using ::nearby::presence::PresenceIdentity;
using ::nearby::presence::proto::PrivateCredential;
using ::nearby::presence::proto::PublicCredential;
using ::nearby::internal::IdentityType;
using ::nearby::internal::PrivateCredential;
using ::nearby::internal::PublicCredential;
enum class CredentialOperationStatus {
kFailed = 0,
kSucceeded = 1,
kUnknown = 0,
kFailed = 1,
kSucceeded = 2,
};
struct CredentialSelector {
std::string account_name;
PresenceIdentity::IdentityType identity_type;
IdentityType identity_type;
};
enum PublicCredentialType {
+26
View File
@@ -0,0 +1,26 @@
proto_library(
name = "device_metadata_proto",
srcs = ["device_metadata.proto"],
)
cc_proto_library(
name = "device_metadata_cc_proto",
visibility = [
"//third_party/nearby:__subpackages__",
],
deps = [":device_metadata_proto"],
)
proto_library(
name = "credential_proto",
srcs = ["credential.proto"],
deps = [":device_metadata_proto"],
)
cc_proto_library(
name = "credential_cc_proto",
visibility = [
"//third_party/nearby:__subpackages__",
],
deps = [":credential_proto"],
)
+80
View File
@@ -0,0 +1,80 @@
syntax = "proto2";
package nearby.internal;
import "internal/proto/device_metadata.proto";
option java_package = "com.google.nearby.presence";
enum IdentityType {
IDENTITY_TYPE_UNSPECIFIED = 0;
IDENTITY_TYPE_PRIVATE = 1;
IDENTITY_TYPE_TRUSTED = 2;
IDENTITY_TYPE_PUBLIC = 3;
IDENTITY_TYPE_PROVISIONED = 4;
}
// A proto to store the local device's private credential.
message PrivateCredential {
optional IdentityType identity_type = 1;
// The unique id of (and hashed based on) a pair of secret
// key (PrivateCredential.verification_key) and X509Certificate's public
// key (PublicCredential.verification_key).
optional bytes secret_id = 2;
// The aes key to encrypt personal fields in public certificates.
// A bytes representation of a Secret Key owned by contact, to decrypt the
// encrypted DeviceMetadata bytes stored within the advertisement.
optional bytes authenticity_key = 3;
// Bytes representation of a private key of X509Certificate, used in
// handshake during contact verification phase.
optional bytes verification_key = 4;
// The time in millis from epoch when this credential becomes effective.
optional uint64 start_time_millis = 5;
// The time in millis from epoch when this credential expires.
optional uint64 end_time_millis = 6;
// The set of 2-byte salts already used to encrypt the metadata key.
map<uint32, bool> consumed_salts = 7;
// The aes key to encrypt DeviceMetadata in public credential.
optional bytes metadata_encryption_key = 8;
// The device metadata relates to this private credential.
optional DeviceMetadata device_metadata = 9;
}
message PublicCredential {
optional IdentityType identity_type = 1;
// The unique id of (and hashed based on) a pair of secret
// key (PrivateCredential.verification_key) and X509Certificate's public
// key (PublicCredential.verification_key).
optional bytes secret_id = 2;
// Bytes representation of a Secret Key owned by contact, to decrypt the
// metadata_key stored within the advertisement.
optional bytes authenticity_key = 3;
// Bytes representation of a public key of X509Certificate, used in
// handshake during contact verification phase.
optional bytes verification_key = 4;
// The time in millis from epoch when this credential becomes effective.
optional uint64 start_time_millis = 5;
// The time in millis from epoch when this credential expires.
optional uint64 end_time_millis = 6;
// The encrypted DeviceMetadata in bytes, contains personal information of the
// device/user who created this certificate. Needs to be decrypted into bytes,
// and converted back to DeviceMetadata instance to access fields.
optional bytes encrypted_metadata_bytes = 7;
// The tag for verifying metadata_encryption_key.
optional bytes metadata_encryption_key_tag = 8;
}
+34
View File
@@ -0,0 +1,34 @@
syntax = "proto2";
package nearby.internal;
// A proto to store the local device's metadata.
message DeviceMetadata {
// Stable device identifier that does not rotate for a few months.
optional string stable_device_id = 1;
// The account name which created the credential.
optional string account_name = 2;
// The name of the local device when the credential is created.
optional string device_name = 3;
// The icon url of the user whose device created the certificate.
optional string icon_url = 4;
// The Bluetooth MAC address of the device which created the certificate.
optional string bluetooth_mac_address = 5;
/** The types of the device. */
enum DeviceType {
UNSPECIFIED = 0;
PHONE = 1;
TABLET = 2;
DISPLAY = 3;
LAPTOP = 4;
TV = 5;
WATCH = 6;
}
optional DeviceType device_type = 6;
}