Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Fix broken build on macOS.
Browse files Browse the repository at this point in the history
The issue was with grpc: bazelbuild/bazel#4341

PiperOrigin-RevId: 245104328
  • Loading branch information
tl0gic authored and copybara-github committed May 10, 2019
1 parent 1f7043b commit 05a608f
Show file tree
Hide file tree
Showing 26 changed files with 119 additions and 273 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Tink

*A multi-language, cross-platform library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.*

**`Ubuntu`** | **`macOS`**
---------------------------------------------------------------------------------------------- | -----------
[![Kokoro Ubuntu](https://storage.googleapis.com/tink-kokoro-build-badges/tink-ubuntu.png)](#) | [![Kokoro macOS](https://storage.googleapis.com/tink-kokoro-build-badges/tink-macos.png)](#)

## Index

1. [Introduction](#introduction)
2. [Getting started](#getting-started)
3. [Current status](#current-status)
4. [Learn more](#learn-more)
5. [Contact and mailing list](#contact-and-mailing-list)
2. [Getting Started](#getting-started)
3. [Current Status](#current-status)
4. [Learn More](#learn-more)
5. [Contact and Mailing List](#contact-and-mailing-list)
6. [Maintainers](#maintainers)

## Introduction
Expand All @@ -37,6 +35,7 @@ To get a quick overview of Tink design please take a look at
talk about Tink](https://www.youtube.com/watch?v=pqev9r3rUJs&t=9665) presented
at [Real World Crypto 2019](https://rwc.iacr.org/2019/).


## Getting started

**TIP** The easiest way to get started with Tink is to install
Expand Down Expand Up @@ -94,7 +93,7 @@ AEAD primitive in Java:
byte[] ciphertext = aead.encrypt(plaintext, associatedData);
```

## Current status
## Current Status

* [Java and Android](docs/JAVA-HOWTO.md), [C++](docs/CPP-HOWTO.md) and
[Obj-C](docs/OBJC-HOWTO.md) are field tested and ready for production. The
Expand All @@ -104,7 +103,7 @@ AEAD primitive in Java:

* Tink for Go and JavaScript are in active development.

## Learn more
## Learn More

* [Java HOW-TO](docs/JAVA-HOWTO.md)
* [C++ HOW-TO](docs/CPP-HOWTO.md)
Expand All @@ -127,7 +126,6 @@ ported it to their favorite languages! Below you can find notable ports.
maintain them and have no plan to support them in the foreseeable future.

* [C# (with JNI)](https://github.com/google-pay/tink-jni-examples)
* [Clojure](https://github.com/perkss/tinklj)

## Contact and mailing list

Expand Down
23 changes: 3 additions & 20 deletions apps/rewardedads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,11 @@
This app implements the verifier side of Server-Side Verification of Google
AdMob Rewarded Ads.

## Latest Release

The most recent release is
[1.2.2](https://github.com/google/tink/releases/tag/v1.2.2), released
2019-01-24. API docs can be found
[here](https://google.github.com/tink/javadoc/apps-rewardedads/1.2.2).

The Maven group ID is `com.google.crypto.tink`, and the artifact ID is
`apps-rewardedads`.

To add a dependency using Maven:

```xml
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>apps-rewardedads</artifactId>
<version>1.2.2</version>
</dependency>
```

## Snapshots

This app has yet not been released, though you can still play with it using
snapshot versions.

Snapshots of this app built from the master branch are available through Maven
using version `HEAD-SNAPSHOT`. API docs can be found
[here](https://google.github.com/tink/javadoc/apps-rewardedads/HEAD-SNAPSHOT).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ public Map<Long, ECPublicKey> get() throws GeneralSecurityException {
* {
* "keys": [
* {
* keyId: 1916455855,
* key_id: 1916455855,
* pem: "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUaWMKcBHWdhUE+DncSIHhFCLLEln\nUs0LB9oanZ4K/FNICIM8ltS4nzc9yjmhgVQOlmSS6unqvN9t8sqajRTPcw==\n-----END PUBLIC KEY-----"
* base64: "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUaWMKcBHWdhUE+DncSIHhFCLLElnUs0LB9oanZ4K/FNICIM8ltS4nzc9yjmhgVQOlmSS6unqvN9t8sqajRTPcw=="
* },
* {
* keyId: 3901585526,
* key_id: 3901585526,
* pem: "-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEtxg2BsK/fllIeADtLspezS6YfHFWXZ8tiJncm8LDBa/NxEC84akdWbWDCUrMMGIV27/3/e7UuKSEonjGvaDUsw==\n-----END PUBLIC KEY-----"
* base64: "MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEtxg2BsK/fllIeADtLspezS6YfHFWXZ8tiJncm8LDBa/NxEC84akdWbWDCUrMMGIV27/3/e7UuKSEonjGvaDUsw=="
* },
Expand Down
4 changes: 2 additions & 2 deletions cc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,8 @@ cc_test(
)

cc_test(
name = "core/template_util_test",
srcs = ["core/template_util_test.cc"],
name = "core/template_utils_test",
srcs = ["core/template_utils_test.cc"],
deps = [
":core/template_util",
"@com_google_googletest//:gtest_main",
Expand Down
8 changes: 3 additions & 5 deletions cc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ tink_cc_library(
SRCS
core/internal_key_manager.h
DEPS
absl::hash
absl::container
tink::core::internal_key_manager
tink::proto::tink_cc_proto
Expand Down Expand Up @@ -594,7 +593,6 @@ tink_cc_test(
tink::proto::common_cc_proto
tink::proto::tink_cc_proto
absl::memory
gmock
)

tink_cc_test(
Expand Down Expand Up @@ -759,10 +757,10 @@ tink_cc_test(
)

tink_cc_test(
NAME template_util_test
SRCS core/template_util_test.cc
NAME template_utils_test
SRCS core/template_utils_test.cc
DEPS
tink::core::template_util
tink::core::template_utils
)

tink_cc_test(
Expand Down
1 change: 0 additions & 1 deletion cc/aead/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ tink_cc_test(
SRCS kms_envelope_aead_key_manager_test.cc
DEPS
tink::aead::aead_config
tink::aead::aead_key_templates
tink::aead::kms_envelope_aead_key_manager
tink::core::aead
tink::core::kms_client
Expand Down
59 changes: 38 additions & 21 deletions cc/core/internal_key_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//
///////////////////////////////////////////////////////////////////////////////

#ifndef TINK_CORE_INTERNAL_KEY_MANAGER_H_
#define TINK_CORE_INTERNAL_KEY_MANAGER_H_
#ifndef TINK_INTERNAL_KEY_MANAGER_H_
#define TINK_INTERNAL_KEY_MANAGER_H_

#include <typeindex>

Expand Down Expand Up @@ -53,10 +53,6 @@ class InternalKeyFactory<KeyProto, void> {

} // namespace internal

template <typename KeyProto, typename KeyFormatProto,
typename PrimitivesTuple>
class InternalKeyManager;

// An InternalKeyManager manages a single key proto. This includes
// * parsing and validating keys
// * parsing and validating key formats (in case generating keys is allowed).
Expand All @@ -66,35 +62,30 @@ class InternalKeyManager;
// the key manager cannot produce keys and a protobuf otherwise.
//
// The constructor should take unique pointers to primitive factories.
//
// InternalKeyManager uses templates for KeyProto, KeyFormatProto and a list of
// Primitives which have to be provided as a std::tuple.
template <typename KeyProto, typename KeyFormatProto,
typename... Primitives>
class InternalKeyManager<KeyProto, KeyFormatProto,
std::tuple<Primitives...>>
template <typename KeyProto, typename KeyFormatProto = void>
class InternalKeyManager
: public internal::InternalKeyFactory<KeyProto, KeyFormatProto> {
public:
// A PrimitiveFactory<Primitive> knows how to create instances of the
// Primitive.
template <typename Primitive>
class PrimitiveFactory {
public:
// Used for template deduction.
using UnderlyingPrimitive = Primitive;

virtual ~PrimitiveFactory() {}
virtual crypto::tink::util::StatusOr<std::unique_ptr<Primitive>> Create(
const KeyProto& key) const = 0;
};

// Creates a new InternalKeyManager. The parameter(s) primitives must be some
// number of unique_ptr<PrimitiveFactory<P>> types.
template <typename... PrimitiveFactories>
explicit InternalKeyManager(
std::unique_ptr<PrimitiveFactory<Primitives>>... primitives) {
static_assert(
!crypto::tink::internal::HasDuplicates<Primitives...>::value,
"List or primitives contains a duplicate, which is not allowed.");
// https://stackoverflow.com/questions/17339789/how-to-call-a-function-on-all-variadic-template-args
ABSL_ATTRIBUTE_UNUSED
int unused[] = {(AddPrimitive(std::move(primitives)), 0)...};
std::unique_ptr<PrimitiveFactories>... primitives) {
AddAllPrimitives<typename PrimitiveFactories::UnderlyingPrimitive...>(
std::move(primitives)...);
}

// Returns the type_url identifying the key type handled by this manager.
Expand Down Expand Up @@ -127,13 +118,39 @@ class InternalKeyManager<KeyProto, KeyFormatProto,
}

private:
// Actual helper function to put the primitive factories into the hash map
// primitive_factories_. Only enabled if the primitives in the given
// Primitives template parameters are distinct.
template <typename... Primitives>
typename std::enable_if<
!crypto::tink::internal::HasDuplicates<Primitives...>::value>::type
AddAllPrimitives(
std::unique_ptr<PrimitiveFactory<Primitives>>... primitives) {
// https://stackoverflow.com/questions/17339789/how-to-call-a-function-on-all-variadic-template-args
ABSL_ATTRIBUTE_UNUSED
int unused[] = {(AddPrimitive(std::move(primitives)), 0)...};
}

// Helper function which adds a single primivie.
template <typename Primitive>
void AddPrimitive(std::unique_ptr<PrimitiveFactory<Primitive>> primitive) {
primitive_factories_.emplace(std::type_index(typeid(Primitive)),
std::move(primitive));
}

// Replacement helper function for AddAllPrimitives which always fails with
// an error message when compiling. Only enabled if at least one primitive
// appears at least twice.
template <typename... Primitives>
typename std::enable_if<
crypto::tink::internal::HasDuplicates<Primitives...>::value>::type
AddAllPrimitives(
std::unique_ptr<PrimitiveFactory<Primitives>>... primitives) {
static_assert(sizeof(KeyProto) < 0,
"The list of arguments to InternalKeyManager contains two "
"PrimitiveFactory objects for the same primitive.");
}

// We use a shared_ptr here because shared_ptr<void> is valid (as opposed to
// unique_ptr<void>, where we would have to add a custom deleter with extra
// work).
Expand All @@ -144,4 +161,4 @@ class InternalKeyManager<KeyProto, KeyFormatProto,
} // namespace tink
} // namespace crypto

#endif // TINK_CORE_INTERNAL_KEY_MANAGER_H_
#endif // TINK_INTERNAL_KEY_MANAGER_H_
6 changes: 2 additions & 4 deletions cc/core/internal_key_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class AeadVariant {
};

class ExampleInternalKeyManager
: public InternalKeyManager<AesGcmKey, AesGcmKeyFormat,
std::tuple<Aead, AeadVariant>> {
: public InternalKeyManager<AesGcmKey, AesGcmKeyFormat> {
public:
class AeadFactory : public PrimitiveFactory<Aead> {
public:
Expand Down Expand Up @@ -138,8 +137,7 @@ TEST(KeyManagerTest, CreateFails) {
}

class ExampleInternalKeyManagerWithoutFactory
: public InternalKeyManager<AesGcmKey, void,
std::tuple<Aead, AeadVariant>> {
: public InternalKeyManager<AesGcmKey> {
public:
class AeadFactory : public PrimitiveFactory<Aead> {
public:
Expand Down
File renamed without changes.
55 changes: 27 additions & 28 deletions cc/integration/gcpkms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ cc_library(
name = "gcp_kms_client",
srcs = ["gcp_kms_client.cc"],
hdrs = ["gcp_kms_client.h"],
include_prefix = "tink",
strip_include_prefix = "/cc",
include_prefix = "tink",
deps = [
":gcp_kms_aead",
"//cc:kms_client",
Expand All @@ -47,30 +47,29 @@ cc_library(

# tests

# TODO(b/119547792): Temporarily disabling until reliability concerns are addressed.
#cc_test(
# name = "gcp_kms_aead_test",
# size = "medium",
# srcs = ["gcp_kms_aead_test.cc"],
# deps = [
# ":gcp_kms_aead",
# "//cc/util:errors",
# "//cc/util:status",
# "//cc/util:statusor",
# "@com_google_googletest//:gtest_main",
# ],
#)
#
#cc_test(
# name = "gcp_kms_client_test",
# size = "medium",
# srcs = ["gcp_kms_client_test.cc"],
# data = ["//testdata:credentials"],
# deps = [
# ":gcp_kms_client",
# "//cc/util:errors",
# "//cc/util:status",
# "//cc/util:statusor",
# "@com_google_googletest//:gtest_main",
# ],
#)
cc_test(
name = "gcp_kms_aead_test",
size = "medium",
srcs = ["gcp_kms_aead_test.cc"],
deps = [
":gcp_kms_aead",
"//cc/util:errors",
"//cc/util:status",
"//cc/util:statusor",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "gcp_kms_client_test",
size = "medium",
srcs = ["gcp_kms_client_test.cc"],
data = ["//testdata:credentials"],
deps = [
":gcp_kms_client",
"//cc/util:errors",
"//cc/util:status",
"//cc/util:statusor",
"@com_google_googletest//:gtest_main",
],
)
15 changes: 1 addition & 14 deletions cc/util/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ cc_library(
include_prefix = "tink",
strip_include_prefix = "/cc",
deps = [
":constants",
":enums",
":protobuf_helper",
":status",
Expand All @@ -152,8 +151,8 @@ cc_library(
"//cc:hybrid_decrypt",
"//cc:hybrid_encrypt",
"//cc:input_stream",
"//cc:keyset_handle",
"//cc:kms_client",
"//cc:keyset_handle",
"//cc:mac",
"//cc:output_stream",
"//cc:public_key_sign",
Expand Down Expand Up @@ -301,15 +300,3 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "test_util_test",
srcs = ["test_util_test.cc"],
deps = [
":test_util",
"//cc/subtle:random",
"//proto:aes_gcm_cc_proto",
"//proto:tink_cc_proto",
"@com_google_googletest//:gtest_main",
],
)
Loading

0 comments on commit 05a608f

Please sign in to comment.