easyssl 0.51.8d8e9a5
EasySSL is base back end library for your c++ Qt projects.
EasySSL::AsyncKeysAuth< CryptoImplementation > Class Template Referenceabstract

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>

Public Member Functions

 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.
 

Protected Member Functions

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.
 

Protected Attributes

unsigned int _unixTime = 0
 
QByteArray _signature
 
QByteArray _publicKey
 

Detailed Description

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:

#include <easyssl.h>
using ECDSAAuth = AsyncKeysAuth<ECDSA>;
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
CryptoImplementationThis is internal implementaion of base encryption functions.
See also
iCrypto class.

Definition at line 69 of file asynckeysauth.h.

Inheritance diagram for EasySSL::AsyncKeysAuth< CryptoImplementation >:
Inheritance graph
Collaboration diagram for EasySSL::AsyncKeysAuth< CryptoImplementation >:
Collaboration graph

Constructor & Destructor Documentation

◆ AsyncKeysAuth()

template<class CryptoImplementation >
EasySSL::AsyncKeysAuth< CryptoImplementation >::AsyncKeysAuth ( )
inline

Definition at line 72 of file asynckeysauth.h.

◆ ~AsyncKeysAuth()

template<class CryptoImplementation >
EasySSL::AsyncKeysAuth< CryptoImplementation >::~AsyncKeysAuth ( )
inline

Definition at line 77 of file asynckeysauth.h.

Member Function Documentation

◆ 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.

Here is the call graph for this function:

◆ checkSign()

template<class CryptoImplementation >
bool EasySSL::AsyncKeysAuth< CryptoImplementation >::checkSign ( const QByteArray &  message,
const QByteArray &  signature,
const QByteArray &  key 
) const
inlineoverrideprotected

Definition at line 207 of file asynckeysauth.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrypt()

template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::decrypt ( const QByteArray &  message,
const QByteArray &  key 
)
inlineoverrideprotected

Definition at line 195 of file asynckeysauth.h.

◆ encrypt()

template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::encrypt ( const QByteArray &  message,
const QByteArray &  key 
)
inlineoverrideprotected

Definition at line 199 of file asynckeysauth.h.

◆ getPrivateKey()

template<class CryptoImplementation >
virtual QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::getPrivateKey ( ) const
protectedpure virtual

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.
Here is the caller graph for this function:

◆ getUserId()

template<class CryptoImplementation >
QString EasySSL::AsyncKeysAuth< CryptoImplementation >::getUserId ( ) const
inline

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.

Here is the caller graph for this function:

◆ isValid()

template<class CryptoImplementation >
bool EasySSL::AsyncKeysAuth< CryptoImplementation >::isValid ( ) const
inline

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.

Here is the caller graph for this function:

◆ prepare()

template<class CryptoImplementation >
bool EasySSL::AsyncKeysAuth< CryptoImplementation >::prepare ( )
inline

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.

Here is the call graph for this function:

◆ publicKey()

template<class CryptoImplementation >
const QByteArray & EasySSL::AsyncKeysAuth< CryptoImplementation >::publicKey ( ) const
inline

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 >
void EasySSL::AsyncKeysAuth< CryptoImplementation >::setPublicKey ( const QByteArray &  newPublicKey)
inline

setPublicKey This method sets new public key for authentication.

Parameters
newPublicKeyThiy is new key.
See also
AsyncKeysAuth::publicKey

Definition at line 189 of file asynckeysauth.h.

◆ setSignature()

template<class CryptoImplementation >
void EasySSL::AsyncKeysAuth< CryptoImplementation >::setSignature ( const QByteArray &  newSignature)
inlineprotected

setSignature Tihis is internal method for sets new signature value.

Parameters
newSignaturenew signature value.
Note
used in the

Definition at line 222 of file asynckeysauth.h.

Here is the caller graph for this function:

◆ setUnixTime()

template<class CryptoImplementation >
void EasySSL::AsyncKeysAuth< CryptoImplementation >::setUnixTime ( unsigned int  newUnixTime)
inline

setUnixTime This method sets new value of the unixTime propertye.

Parameters
newUnixTimeThis 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 >
const QByteArray & EasySSL::AsyncKeysAuth< CryptoImplementation >::signature ( ) const
inline

signature This method return signature array.

Returns
signature array.
See also
AsyncKeysAuth::setSignature

Definition at line 149 of file asynckeysauth.h.

Here is the caller graph for this function:

◆ signMessage()

template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::signMessage ( const QByteArray &  message,
const QByteArray &  key 
) const
inlineoverrideprotected

Definition at line 203 of file asynckeysauth.h.

Here is the caller graph for this function:

◆ unixTime()

template<class CryptoImplementation >
unsigned int EasySSL::AsyncKeysAuth< CryptoImplementation >::unixTime ( ) const
inline

unixTime This method return unix time that client added for authentication.

Returns
unix time that client added for authentication.
See also
AsyncKeysAuth::setUnixTime

Definition at line 132 of file asynckeysauth.h.

Member Data Documentation

◆ _publicKey

template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::_publicKey
protected

Definition at line 228 of file asynckeysauth.h.

◆ _signature

template<class CryptoImplementation >
QByteArray EasySSL::AsyncKeysAuth< CryptoImplementation >::_signature
protected

Definition at line 227 of file asynckeysauth.h.

◆ _unixTime

template<class CryptoImplementation >
unsigned int EasySSL::AsyncKeysAuth< CryptoImplementation >::_unixTime = 0
protected

Definition at line 226 of file asynckeysauth.h.


The documentation for this class was generated from the following file: