add compare function with private key as parameter for comparing private keys in controller::user::login to skip calculating public key from private key

This commit is contained in:
Dario 2020-06-24 10:18:30 +02:00
parent 910e2ac5e9
commit dcfed9bb12

View File

@ -11,6 +11,7 @@
* \brief: Key Pairs class for ed25519 keys, used for default gradido transactions
*/
#include "sodium.h"
#include "AuthenticatedEncryption.h"
@ -41,6 +42,14 @@ public:
inline bool isTheSame(const unsigned char* pubkey) const {
return 0 == sodium_memcmp(mSodiumPublic, pubkey, crypto_sign_PUBLICKEYBYTES);
}
//! \return 0 if the same
//! \return -1 if not the same
//! \return 1 if hasn't private key
inline int isTheSame(const MemoryBin* privkey) const {
if (!mSodiumSecret) return 1;
if (privkey->size() != mSodiumSecret->size()) return -1;
return sodium_memcmp(*mSodiumSecret, *privkey, privkey->size());
}
inline bool operator == (const KeyPairEd25519& b) const { return isTheSame(b); }
inline bool operator != (const KeyPairEd25519& b) const { return !isTheSame(b); }