Skip to content

ecdsa-python: initial integration #7498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions projects/ecdsa-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 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-python
RUN git clone https://github.com/starkbank/ecdsa-python/
WORKDIR $SRC
COPY build.sh $SRC/
COPY fuzz_* $SRC/
24 changes: 24 additions & 0 deletions projects/ecdsa-python/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -eu
# Copyright 2022 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.
#
################################################################################

cd ecdsa-python
python3 ./setup.py install

# Build fuzzers
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
compile_python_fuzzer $fuzzer
done
51 changes: 51 additions & 0 deletions projects/ecdsa-python/fuzz_private_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/python3
# Copyright 2022 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.

import sys
import atheris

with atheris.instrument_imports():
from ellipticcurve import Ecdsa, Signature, PublicKey, PrivateKey


@atheris.instrument_func
def TestOneInput(input_bytes):
fdp = atheris.FuzzedDataProvider(input_bytes)

privateKey1 = PrivateKey()
publicKey1 = privateKey1.publicKey()

privateKeyPem = privateKey1.toPem()
publicKeyPem = publicKey1.toPem()

privateKey2 = PrivateKey.fromPem(privateKeyPem)
publicKey2 = PublicKey.fromPem(publicKeyPem)

message = fdp.ConsumeUnicode(sys.maxsize)

signatureBase64 = Ecdsa.sign(message=message,
privateKey=privateKey2).toBase64()

signature = Signature.fromBase64(signatureBase64)
assert(Ecdsa.verify(message=message, signature=signature, publicKey=publicKey2))


def main():
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
atheris.Fuzz()


if __name__ == "__main__":
main()
8 changes: 8 additions & 0 deletions projects/ecdsa-python/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
homepage: "https://github.com/starkbank/ecdsa-python"
language: python
primary_contact: "[email protected]"
fuzzing_engines:
- libfuzzer
sanitizers:
- address
main_repo: "https://github.com/starkbank/ecdsa-python/"