The AsyncKeysAuth class is temaplate class for works with authorization of a pair of asynchronous keys This class contains base implementation for the authentication using async encryption. The base encryption algorithm defined on the template argument CryptoImplementation. You can use any crypto algorithm.
More...
#include <asynckeysauth.h>
|
| AsyncKeysAuth () |
|
| ~AsyncKeysAuth () |
|
bool | auth (int allowedTimeRangeSec, QString *retLoginedUserId) const |
| auth This method make authentication and return true if the authentication finished successful else false.
|
|
bool | prepare () |
| prepare This method will generate signature for autentication of client. Please inboke this method before send request to server.
|
|
unsigned int | unixTime () const |
| unixTime This method return unix time that client added for authentication.
|
|
void | setUnixTime (unsigned int newUnixTime) |
| setUnixTime This method sets new value of the unixTime propertye.
|
|
const QByteArray & | signature () const |
| signature This method return signature array.
|
|
bool | isValid () const |
| isValid this method check this ibject to valid.
|
|
QString | getUserId () const |
| getUserId This method return user id that generated from the public key.
|
|
const QByteArray & | publicKey () const |
| publicKey This method return public key that client added for authentication.
|
|
void | setPublicKey (const QByteArray &newPublicKey) |
| setPublicKey This method sets new public key for authentication.
|
|
|
QByteArray | decrypt (const QByteArray &message, const QByteArray &key) override |
|
QByteArray | encrypt (const QByteArray &message, const QByteArray &key) override |
|
QByteArray | signMessage (const QByteArray &message, const QByteArray &key) const override |
|
bool | checkSign (const QByteArray &message, const QByteArray &signature, const QByteArray &key) const override |
|
virtual QByteArray | getPrivateKey () const =0 |
| getPrivateKey This method should be return private key for the public key that saved in this object.
|
|
void | setSignature (const QByteArray &newSignature) |
| setSignature Tihis is internal method for sets new signature value.
|
|
template<class CryptoImplementation>
class EasySSL::AsyncKeysAuth< CryptoImplementation >
The AsyncKeysAuth class is temaplate class for works with authorization of a pair of asynchronous keys This class contains base implementation for the authentication using async encryption. The base encryption algorithm defined on the template argument CryptoImplementation. You can use any crypto algorithm.
Exampel of use:
The AsyncKeysAuth class is temaplate class for works with authorization of a pair of asynchronous key...
How to it works:
** Client Part **
- Client make a pair keys (public and private) = PUB and PRIV
- Client get current unix time = U
- Client make a data for signing = S S = SHA256{U + PUB}
- Client make a signature SIG SIG = PRIV.signMessage(S)
- Client prepare a auth request for server = R: R = {U,SIG,PUB}
- Cleint send R to server
- --—
** Server Part **
- Server receive R from client.
- Server compare U time with current unix time.
- If the diferrence more then allowed value then server reject an auth
- Server make S value as a client
- Server check SIG value and comapre it with S value
- If message sign is valid then server accept an auth else reject.
- After accept server create new user with ID = sha256(PUB) or if user alredy exits make them as a logined user.
- Template Parameters
-
CryptoImplementation | This is internal implementaion of base encryption functions. |
- See also
- iCrypto class.
Definition at line 69 of file asynckeysauth.h.
◆ AsyncKeysAuth()
template<class CryptoImplementation >
◆ ~AsyncKeysAuth()
template<class CryptoImplementation >
◆ auth()
template<class CryptoImplementation >
bool EasySSL::AsyncKeysAuth< CryptoImplementation >::auth |
( |
int |
allowedTimeRangeSec, |
|
|
QString * |
retLoginedUserId |
|
) |
| const |
|
inline |
auth This method make authentication and return true if the authentication finished successful else false.
retLoginedUserId This is logined user id in Base64UrlEncoding
- Returns
- true if the authentication finished successful else false.
Definition at line 86 of file asynckeysauth.h.
◆ checkSign()
template<class CryptoImplementation >
bool EasySSL::AsyncKeysAuth< CryptoImplementation >::checkSign |
( |
const QByteArray & |
message, |
|
|
const QByteArray & |
signature, |
|
|
const QByteArray & |
key |
|
) |
| const |
|
inlineoverrideprotected |
◆ decrypt()
template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::decrypt |
( |
const QByteArray & |
message, |
|
|
const QByteArray & |
key |
|
) |
| |
|
inlineoverrideprotected |
◆ encrypt()
template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::encrypt |
( |
const QByteArray & |
message, |
|
|
const QByteArray & |
key |
|
) |
| |
|
inlineoverrideprotected |
◆ getPrivateKey()
template<class CryptoImplementation >
getPrivateKey This method should be return private key for the public key that saved in this object.
- Returns
- private key for the public key that saved in this object.
◆ getUserId()
template<class CryptoImplementation >
getUserId This method return user id that generated from the public key.
- Note
- This function works slow, because this object does not contain ID of user. The user ID will be generated every invoke of this function
- Returns
- user ID.
Definition at line 167 of file asynckeysauth.h.
◆ isValid()
template<class CryptoImplementation >
isValid this method check this ibject to valid.
- Returns
- return true if object contains valid signature else false.
- Note
- Invoke the AsyncKeysAuth::prepare method before check valid of object. All object that not be preparred is invalid.
Definition at line 158 of file asynckeysauth.h.
◆ prepare()
template<class CryptoImplementation >
prepare This method will generate signature for autentication of client. Please inboke this method before send request to server.
- Returns
- true if signature generated sucessuful.
Definition at line 115 of file asynckeysauth.h.
◆ publicKey()
template<class CryptoImplementation >
publicKey This method return public key that client added for authentication.
- Note
- The publicKey will be used forcreate user id.
- Returns
- public key that client added for authentication.
- See also
- AsyncKeysAuth::setPublicKey
Definition at line 180 of file asynckeysauth.h.
◆ setPublicKey()
template<class CryptoImplementation >
◆ setSignature()
template<class CryptoImplementation >
setSignature Tihis is internal method for sets new signature value.
- Parameters
-
newSignature | new signature value. |
- Note
- used in the
Definition at line 222 of file asynckeysauth.h.
◆ setUnixTime()
template<class CryptoImplementation >
setUnixTime This method sets new value of the unixTime propertye.
- Parameters
-
newUnixTime | This is new unix time value. Unix time sets in secunds from 1970 year |
Definition at line 140 of file asynckeysauth.h.
◆ signature()
template<class CryptoImplementation >
◆ signMessage()
template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::signMessage |
( |
const QByteArray & |
message, |
|
|
const QByteArray & |
key |
|
) |
| const |
|
inlineoverrideprotected |
◆ unixTime()
template<class CryptoImplementation >
◆ _publicKey
template<class CryptoImplementation >
◆ _signature
template<class CryptoImplementation >
◆ _unixTime
template<class CryptoImplementation >
The documentation for this class was generated from the following file: