diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000..b84a07b --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,24 @@ +name: Docs +on: [push, pull_request, workflow_dispatch] +permissions: + contents: write +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - name: Install Sphinx + run: | + pip install sphinx sphinx-rtd-theme cryptography + - name: Build documentation + run: | + sphinx-build docs _build + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + with: + publish_branch: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: _build/ + force_orphan: true diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..9e22651 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,105 @@ + +# Erbsland DEV Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers of Erbsland DEV pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces and when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@erbsland.dev. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..14fef79 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,83 @@ +# Erbsland DEV Contributing Guidelines + +First of all, thank you for considering to contribute to our software! We appreciate your time and effort. This document provides a set of guidelines to help ensure a smooth contribution process. Please take a moment to review and follow these guidelines to help maintain a healthy and inclusive project environment. + +## Code of Conduct + +By participating in this project, you agree to abide by the [Code of Conduct](./CODE_OF_CONDUCT.md). Please ensure you read and follow its principles to help maintain a welcoming and inclusive community environment. + +## How Can I Contribute? + +### Reporting Bugs + +If you encounter a bug, please create a new issue in the project's issue tracker. Be sure to include the following information: + +* A clear and concise description of the bug. +* Steps to reproduce the issue. +* Any additional information that may be helpful (e.g., screenshots, logs, or environment details). + +### Suggesting Enhancements + +To suggest a new feature or enhancement, please create a new issue in the project's issue tracker. In your suggestion, include: + +* A clear and concise description of the enhancement. +* The motivation behind the suggestion (e.g., how it would improve the project or solve a problem). +* Any relevant examples or resources that support your suggestion. + +### Code Contributions + +At Erbsland DEV, we maintain high standards for security, reliability, and quality in our software. To ensure the integrity of the codebase, we do not accept pull requests by default. If you would like to contribute code, please follow the steps below: + +1. Start by reporting a bug or suggesting a feature through the issue tracker. Alternatively, you can contact us directly to discuss your proposed contribution. + +2. Wait for feedback from the maintainers or the community. This will help ensure that your proposed changes align with the project's goals and quality standards. + +3. Once your proposal has been reviewed and approved, you may proceed with creating a pull request. Make sure to follow the instructions outlined in the [Pull Requests](#pull-requests) section. + +Please note that any pull requests submitted without prior communication or approval may be declined. This policy helps maintain the quality and consistency of the Erbsland DEV project. Your understanding and cooperation are greatly appreciated. + +### Pull Requests + +Once your proposal has been reviewed and approved, please follow these steps to contribute code changes: + +1. Create a new branch for your changes. +2. Compile and test your changes. +3. Write unit tests that test your added code through fully. +4. Commit the changes to your new branch. +5. Push your changes to your fork on GitHub. +6. Open a pull request on the original repository and the repository with the unit tests. + +Please note: **Make sure your code follows _the exact coding style_ of the existing code.** Code that is not formatted as existing code of the project is a reason to **reject** your pull request. + +## Style Guidelines + +### Coding Style + +**This project uses "Black" for code formatting.** + +If you contribute code, you must run the "Black" code formatter with the parameter `--line-length=120`. + +Please also follow these general coding style guidelines: + +* Document all classes, methods and instance variables using doc-strings. +* Document internal and private methods if its use is not obvious. + +### Commit Messages + +When writing commit messages, follow these guidelines: + +* Write concise and descriptive commit messages. +* Start the commit message with a capital letter. +* List *every* change of your commit, group the changes where possible. +* If you do extensive changes, split them into multiple small commits. + +## Legal + +### Licensing of Contributions + +All contributions must be made under the same license as the project. + +### Copyright Notice for Contributions + +By contributing to this project, you agree to license your contributions under the same terms as the existing copyright and license. Your contributions will be incorporated into the existing copyrighted material without separate copyright attribution. This does not affect your rights to use your own contributions for any other purpose, including licensing them under different terms. + diff --git a/COPYRIGHT.md b/COPYRIGHT.md new file mode 100644 index 0000000..5820e8b --- /dev/null +++ b/COPYRIGHT.md @@ -0,0 +1,61 @@ + +# Informative Preamble + +Hey there! 👋 If you're reading this, you might be a developer, a contributor, or just someone curious about the project *Fast File Encryption*. While this document may look a bit formal, there's no need to fret! Its main goal is to clarify the copyright and license terms, primarily for those explicitly listed as *Copyright Holders* further down. + +## What This Means for You + +- **Developers and Contributors**: For those of you diving deeper into the code, thank you! This document won't impact your contributions or your ability to use the project. In fact, it's designed to protect the project's open-source nature, ensuring the code remains free for everyone. However, do make sure to read the [Contributing](./CONTRIBUTING.md) document. + +- **Users**: If you're using this software in your projects, rest easy. These terms are set up to protect both the project's longevity and its open-source status. This ensures you can continue to use it with confidence. + +So, unless you're specifically listed as a *Copyright Holder*, go ahead and carry on. These terms aim to ensure that *ErbslandFORMER* remains a free and open-source project, serving the best interests of all its users. + +--- + +# Copyright Terms for Project *Fast File Encryption* + +_Version: 1.0, Last Modified: 2024-01-05_ + +## Copyright Holders + +- Tobias Erbsland, Erbsland DEV. +- EducateIT GmbH. + +## License + +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. + +## Active Entities + +- Tobias Erbsland, Erbsland DEV, reserves the right to enforce the license terms and issue disclaimers regarding liability for the project. +- EducateIT GmbH, granted special permissions solely under the ownership of Marc Rollier, may use a copy of this software under the following alternative terms: + 1. Permission to integrate the software into EducateIT GmbH's proprietary projects, without being required to disclose source code. + 2. Obligation to contribute bug fixes back to the open-source project, but not new features. + +## Succession and Termination + +In the event that Tobias Erbsland or EducateIT GmbH cease to exist, or if there is a change in ownership or control of EducateIT GmbH, the following terms shall apply: + +- The copyright held by Tobias Erbsland will pass on to his designated heirs or executors. If no such party can reasonably be identified, the copyright will be considered to be held by the remaining copyright holder(s). +- In the event of EducateIT GmbH's dissolution, bankruptcy, termination, or change in ownership or control, its copyright and associated rights are terminated, and the copyright will revert to the remaining copyright holder(s). +- Should there be a change in ownership or control of EducateIT GmbH (currently owned by Marc Rollier), the copyright and associated rights held by EducateIT GmbH are terminated. + +In the unlikely event that all copyright holders cease to exist and no heirs or executors can reasonably be identified, the copyright for the project will be transferred to the Apache Software Foundation to ensure its continued stewardship under the terms of the Apache License, Version 2.0. + +## Governing Law and Jurisdiction + +This agreement is governed by the laws of Switzerland. Any disputes arising from or related to this agreement shall be resolved exclusively in the courts located in Bern, Switzerland. + +## Severability + +If any clause in this document is found to be legally unenforceable or invalid, that clause will be limited or eliminated to the minimum extent necessary so that this agreement otherwise remains in full force and effect and enforceable. The remaining clauses will be interpreted in a manner that most closely approximates the original intent of the parties. + +## Contact + +- Tobias Erbsland: [erbsland.dev](https://erbsland.dev/) +- EducateIT GmbH: [educateit.ch](https://educateit.ch/) diff --git a/README.rst b/README.rst index 7d8aa07..f63c286 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,9 @@ You find all details about the library, it's design and file format in the `docu License ------- -Copyright 2021 by Tobias Erbsland @ EducateIT GmbH +Copyright © 2021-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ + +According to the copyright terms specified in the file "COPYRIGHT.md". 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 diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..5e85e52 --- /dev/null +++ b/requirements.in @@ -0,0 +1,2 @@ +cryptography +pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c4ede93 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,20 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile +# +cffi==1.16.0 + # via cryptography +cryptography==41.0.7 + # via -r requirements.in +iniconfig==2.0.0 + # via pytest +packaging==23.2 + # via pytest +pluggy==1.3.0 + # via pytest +pycparser==2.21 + # via cffi +pytest==7.4.4 + # via -r requirements.in diff --git a/setup.cfg b/setup.cfg index b004dda..4f6ebf0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,24 +1,24 @@ [metadata] name = fast-file-encryption version = attr: fast_file_encryption._about.VERSION -author = Tobias Erbsland -author_email = tobias.erbsland@educateit.ch +author = Erbsland DEV +author_email = info@erbsland.dev description = A simple and fast asynchronous file encryption library for large files and data streams. long_description = file: README.rst long_description_content_type = text/x-rst -url = https://github.com/educateitgmbh/fast-file-encryption +url = https://github.com/erbsland-dev/fast-file-encryption project_urls = Documentation=https://fast-file-encryption.readthedocs.io/ - Source=https://github.com/educateitgmbh/fast-file-encryption - Issues=https://github.com/educateitgmbh/fast-file-encryption/issues + Source=https://github.com/erbsland-dev/fast-file-encryption + Issues=https://github.com/erbsland-dev/fast-file-encryption/issues classifiers = Development Status :: 5 - Production/Stable Intended Audience :: Developers Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 License :: OSI Approved :: Apache Software License Operating System :: OS Independent Topic :: Security @@ -27,9 +27,9 @@ classifiers = package_dir = =src packages = find: -python_requires = >=3.8 +python_requires = >=3.9 install_requires = - cryptography >= 36.0.1 + cryptography >= 40.0.1 [options.packages.find] where = src \ No newline at end of file diff --git a/src/fast_file_encryption/__init__.py b/src/fast_file_encryption/__init__.py index a6b6f7b..60f7f0f 100644 --- a/src/fast_file_encryption/__init__.py +++ b/src/fast_file_encryption/__init__.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 """ diff --git a/src/fast_file_encryption/_about.py b/src/fast_file_encryption/_about.py index f301ee4..8817877 100644 --- a/src/fast_file_encryption/_about.py +++ b/src/fast_file_encryption/_about.py @@ -1,16 +1,6 @@ -# Copyright 2022 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 __all__ = [ @@ -19,6 +9,6 @@ 'COPYRIGHT', ] -VERSION = '1.2.5' +VERSION = '1.2.6' AUTHOR = 'Tobias Erbsland' -COPYRIGHT = f'2021-2022, Tobias Erbsland / EducateIT GmbH' +COPYRIGHT = f'2021-2024, Tobias Erbsland and EducateIT GmbH' diff --git a/src/fast_file_encryption/decryptor.py b/src/fast_file_encryption/decryptor.py index d2234f9..6868907 100644 --- a/src/fast_file_encryption/decryptor.py +++ b/src/fast_file_encryption/decryptor.py @@ -1,23 +1,13 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 import hashlib import io import json from pathlib import Path -from typing import Dict, Any, Optional, Tuple +from typing import Dict, Any, Optional, Tuple, Union, BinaryIO from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric.padding import OAEP, MGF1 @@ -32,6 +22,9 @@ CHUNKED_BLOCK_SIZE_VALUE, MAXIMUM_BLOCK_SIZE_VALUE +AcceptedIOStream = Union[io.BufferedIOBase, BinaryIO] + + class Decryptor: """ The encryptor provides methods to encrypt files. @@ -496,7 +489,7 @@ def _decrypt_static_block(self, encrypted_block_size: int, destination: io.Buffe # At this point the decrypted data has its final length. Return the digest. return block_hash_context.digest() - def _decrypt_stream(self, source_io: io.BufferedIOBase, destination_io: io.BufferedIOBase): + def _decrypt_stream(self, source_io: AcceptedIOStream, destination_io: AcceptedIOStream): """ Decrypt a file from a source stream and write the decrypted data into the target stream. @@ -545,7 +538,7 @@ def copy_decrypted(self, source: Path, destination: Path): destination.unlink(missing_ok=True) raise - def stream_decrypted(self, source_io: io.BufferedIOBase, destination_io: io.BufferedIOBase): + def stream_decrypted(self, source_io: AcceptedIOStream, destination_io: AcceptedIOStream): """ Decrypt the data from the source stream and write it to the destination stream. diff --git a/src/fast_file_encryption/encryptor.py b/src/fast_file_encryption/encryptor.py index 08c656e..d5c5ff7 100644 --- a/src/fast_file_encryption/encryptor.py +++ b/src/fast_file_encryption/encryptor.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 import hashlib @@ -19,7 +9,7 @@ import os from datetime import datetime from pathlib import Path -from typing import Dict, Any, Optional, Tuple +from typing import Dict, Any, Optional, Tuple, Union, BinaryIO from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric.padding import OAEP, MGF1 @@ -33,6 +23,9 @@ SIZE_VALUE_LENGTH, AES_KEY_LENGTH_BYTES, CHUNK_SIZE_LENGTH, MAXIMUM_CHUNK_SIZE, CHUNKED_BLOCK_SIZE_VALUE +AcceptedIOStream = Union[io.BufferedIOBase, BinaryIO] + + class Encryptor: """ The encryptor provides methods to encrypt files. @@ -199,7 +192,7 @@ def _write_bytes_data(self, source_data: bytes): self._write_encrypted_block(b'DATA', source_data) self._write_encrypted_block(b'DTHA', hashlib.sha3_512(source_data).digest()) - def _write_file_data(self, source_size: int, sf: io.BufferedIOBase): + def _write_file_data(self, source_size: int, sf: AcceptedIOStream): """ Write the file data encrypted to the destination. @@ -427,7 +420,7 @@ def copy_encrypted(self, source: Path, destination: Path, meta: Dict[str, Any] = self._write_end_with_hash() self._clean_up() - def stream_encrypted(self, source_io: io.BufferedIOBase, destination_io: io.BufferedIOBase, + def stream_encrypted(self, source_io: AcceptedIOStream, destination_io: AcceptedIOStream, meta: Dict[str, Any] = None): """ Read data from a stream and write it encrypted into another stream. diff --git a/src/fast_file_encryption/errors.py b/src/fast_file_encryption/errors.py index b07d1fd..6ed333a 100644 --- a/src/fast_file_encryption/errors.py +++ b/src/fast_file_encryption/errors.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 class IntegrityError(Exception): diff --git a/src/fast_file_encryption/internals.py b/src/fast_file_encryption/internals.py index 6048a9a..0fdc785 100644 --- a/src/fast_file_encryption/internals.py +++ b/src/fast_file_encryption/internals.py @@ -1,16 +1,7 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 + """ This module contains the shared values for the encryption, decryption and key generation. diff --git a/src/fast_file_encryption/tools.py b/src/fast_file_encryption/tools.py index f8f33f9..431c598 100644 --- a/src/fast_file_encryption/tools.py +++ b/src/fast_file_encryption/tools.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2022-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 """ diff --git a/tests/shared.py b/tests/shared.py index 3b4722c..1e591a2 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2021-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 from pathlib import Path diff --git a/tests/test_encryption.py b/tests/test_encryption.py index a7973bf..ab54677 100644 --- a/tests/test_encryption.py +++ b/tests/test_encryption.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2021-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 import itertools diff --git a/tests/test_meta.py b/tests/test_meta.py index 3621c45..96094cf 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2021-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 import random @@ -68,8 +58,10 @@ def test_invalid_metadata(self, tmp_path, public_key): stored_file_path = tmp_path / 'empty.data' encryptor = Encryptor(public_key=public_key) with pytest.raises(ValueError): + # noinspection PyTypeChecker encryptor.save_encrypted(source_data=bytes(), destination=stored_file_path, meta=12) with pytest.raises(ValueError): + # noinspection PyTypeChecker encryptor.save_encrypted(source_data=bytes(), destination=stored_file_path, meta='text') with pytest.raises(ValueError): meta = { diff --git a/tests/test_stream.py b/tests/test_stream.py index 8160bcb..a34a284 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2021-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 import io @@ -162,6 +152,7 @@ def readable(self) -> bool: def seekable(self) -> bool: return False + # noinspection PyMethodOverriding def read(self, size: int) -> bytes: if not self.buffer: return b'' @@ -170,6 +161,7 @@ def read(self, size: int) -> bytes: del self.buffer[:b] return result + # noinspection PyMethodOverriding def read1(self, size: int) -> bytes: return self.read(size) diff --git a/tests/test_tools.py b/tests/test_tools.py index ba90fa6..60f0c8d 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1,16 +1,6 @@ -# Copyright 2021 by Tobias Erbsland / EducateIT GmbH -# -# 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. +# Copyright © 2021-2024 Tobias Erbsland https://erbsland.dev/ and EducateIT GmbH https://educateit.ch/ +# According to the copyright terms specified in the file "COPYRIGHT.md". +# SPDX-License-Identifier: Apache-2.0 from cryptography.hazmat.primitives import serialization @@ -30,6 +20,7 @@ def test_read_public_key(self, keys_dir): s = b.decode('utf-8') ffe.read_public_key(s) with pytest.raises(ValueError): + # noinspection PyTypeChecker ffe.read_public_key(10) with pytest.raises(ValueError): ffe.read_public_key('''-----BEGIN PUBLIC KEY----- @@ -45,6 +36,7 @@ def test_read_private_key(self, keys_dir): s = b.decode('utf-8') ffe.read_private_key(s) with pytest.raises(ValueError): + # noinspection PyTypeChecker ffe.read_private_key(10) with pytest.raises(ValueError): ffe.read_private_key('''-----BEGIN EC PRIVATE KEY----- @@ -81,10 +73,14 @@ def test_save_keypair(self, tmp_path): assert private_key.read_bytes() != private_key_data # Test invalid parameters with pytest.raises(ValueError): + # noinspection PyTypeChecker ffe.save_key_pair(public_key=None, private_key=private_key) with pytest.raises(ValueError): + # noinspection PyTypeChecker ffe.save_key_pair(public_key='path', private_key=private_key) with pytest.raises(ValueError): + # noinspection PyTypeChecker ffe.save_key_pair(public_key=public_key, private_key=None) with pytest.raises(ValueError): + # noinspection PyTypeChecker ffe.save_key_pair(public_key=public_key, private_key='path')