summaryrefslogtreecommitdiff
path: root/modules/encryption
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
committerAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
commit42238034490fb5479d787bd1695750387d508200 (patch)
treec93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/encryption
parentd492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff)
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most object relationships implicitly defined, and use the graph to trace references between objects to determine relationships. Edges may also be marked as having a dependency of the object they point to, which allows for automatic cleanup and deletion of most objects when no longer needed. Additionally, this allows not having to require in-memory copies of everything when using external databases. db_sql has been rewritten for this and now always requires a database to function. db_sql with MySQL now requires InnoDB to make use of transactions and foreign key constraints.
Diffstat (limited to 'modules/encryption')
-rw-r--r--modules/encryption/enc_bcrypt.cpp22
-rw-r--r--modules/encryption/enc_md5.cpp16
-rw-r--r--modules/encryption/enc_none.cpp16
-rw-r--r--modules/encryption/enc_old.cpp16
-rw-r--r--modules/encryption/enc_sha1.cpp16
-rw-r--r--modules/encryption/enc_sha256.cpp19
6 files changed, 64 insertions, 41 deletions
diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp
index 296d81b53..1a4e00e20 100644
--- a/modules/encryption/enc_bcrypt.cpp
+++ b/modules/encryption/enc_bcrypt.cpp
@@ -900,19 +900,19 @@ class EBCRYPT : public Module
void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
{
- const NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (na == NULL)
return;
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
- size_t pos = nc->pass.find(':');
+ size_t pos = nc->GetPassword().find(':');
if (pos == Anope::string::npos)
return;
- Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos);
+ Anope::string hash_method(nc->GetPassword().begin(), nc->GetPassword().begin() + pos);
if (hash_method != "bcrypt")
return;
- if (Compare(req->GetPassword(), nc->pass.substr(7)))
+ if (Compare(req->GetPassword(), nc->GetPassword().substr(7)))
{
/* if we are NOT the first module in the list,
* we want to re-encrypt the pass with the new encryption
@@ -921,19 +921,23 @@ class EBCRYPT : public Module
unsigned int hashrounds = 0;
try
{
- size_t roundspos = nc->pass.find('$', 11);
+ size_t roundspos = nc->GetPassword().find('$', 11);
if (roundspos == Anope::string::npos)
throw ConvertException("Could not find hashrounds");
- hashrounds = convertTo<unsigned int>(nc->pass.substr(11, roundspos - 11));
+ hashrounds = convertTo<unsigned int>(nc->GetPassword().substr(11, roundspos - 11));
}
catch (const ConvertException &)
{
- Log(this) << "Could not get the round size of a hash. This is probably a bug. Hash: " << nc->pass;
+ Log(this) << "Could not get the round size of a hash. This is probably a bug. Hash: " << nc->GetPassword();
}
if (ModuleManager::FindFirstOf(ENCRYPTION) != this || (hashrounds && hashrounds != rounds))
- Anope::Encrypt(req->GetPassword(), nc->pass);
+ {
+ Anope::string p;
+ Anope::Encrypt(req->GetPassword(), p);
+ nc->SetPassword(p);
+ }
req->Success(this);
}
}
diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp
index 442918aa6..3de183adb 100644
--- a/modules/encryption/enc_md5.cpp
+++ b/modules/encryption/enc_md5.cpp
@@ -371,27 +371,31 @@ class EMD5 : public Module
void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
{
- const NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (na == NULL)
return;
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
- size_t pos = nc->pass.find(':');
+ size_t pos = nc->GetPassword().find(':');
if (pos == Anope::string::npos)
return;
- Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos);
+ Anope::string hash_method(nc->GetPassword().begin(), nc->GetPassword().begin() + pos);
if (!hash_method.equals_cs("md5"))
return;
Anope::string buf;
this->OnEncrypt(req->GetPassword(), buf);
- if (nc->pass.equals_cs(buf))
+ if (nc->GetPassword().equals_cs(buf))
{
/* if we are NOT the first module in the list,
* we want to re-encrypt the pass with the new encryption
*/
if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
- Anope::Encrypt(req->GetPassword(), nc->pass);
+ {
+ Anope::string p;
+ Anope::Encrypt(req->GetPassword(), p);
+ nc->SetPassword(p);
+ }
req->Success(this);
}
}
diff --git a/modules/encryption/enc_none.cpp b/modules/encryption/enc_none.cpp
index 8781be910..86f01ae38 100644
--- a/modules/encryption/enc_none.cpp
+++ b/modules/encryption/enc_none.cpp
@@ -46,27 +46,31 @@ class ENone : public Module
void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
{
- const NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (na == NULL)
return;
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
- size_t pos = nc->pass.find(':');
+ size_t pos = nc->GetPassword().find(':');
if (pos == Anope::string::npos)
return;
- Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos);
+ Anope::string hash_method(nc->GetPassword().begin(), nc->GetPassword().begin() + pos);
if (!hash_method.equals_cs("plain"))
return;
Anope::string buf;
this->OnEncrypt(req->GetPassword(), buf);
- if (nc->pass.equals_cs(buf))
+ if (nc->GetPassword().equals_cs(buf))
{
/* if we are NOT the first module in the list,
* we want to re-encrypt the pass with the new encryption
*/
if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
- Anope::Encrypt(req->GetPassword(), nc->pass);
+ {
+ Anope::string p;
+ Anope::Encrypt(req->GetPassword(), p);
+ nc->SetPassword(p);
+ }
req->Success(this);
}
}
diff --git a/modules/encryption/enc_old.cpp b/modules/encryption/enc_old.cpp
index f36b2236b..ec2c076cf 100644
--- a/modules/encryption/enc_old.cpp
+++ b/modules/encryption/enc_old.cpp
@@ -87,27 +87,31 @@ class EOld : public Module
void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
{
- const NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (na == NULL)
return;
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
- size_t pos = nc->pass.find(':');
+ size_t pos = nc->GetPassword().find(':');
if (pos == Anope::string::npos)
return;
- Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos);
+ Anope::string hash_method(nc->GetPassword().begin(), nc->GetPassword().begin() + pos);
if (!hash_method.equals_cs("oldmd5"))
return;
Anope::string buf;
this->OnEncrypt(req->GetPassword(), buf);
- if (nc->pass.equals_cs(buf))
+ if (nc->GetPassword().equals_cs(buf))
{
/* if we are NOT the first module in the list,
* we want to re-encrypt the pass with the new encryption
*/
if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
- Anope::Encrypt(req->GetPassword(), nc->pass);
+ {
+ Anope::string p;
+ Anope::Encrypt(req->GetPassword(), p);
+ nc->SetPassword(p);
+ }
req->Success(this);
}
}
diff --git a/modules/encryption/enc_sha1.cpp b/modules/encryption/enc_sha1.cpp
index d2189a941..010add276 100644
--- a/modules/encryption/enc_sha1.cpp
+++ b/modules/encryption/enc_sha1.cpp
@@ -226,24 +226,28 @@ class ESHA1 : public Module
void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
{
- const NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (na == NULL)
return;
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
- size_t pos = nc->pass.find(':');
+ size_t pos = nc->GetPassword().find(':');
if (pos == Anope::string::npos)
return;
- Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos);
+ Anope::string hash_method(nc->GetPassword().begin(), nc->GetPassword().begin() + pos);
if (!hash_method.equals_cs("sha1"))
return;
Anope::string buf;
this->OnEncrypt(req->GetPassword(), buf);
- if (nc->pass.equals_cs(buf))
+ if (nc->GetPassword().equals_cs(buf))
{
if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
- Anope::Encrypt(req->GetPassword(), nc->pass);
+ {
+ Anope::string p;
+ Anope::Encrypt(req->GetPassword(), p);
+ nc->SetPassword(p);
+ }
req->Success(this);
}
}
diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp
index b8c5c8e76..e7989c24d 100644
--- a/modules/encryption/enc_sha256.cpp
+++ b/modules/encryption/enc_sha256.cpp
@@ -55,7 +55,6 @@ static const unsigned SHA256_BLOCK_SIZE = 512 / 8;
inline static uint32_t SHFR(uint32_t x, uint32_t n) { return x >> n; }
inline static uint32_t ROTR(uint32_t x, uint32_t n) { return (x >> n) | (x << ((sizeof(x) << 3) - n)); }
-inline static uint32_t ROTL(uint32_t x, uint32_t n) { return (x << n) | (x >> ((sizeof(x) << 3) - n)); }
inline static uint32_t CH(uint32_t x, uint32_t y, uint32_t z) { return (x & y) ^ (~x & z); }
inline static uint32_t MAJ(uint32_t x, uint32_t y, uint32_t z) { return (x & y) ^ (x & z) ^ (y & z); }
@@ -308,29 +307,33 @@ class ESHA256 : public Module
void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
{
- const NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (na == NULL)
return;
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
- size_t pos = nc->pass.find(':');
+ size_t pos = nc->GetPassword().find(':');
if (pos == Anope::string::npos)
return;
- Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos);
+ Anope::string hash_method(nc->GetPassword().substr(0, pos));
if (!hash_method.equals_cs("sha256"))
return;
- GetIVFromPass(nc->pass);
+ GetIVFromPass(nc->GetPassword());
use_iv = true;
Anope::string buf;
this->OnEncrypt(req->GetPassword(), buf);
- if (nc->pass.equals_cs(buf))
+ if (nc->GetPassword().equals_cs(buf))
{
/* if we are NOT the first module in the list,
* we want to re-encrypt the pass with the new encryption
*/
if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
- Anope::Encrypt(req->GetPassword(), nc->pass);
+ {
+ Anope::string p;
+ Anope::Encrypt(req->GetPassword(), p);
+ nc->SetPassword(p);
+ }
req->Success(this);
}
}