diff options
author | 2021-12-01 14:45:05 +0000 | |
---|---|---|
committer | 2021-12-01 09:45:05 -0500 | |
commit | aee8d9330bf1035ea99efa4afbb4b6b83581163a (patch) | |
tree | 2dea749a280a684c3ad2609e27ee6d509f9b894b /projects/tink | |
parent | a458e3c8edc4191488bca4563bc1bcf92043226b (diff) |
[tink] Initial integration (#5725)
Diffstat (limited to 'projects/tink')
-rw-r--r-- | projects/tink/Dockerfile | 25 | ||||
-rwxr-xr-x | projects/tink/build.sh | 23 | ||||
-rw-r--r-- | projects/tink/fuzzing_CMake | 8 | ||||
-rw-r--r-- | projects/tink/project.yaml | 12 | ||||
-rw-r--r-- | projects/tink/tink_encrypt_decrypt_fuzzer.cc | 31 |
5 files changed, 99 insertions, 0 deletions
diff --git a/projects/tink/Dockerfile b/projects/tink/Dockerfile new file mode 100644 index 00000000..12b859f3 --- /dev/null +++ b/projects/tink/Dockerfile @@ -0,0 +1,25 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +FROM gcr.io/oss-fuzz-base/base-builder-go +RUN apt-get update && apt-get install -y make pkg-config +RUN git clone --depth 1 https://github.com/google/tink +WORKDIR tink +COPY fuzzing_CMake \ + build.sh \ + tink_encrypt_decrypt_fuzzer.cc \ + $SRC/ diff --git a/projects/tink/build.sh b/projects/tink/build.sh new file mode 100755 index 00000000..e75c0f20 --- /dev/null +++ b/projects/tink/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash -eu +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +mkdir ./cc/fuzzing +cp $SRC/tink_encrypt_decrypt_fuzzer.cc ./cc/fuzzing/ +cp $SRC/fuzzing_CMake ./cc/fuzzing/CMakeLists.txt +cd cc/fuzzing && cmake . +make -j$(nproc) +mv tink_encrypt_fuzzer $OUT/ diff --git a/projects/tink/fuzzing_CMake b/projects/tink/fuzzing_CMake new file mode 100644 index 00000000..63202ad7 --- /dev/null +++ b/projects/tink/fuzzing_CMake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.5) +project(tink_fuzz CXX) +set(CMAKE_CXX_STANDARD 11) + +add_subdirectory(../.. tink) + +add_executable(tink_encrypt_fuzzer tink_encrypt_decrypt_fuzzer.cc) +target_link_libraries(tink_encrypt_fuzzer tink::static $ENV{LIB_FUZZING_ENGINE}) diff --git a/projects/tink/project.yaml b/projects/tink/project.yaml new file mode 100644 index 00000000..9fb2608a --- /dev/null +++ b/projects/tink/project.yaml @@ -0,0 +1,12 @@ +homepage: "https://developers.google.com/tink" +language: c++ +primary_contact: "thaidn@google.com" +auto_ccs: + - "Adam@adalogics.com" + - "sschmieg@google.com" + - "tholenst@google.com" +sanitizers: + - address + - undefined + - memory +main_repo: "https://github.com/google/tink" diff --git a/projects/tink/tink_encrypt_decrypt_fuzzer.cc b/projects/tink/tink_encrypt_decrypt_fuzzer.cc new file mode 100644 index 00000000..c392f9ca --- /dev/null +++ b/projects/tink/tink_encrypt_decrypt_fuzzer.cc @@ -0,0 +1,31 @@ +/* Copyright 2021 Google LLC +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include <stdint.h> +#include <string.h> +#include <stdlib.h> +#include <string> +#include "tink/subtle/aes_siv_boringssl.h" + + +extern "C" +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ + crypto::tink::util::SecretData key = crypto::tink::util::SecretDataFromStringView("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"); + auto res = crypto::tink::subtle::AesSivBoringSsl::New(key); + auto cipher = std::move(res.ValueOrDie()); + std::string aad = "Additional data"; + std::string message(reinterpret_cast<const char*>(data), size); + auto ct = cipher->EncryptDeterministically(message, aad); + auto pt = cipher->DecryptDeterministically(ct.ValueOrDie(), aad); + + return 0; +} |