Commit Graph
185 Commits
Author SHA1 Message Date
Anthony Rueda 0eb6b57423 Update MapAction in advertisemet_decoder_rust_impl.cc to take any ActionBit.
PiperOrigin-RevId: 834418752
2025-11-19 13:22:40 -08:00
Francis Tsui 85a98dde84 internal changes
PiperOrigin-RevId: 821674793
2025-10-20 09:14:11 -07:00
Francis Tsui 520223f3b9 Add IS_VLOG_ON macro to platform logging.
PiperOrigin-RevId: 820402805
2025-10-16 14:47:30 -07:00
Guogang Li cce45b745e Internal refactor
PiperOrigin-RevId: 815749899
2025-10-06 09:03:08 -07:00
Anay Wadhera c957099ca0 Latest sync into repo with fixes
PiperOrigin-RevId: 813321071
2025-09-30 10:17:58 -07:00
Francis Tsui 52475a9cb3 Internal changes
PiperOrigin-RevId: 802310547
2025-09-02 15:32:47 -07:00
Ivo Ristovski List 038c73520d Automated Code Change
PiperOrigin-RevId: 802282871
2025-09-02 14:04:04 -07:00
Francis Tsui 000e12da8e Migrate platform to use MacAddress class.
PiperOrigin-RevId: 800631540
2025-08-28 15:14:16 -07:00
hai007 00a2999269 Format all the files in CL786733783
PiperOrigin-RevId: 786873870
2025-07-24 16:25:18 -07:00
hai007 71cdf84236 Replace NEARBY_LOGS with LOG for all coding under google3/third_party/nearby/
PiperOrigin-RevId: 786733783
2025-07-24 09:34:17 -07:00
Francis Tsui 30b32e52f2 internal change
PiperOrigin-RevId: 758393007
2025-05-13 15:12:11 -07:00
Francis Tsui b48b943275 Remove reference to BlePeripheral.
PiperOrigin-RevId: 757830081
2025-05-12 10:55:38 -07:00
Crisrael Lucero 531dd28400 Updated preprocessors to include correct LDT stub impl
PiperOrigin-RevId: 746121206
2025-04-10 12:04:28 -07:00
hai007 5faaac3565 Add back in Ldt stub impl, so it can be used in chromium
PiperOrigin-RevId: 742808756
2025-04-01 13:01:05 -07:00
Bryan Kersting 79ae5cab5a Fix unsound Rust reference in np_ffi_CredentialSlab_add_v0_credential
Currently, in the Rust implementation of `np_ffi_CredentialSlab_add_v0_credential`, we take the underlying buffer of the passed `V0MatchableCredential` and turn it into a Rust `&[u8]` by calling `unsafe slice::from_raw_parts`. The safety contract of `from_raw_parts` states that the passed pointer can neither be null, nor be unaligned. In the `advertisment_decoder_rust_impl.cc` we have a code path that leads to a null pointer being passed, though. We get a nullpointer if we pass a `std::vector` of size 0. This change fixes the issue by making sure we always pass a non-null buffer.

PiperOrigin-RevId: 729417182
2025-02-21 00:37:51 -08:00
hai007 05ae5583f8 Move crypto-related symbols from ::crypto:: to ::nearby::crypto:: to deconflict
them with chromium ::crypto symbols of the same names.

PiperOrigin-RevId: 684566882
2024-10-10 13:54:53 -07:00
hai007 1d2e43e931 Automated Code Change
PiperOrigin-RevId: 675305801
2024-09-16 15:10:32 -07:00
Guogang Li d5b5d92f87 Internal logging update
PiperOrigin-RevId: 669420403
2024-08-30 13:08:35 -07:00
Francis Tsui 4bca950bc7 Rename NEARBY_LOG() to NEARBY_LOG_OBSOLETE()
PiperOrigin-RevId: 667785090
2024-08-26 18:20:49 -07:00
Francis Tsui b03a383f7a Trivial replacement of NEARBY_LOG with NEARBY_LOGS.
PiperOrigin-RevId: 667740113
2024-08-26 15:34:21 -07:00
hai007 cdd6870af2 Use credential_id to correlate matched credential back to original
Upon succesfully dectypting an advertisements, the decoding library returns the id of the credential which was used to decrypt. We then use this id to correlate the decoded adv back to the original shared_credential which was used to decrypt it and save this and propagate it in the result returned to the caller

PiperOrigin-RevId: 646179759
2024-06-24 12:16:34 -07:00
Crisrael Lucero acc38a809b [Nearby Presence] Update ScanManager to trigger changed and lost events
PiperOrigin-RevId: 644072733
2024-06-17 11:17:00 -07:00
hai007 da927092e2 Fix build warnings from missing includes, unused includes or clang tidy
PiperOrigin-RevId: 633683523
2024-05-14 13:14:44 -07:00
Anay Wadhera f26d25ed01 Provide a platform abstraction for RandBytes instead of swapping headers
The `RandBytes` functions were being placed in the `crypto` namespace,
which collides with Chromium's namespace of the same name. Within,
`RandBytes` was defined with almost-the-same API. Then in Chromium
builds, the Chromium header would be used instead (though somewhat
inconsistently).

This creates a lot of pain for Chromium development as there's a
third-party repository directly depending on headers from Chromium's
source tree, and is against the third-party policies for that reason.
There are a number of other headers that mirror Chromium and are
swapped out in the Chromium build that will cause similar pain, such as:
```
include "crypto/aead.h"
include "crypto/ec_private_key.h"
include "crypto/hkdf.h"
```

This CL provides a template for how to get rid of these header swaps and
give a platform abstraction in nearby instead.

We provide a platform abstraction in `platform/crypto.h` (really in
`platform/implementation/crypto.h`) which is implemented in
`platform/implementation/shared/crypto.cc`. However that implementation
is removed by `#ifdef` when in the Chromium build.

Then, in the Chromium repo, we will add (separately) an implementation
of the same abstraction in `//third_party/nearby/platform_impl` with GN
rules to include it in the build. It will replace the implementation
from the nearby repo.

Copybara import of the project:

--
6ca8099 by danakj <danakj@chromium.org>:

Provide a platform abstraction for RandBytes instead of swapping headers

The `RandBytes` functions were being placed in the `crypto` namespace,
which collides with Chromium's namespace of the same name. Within,
`RandBytes` was defined with almost-the-same API. Then in Chromium
builds, the Chromium header would be used instead (though somewhat
inconsistently).

This creates a lot of pain for Chromium development as there's a
third-party repository directly depending on headers from Chromium's
source tree, and is against the third-party policies for that reason.
There are a number of other headers that mirror Chromium and are
swapped out in the Chromium build that will cause similar pain, such as:
```
include "crypto/aead.h"
include "crypto/ec_private_key.h"
include "crypto/hkdf.h"
```

This CL provides a template for how to get rid of these header swaps and
give a platform abstraction in nearby instead.

We provide a platform abstraction in `platform/crypto.h` (really in
`platform/implementation/crypto.h`) which is implemented in
`platform/implementation/shared/crypto.cc`. However that implementation
is removed by `#ifdef` when in the Chromium build.

Then, in the Chromium repo, we will add (separately) an implementation
of the same abstraction in `//third_party/nearby/platform_impl` with GN
rules to include it in the build. It will replace the implementation
from the nearby repo.

--
9c2654b by danakj <danakj@chromium.org>:

Remove CryptoSpan, use absl::Span

The header swapping of Chromium crypto libraries is
problematic, but absl::Span will convert to base::span
so there's no need for the typedef even without
removing the header swapping yet.

--
df1135d by danakj <danakj@chromium.org>:

Add missing files

--
ab18a15 by danakj <danakj@chromium.org>:

Remove the random_unittest.cc from Swift build

The file moved, so the Swift package needs its path
updated.

--
2038f78 by danakj <danakj@chromium.org>:

Combine crypto unittests into crypto_test.cc

--
f7ad176 by danakj <danakj@chromium.org>:

Add stdint and stddef includes for uint8_t and size_t

--
9f04590 by danakj <danakj@chromium.org>:

Mark the shared crypto implementation compatable_with non_prod

--
18eeafd by danakj <danakj@chromium.org>:

Add IWYU pragma for crypto implementation

PiperOrigin-RevId: 632150866
2024-05-09 08:02:50 -07:00
hai007 112da1a737 Remove extra semi which breaks ChromeOs build
PiperOrigin-RevId: 631928582
2024-05-08 14:39:28 -07:00
Hai Shang bc44fee374 use abs to make sure the id is not negative
PiperOrigin-RevId: 631891168
2024-05-08 12:42:34 -07:00
hai007 a632a1f691 Cleanup header includes
including log/check.h directly leads to a build error on chrome

PiperOrigin-RevId: 631864164
2024-05-08 11:18:51 -07:00
Ryan Hansberry cc84b6f4a4 Make credential refill asynchronous
Fixes a ChromeOS-deadlock during credential refill. The
previous logic blocked the IO thread that ChromeOS is using
to listen for responses from its CredentialStorage layer,
thus preventing it from signaling the latch.

Given that CheckCredentialsAndRefillIfNeeded is meant to
be async (given its continuation-passing style), this CL
avoids any thread trickiness by removing any latch-waiting
within the function. The nice side-effect of this is breaking
up the function into 3 smaller functions, which should
hopefully make it a bit more readable.

//.../g3/credential_storage_impl.cc has its mutex locks
removed -- they otherwise cause deadlocks, and are now
unnecessary.

This CL introduces a CHECK_EQ to ensure that the number of
remaining valid (not-expired) credentials is equal across the
shared and local list. This actually exposed a bug in the
credential_manager_impl_test.cc -- the test was only expiring
a public credential, and not its corresponding private credential.
Thus, the test is also updated in this CL to correctly mark
the first credential of the shared and local list as expired.

PiperOrigin-RevId: 631822135
2024-05-08 09:14:53 -07:00
Hai Shang 17df967296 replace secrect_id to id inside presence credential manager
PiperOrigin-RevId: 630558485
2024-05-03 19:28:48 -07:00
hai007 50c1838e00 Use rust based decoding logic by default
PiperOrigin-RevId: 629850723
2024-05-01 15:09:13 -07:00
hai007 464380d931 Implement action bit parsing logic for rust implemented decoder
- This does not change any public APIs, but makes the rust backed impl fill in
   the values of the current public API.

PiperOrigin-RevId: 629844656
2024-05-01 14:48:28 -07:00
Crisrael Lucero fb4099455e [Nearby Presence] Use different include path for NEARBY_CHROMIUM Rust ldt
PiperOrigin-RevId: 629810240
2024-05-01 13:00:00 -07:00
hai007 bba1ca540f Remove provisioned identity type from proto
PiperOrigin-RevId: 629178167
2024-04-29 13:59:55 -07:00
hai007 0b04994f71 Update identity type name
PiperOrigin-RevId: 629163344
2024-04-29 13:12:45 -07:00
hai007 a1b80ff649 Update identity type name
PiperOrigin-RevId: 628545355
2024-04-26 16:57:25 -07:00
hai007 54eff829b5 Update identity type name
PiperOrigin-RevId: 628513553
2024-04-26 14:40:17 -07:00
hai007 f4bad55cac Internal change
PiperOrigin-RevId: 628207314
2024-04-25 15:23:36 -07:00
hai007 e9b57452b1 Remove LDT build flag, build against rust ldt by default
PiperOrigin-RevId: 628196553
2024-04-25 14:47:07 -07:00
hai007 eba96c9673 Remove unused include to fix OSS build
PiperOrigin-RevId: 627473304
2024-04-23 12:42:17 -07:00
hai007 47caa7979a Fix copybara export of build rules for beto-core
PiperOrigin-RevId: 627464568
2024-04-23 12:09:50 -07:00
hai007 e9c39b46b3 Fix copybara export of beto-core headers
PiperOrigin-RevId: 627449838
2024-04-23 11:23:24 -07:00
hai007 1c4bd01fe6 Update presence build rules and copybara export to OSS
- updates the build to be compatible with ldt in the open source repo

PiperOrigin-RevId: 627415836
2024-04-23 09:40:55 -07:00
hai007 d1f3a91e24 Initial implementation of rust decoder
PiperOrigin-RevId: 624312324
2024-04-12 15:40:44 -07:00
Ryan Hansberry f788b89190 [NearbyPresence] Fix typo: remove extraneous semicolon.
PiperOrigin-RevId: 623198081
2024-04-09 09:54:23 -07:00
hai007 734014a841 Add build flag to switch between C++ and rust implemented parser
- Both implementations implement `AdvertisementDecoder` interface and provide the
   concrete implementation for AdvertisementDecoderImpl
 - cleanup missing includes as complained about by clang-tidy

PiperOrigin-RevId: 621187625
2024-04-02 08:43:31 -07:00
hai007 112da5e64a Refactor, remove scan_request dependency from AdvertisementDecoder
- Removes banned_data_types_, PUBLIC identity advertisements will never have
   any corresponding credentials anyways, so decryption will always be skipped
   and this is now guarenteed by asserts in UpdatePublicCredentials
 - Filtering adv based on identity is moved into advertisement Filter which
   already contains the requested identity info from scan_request
 - LegacyPresenceScanFilter is no longer used by AdvertisementDecoder since
   this is not being used anywhere at the moment
 - Cleanup miscellaneous clang-tidy lints about missing or unused includes

PiperOrigin-RevId: 620086399
2024-03-28 16:15:37 -07:00
hai007 b224eb7bf8 Internal change
PiperOrigin-RevId: 619658526
2024-03-27 17:31:38 -07:00
hai007 5bc1c83472 Pure Refactor: move filtering logic into AdvertisementFilter class
- this decouples filtering logic from advertisement decoding logic
   in preparation for introducing a Rust backed impl of
   AdvertisementDecoder
 - this change is only a refactor and does not change functionality
   in any way

PiperOrigin-RevId: 618978564
2024-03-25 15:33:20 -07:00
Suet-Fei Li 989efcf2c5 Metadata to DeviceIdentityMetaData Migration
PiperOrigin-RevId: 616182462
2024-03-15 10:57:58 -07:00
Ryan Hansberry 8561d03a21 [Nearby] CredentialManager: Do not block on main thread.
PiperOrigin-RevId: 608743138
2024-02-20 14:37:12 -08:00