Commit Graph
19 Commits
Author SHA1 Message Date
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
Anay Wadhera ad6ac4b4a4 include missing str_cat header in ed25519 crypto
PiperOrigin-RevId: 563836632
2023-09-08 18:42:31 -07:00
Crisrael Lucero 0e44ed626d Refactor crypto/ directory into crypto_cros/ and crypto/
PiperOrigin-RevId: 549467911
2023-07-19 17:12:52 -07:00
Anay Wadhera 5917c87e73 Add ED25519 Keypair generator utilities to signer
PiperOrigin-RevId: 538034774
2023-06-05 18:25:00 -07:00
Anay Wadhera 71558c0a5c Add ed25519 signature utilities
PiperOrigin-RevId: 537351543
2023-06-02 10:45:40 -07:00
Timothy Hutchins 6e6929ac27 Fixed header changes in Clang 15 and GCC 13
Changes in the compilers made it to where some includes would not be
included in some headers (see [this](https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes) for more info) and one of those includes were `cstdint` / `stdint.h`. This commit brings the dependancy abseil-cpp to a commit that fixes that issue and included the relavent files in internel headers to fix the problem.
2023-05-16 10:46:50 -05:00
Hai Shang f1a1a7510b fix include paths
PiperOrigin-RevId: 525315412
2023-04-18 19:21:36 -07:00
Suet-Fei Li 31f3f53000 Fix crypto include path for Chromium.
PiperOrigin-RevId: 524452486
2023-04-14 20:56:29 -07:00
Suet-Fei Li 204f31b429 Remove internal/crypto/BUILD.gn as it should not be used.
PiperOrigin-RevId: 520779110
2023-03-30 16:59:20 -07:00
Nick Bourdakos cbf50a3d49 Add more visibilities
PiperOrigin-RevId: 518647351
2023-03-22 12:51:23 -07:00
Suet-Fei Li 32163382b9 Internal fix
PiperOrigin-RevId: 494245945
2022-12-09 13:10:37 -08:00
Nick Bourdakos ff5fb4a8f3 Replace absl/log/check.h with internal/platform/logging.h for SPM.
PiperOrigin-RevId: 494192824
2022-12-09 09:34:24 -08:00
Suet-Fei Li c5bb844509 Internal bug fix.
PiperOrigin-RevId: 494020404
2022-12-08 16:08:26 -08:00
Suet-Fei Li a8ca18f477 Internal refactor.
PiperOrigin-RevId: 493970269
2022-12-08 12:47:57 -08:00
Janusz Sobczak 0cb5b004e4 Add more Rand helper methods
PiperOrigin-RevId: 491409479
2022-11-28 12:14:19 -08:00
Anay Wadhera 74f7f5ec5c Fix visibility rules
PiperOrigin-RevId: 485897261
2022-11-03 09:44:47 -07:00
bourdakos 4c70daf66f Fix github build
PiperOrigin-RevId: 465689821
2022-08-05 18:44:37 -07:00
suetfei 4bf31d18da Internal Flow change
PiperOrigin-RevId: 465623255
2022-08-05 12:30:23 -07:00
suetfei 21c2c7c1ea Port crypto from location/nearby/cpp/sharing/implementation/internal/crypto to third_party/nearby/internal/crypto.
BEGIN_PUBLIC
Add crypto library to Nearby.
END_PUBLIC

Remove the reference to absl::SourceLocation as it is not in OSS.

PiperOrigin-RevId: 465427879
2022-08-04 16:11:00 -07:00