mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
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:
parent
910e2ac5e9
commit
dcfed9bb12
@ -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); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user