| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <QByteArray> |
| 7 | |
| 8 | class ICryptoLayer |
| 9 | { |
| 10 | public: |
| 11 | /// Initialization. |
| 12 | virtual void init() = 0; |
| 13 | |
| 14 | /// @return subject public key. |
| 15 | virtual QByteArray publicKey() = 0; |
| 16 | |
| 17 | /// Set the key that will be used in public key operations (as verify). |
| 18 | /// This key is generated by other subject. |
| 19 | virtual void usePublicKey(QByteArray const &publicKey) = 0; |
| 20 | |
| 21 | /// Compute and validates the data signature against the provided signature. |
| 22 | virtual bool verify(QByteArray const &data, QByteArray const &signature) = 0; |
| 23 | |
| 24 | /// Generates the signature of the data. |
| 25 | virtual QByteArray signature(QByteArray const &data) = 0; |
| 26 | |
| 27 | virtual ~ICryptoLayer() = default; |
| 28 | }; |