This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

View file

@ -0,0 +1,71 @@
#ifndef _STAR_CLIENT_AUTHENTICATION_HPP_
#define _STAR_CLIENT_AUTHENTICATION_HPP_
#include "StarAuthenticationKey.hpp"
#include "StarException.hpp"
#include "StarVariant.hpp"
#include <string>
namespace Star {
namespace Auth {
/*
<AuthSignature>=
{
"signedAuthKey" : {
"authPublicKey": ...
"validFrom":...
"validTo":...
}
"rootSignedAuthKeySignature": <signature made with root privkey>
}
<ClientClaim>=
{
"claim": {
"metadata: {
"clientPublicKey":...
"username":...
"validFrom":...
"validTo":...
}
"signature"
}
"authSignature": {
"signedAuthKey" : {
"authPublicKey": ...
"validFrom":...
"validTo":...
}
"rootSignedAuthKeySignature": <signature made with root privkey>
}
"signature": <signature of main message with authPrivateKey>
}
*/
class ClientAuthentication {
public:
ClientAuthentication(shared_ptr<Key> const& rootKey);
~ClientAuthentication();
Variant authsvrRequest(String const& username, String const& passwordHash, String const& authClaim, Key const& clientPrivateKey);
Variant authsvrResponse(String const& response, Key const& clientPrivateKey);
String serverRequest();
bool serverResponse(String const& response);
Variant authsvrValidateRequest(Variant const& claim, String const& authClaim, Key const& clientPrivateKey);
bool authsvrValidateResponse(String const& response, Key const& clientPrivateKey);
private:
shared_ptr<Key> m_rootPublicKey;
};
}
}
#endif