diff --git a/projects/tink/Dockerfile b/projects/tink/Dockerfile new file mode 100644 index 000000000..12b859f36 --- /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 000000000..e75c0f204 --- /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 000000000..63202ad78 --- /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 000000000..9fb2608a6 --- /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 000000000..c392f9cac --- /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 +#include +#include +#include +#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(data), size); + auto ct = cipher->EncryptDeterministically(message, aad); + auto pt = cipher->DecryptDeterministically(ct.ValueOrDie(), aad); + + return 0; +}