code format
This commit is contained in:
@@ -5,55 +5,62 @@
|
||||
* \~russian API аутентификации
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP Authentication API
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
PIP Authentication API
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIAUTH_H
|
||||
#define PIAUTH_H
|
||||
|
||||
#include "pip_crypt_export.h"
|
||||
#include "piobject.h"
|
||||
#include "picrypt.h"
|
||||
#include "piobject.h"
|
||||
#include "pip_crypt_export.h"
|
||||
|
||||
|
||||
class PIP_CRYPT_EXPORT PIAuth : public PIObject
|
||||
{
|
||||
class PIP_CRYPT_EXPORT PIAuth: public PIObject {
|
||||
PIOBJECT(PIAuth)
|
||||
|
||||
public:
|
||||
enum State {NotConnected, AuthProbe, PassRequest, AuthReply, KeyExchange, Connected};
|
||||
enum State {
|
||||
NotConnected,
|
||||
AuthProbe,
|
||||
PassRequest,
|
||||
AuthReply,
|
||||
KeyExchange,
|
||||
Connected
|
||||
};
|
||||
|
||||
//! Create PIAuth with your digital sign
|
||||
PIAuth(const PIByteArray & sign);
|
||||
|
||||
//! Set server info data for client authorize event
|
||||
void setInfoData(const PIByteArray & info) {custom_info = info;}
|
||||
void setInfoData(const PIByteArray & info) { custom_info = info; }
|
||||
|
||||
//! Set server password for check
|
||||
void setServerPassword(const PIString & ps);
|
||||
|
||||
//! Set list of trusted clients/servers public digital sign keys
|
||||
void setAuthorizedPublicKeys(const PIVector<PIByteArray> & pkeys) {auth_pkeys = pkeys;}
|
||||
void setAuthorizedPublicKeys(const PIVector<PIByteArray> & pkeys) { auth_pkeys = pkeys; }
|
||||
|
||||
//! Get list of trusted clients/servers public digital sign keys
|
||||
PIVector<PIByteArray> getAuthorizedPublicKeys() {return auth_pkeys;}
|
||||
PIVector<PIByteArray> getAuthorizedPublicKeys() { return auth_pkeys; }
|
||||
|
||||
//! Get your digital sign public key
|
||||
PIByteArray getSignPublicKey() {return sign_pk;}
|
||||
PIByteArray getSignPublicKey() { return sign_pk; }
|
||||
|
||||
|
||||
//! Stop authorization
|
||||
@@ -91,7 +98,10 @@ public:
|
||||
EVENT1(passwordCheck, bool, result);
|
||||
|
||||
private:
|
||||
enum Role {Client, Server};
|
||||
enum Role {
|
||||
Client,
|
||||
Server
|
||||
};
|
||||
|
||||
State disconnect(PIByteArray & ba, const PIString & error = PIString());
|
||||
bool isAuthorizedKey(const PIByteArray & pkey);
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
* \~russian Шифрование с помощью libsodium
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Cryptographic class using lib Sodium
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Cryptographic class using lib Sodium
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PICRYPT_H
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
PIByteArray setKey(const PIString & secret);
|
||||
|
||||
//! Returns current key
|
||||
PIByteArray key() {return key_;}
|
||||
PIByteArray key() { return key_; }
|
||||
|
||||
//! Encrypt given data "data", result size will be increased by \a sizeCrypt()
|
||||
PIByteArray crypt(const PIByteArray & data);
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
static PIByteArray extractSignPublicKey(const PIByteArray & secret_key);
|
||||
|
||||
//! Calculate digital signature for data
|
||||
PIByteArray signMessage(const PIByteArray & data, PIByteArray secret_key);
|
||||
PIByteArray signMessage(const PIByteArray & data, PIByteArray secret_key);
|
||||
|
||||
//! Verify digital signature of signed message
|
||||
bool verifySign(const PIByteArray & data, const PIByteArray & signature, PIByteArray public_key);
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
static void generateKeypair(PIByteArray & public_key, PIByteArray & secret_key, const PIByteArray & seed);
|
||||
|
||||
//! Encrypt given data "data"
|
||||
PIByteArray crypt(const PIByteArray &data, const PIByteArray & public_key, const PIByteArray & secret_key);
|
||||
PIByteArray crypt(const PIByteArray & data, const PIByteArray & public_key, const PIByteArray & secret_key);
|
||||
|
||||
//! Decrypt given data "crypt_data"
|
||||
PIByteArray decrypt(const PIByteArray & crypt_data, const PIByteArray & public_key, const PIByteArray & secret_key, bool * ok = 0);
|
||||
@@ -120,7 +120,6 @@ private:
|
||||
static bool init();
|
||||
|
||||
PIByteArray nonce_, key_;
|
||||
|
||||
};
|
||||
|
||||
#endif // PICRYPT_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//! \defgroup Crypt Crypt
|
||||
//! \~\brief
|
||||
@@ -51,7 +51,7 @@
|
||||
#ifndef PICRYPTMODULE_H
|
||||
#define PICRYPTMODULE_H
|
||||
|
||||
#include "picrypt.h"
|
||||
#include "piauth.h"
|
||||
#include "picrypt.h"
|
||||
|
||||
#endif // PICRYPTMODULE_H
|
||||
|
||||
Reference in New Issue
Block a user