Commit 321f83d8 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

registration: daemon should sign the name in lowercase

Because the signature is now fixed and sign(Name) != sign(name),
the daemon should sign the name in lowercase because it will
try to register the name in lowercase.

Change-Id: If5f786f241fedb83d65015ac7edf0cacd66f4d2d
parent 1c36f964
......@@ -1666,10 +1666,12 @@ void
JamiAccount::registerName(const std::string& password, const std::string& name)
{
std::string signedName;
auto nameLowercase {name};
std::transform(nameLowercase.begin(), nameLowercase.end(), nameLowercase.begin(), ::tolower);
std::string publickey;
try {
auto privateKey = readArchive(password).id.first;
signedName = base64::encode(privateKey->sign(Blob(name.begin(), name.end())));
signedName = base64::encode(privateKey->sign(Blob(nameLowercase.begin(), nameLowercase.end())));
publickey = privateKey->getPublicKey().toString();
} catch (const std::exception& e) {
JAMI_ERR("[Account %s] can't export account: %s", getAccountID().c_str(), e.what());
......@@ -1677,7 +1679,7 @@ JamiAccount::registerName(const std::string& password, const std::string& name)
return;
}
nameDir_.get().registerName(ringAccountId_, name, ethAccount_, [acc=getAccountID(), name, w=weak()](NameDirectory::RegistrationResponse response){
nameDir_.get().registerName(ringAccountId_, nameLowercase, ethAccount_, [acc=getAccountID(), name, w=weak()](NameDirectory::RegistrationResponse response){
int res = (response == NameDirectory::RegistrationResponse::success) ? 0 : (
(response == NameDirectory::RegistrationResponse::invalidName) ? 2 : (
(response == NameDirectory::RegistrationResponse::alreadyTaken) ? 3 : 4));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment