easyssl/README.md

113 lines
2.8 KiB
Markdown
Raw Normal View History

2023-03-26 21:25:15 +02:00
# EasySSL
This is wrapper library that make using OpenSSL library more simple.
This library contains interfaces for the signing and encryption data.
2023-03-26 19:36:35 +03:00
### Supported encryption algorithms:
2023-07-17 22:52:15 +02:00
* ECDSA
* RSA
2023-03-26 21:25:15 +02:00
### Supported features
* encryption
2023-03-26 21:25:15 +02:00
* signing
* keys creating
* asyn auth bse on the asyn encryptions methods
2023-03-26 21:25:15 +02:00
## Build and Include
### CMake
2023-03-26 21:25:15 +02:00
* cd yourRepo
* git submodule add https://github.com/QuasarApp/easyssl.git # add the repository of EasySSL into your repo like submodule
2023-03-26 21:25:15 +02:00
* git submodule update --init --recursive
* Include in your CMakeLists.txt file the main CMakeLists.txt file of EasySSL library
2023-03-26 21:25:15 +02:00
```cmake
add_subdirectory(easyssl)
```
* link the EasySSL library to your target
2023-03-26 21:25:15 +02:00
```cmake
target_link_libraries(yourLib PUBLIC easyssl)
```
* rebuild yuor project
### Independet of SSL build
Dependency on the ssl library greatly complicates the deployment of the final product. For fix this issue, you can build EasySSL library with static SSL library. In this case, SSL library code will be saved in your EasySell binary, and deploy of your application will be easily. The ssl code will not available for your application or other libraries, so you will not get conflicts between different major versions ssl libraries if your distribution kit has it.
2023-03-26 21:25:15 +02:00
Just set the **EASYSSL_STATIC_SSL** option to true.
``` bash
cmake .. -DEASYSSL_STATIC_SSL=1
```
The described case may be useful for the Qt 5.15.x, because the QNetwork 5.15 depends on the SSL v1.1 and EasySsl works with the SSL >= 3.0.
2023-03-26 21:25:15 +02:00
## Usage
### Encryption
2023-07-17 22:52:15 +02:00
```cpp
2023-07-17 23:07:28 +02:00
#include "easyssl/rsassl.h"
// create a publick and private keys array.
int main() {
QByteArray pub, priv;
EasySSL::RSASSL crypto;
crypto.makeKeys(pub, priv)
2023-07-17 23:07:28 +02:00
auto siganture = crypto.signMessage(message, priv);
crypto.checkSign(message, siganture, pub);
auto encryptedMsg = crypto.encrypt(message, pub);
auto decryptedMsg = crypto.decrypt(encryptedMsg, priv);
2023-07-17 23:07:28 +02:00
}
2023-07-17 22:52:15 +02:00
```
### Authentication
2023-03-26 21:25:15 +02:00
```cpp
#include <easyssl/authecdsa.h>
class ECDSA: public EasySSL::AuthECDSA {
public:
// AsyncKeysAuth interface
void setPrivateKey(const QByteArray &newPriv) {
_priv = newPriv;
}
QByteArray getPrivateKey() const {
return _priv;
};
private:
QByteArray _priv;
};
ECDSA edsa;
QByteArray pub, priv;
QString userID;
// make public and private keys.
edsa.makeKeys(pub, priv);
edsa.setPrivateKey(priv);
edsa.setPublicKey(pub);
// prepare an authentication object.
edsa.prepare();
edsa.setPrivateKey({});
edsa.auth(1000, &userID)
```
2023-03-26 19:36:35 +03:00
## Do not forget to help us make this library better...
See our main documentation about contributing to [EasySsl](https://github.com/QuasarApp/easyssl/blob/main/CONTRIBUTING.md)
2023-07-17 23:07:28 +02:00
Full documentation available [here](https://quasarapp.ddns.net:3031/docs/QuasarApp/easyssl/latest/index.html)