2020-05-22 16:18:41 +03:00
|
|
|
/*
|
2024-10-08 20:44:25 +03:00
|
|
|
* Copyright (c) 2013-2024, The PurpleI2P Project
|
2020-05-22 16:18:41 +03:00
|
|
|
*
|
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3
|
|
|
|
*
|
|
|
|
* See full license text in LICENSE file at top of project tree
|
|
|
|
*/
|
|
|
|
|
2016-02-18 23:57:43 +03:00
|
|
|
#ifndef FAMILY_H__
|
2016-02-21 04:20:19 +03:00
|
|
|
#define FAMILY_H__
|
2016-02-18 23:57:43 +03:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
2024-10-08 20:44:25 +03:00
|
|
|
#include <openssl/evp.h>
|
2016-02-20 00:13:46 +03:00
|
|
|
#include "Identity.h"
|
2016-02-18 23:57:43 +03:00
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace data
|
|
|
|
{
|
2022-03-24 22:50:20 +03:00
|
|
|
typedef int FamilyID;
|
2016-02-18 23:57:43 +03:00
|
|
|
class Families
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
Families ();
|
|
|
|
~Families ();
|
|
|
|
void LoadCertificates ();
|
2018-01-06 06:48:51 +03:00
|
|
|
bool VerifyFamily (const std::string& family, const IdentHash& ident,
|
2022-03-24 22:50:20 +03:00
|
|
|
const char * signature, const char * key = nullptr) const;
|
|
|
|
FamilyID GetFamilyID (const std::string& family) const;
|
2016-02-18 23:57:43 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void LoadCertificate (const std::string& filename);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2024-10-08 20:44:25 +03:00
|
|
|
std::map<std::string, std::pair<EVP_PKEY *, FamilyID> > m_SigningKeys; // family -> (verification pkey, id)
|
2018-01-06 06:48:51 +03:00
|
|
|
};
|
2016-02-21 04:20:19 +03:00
|
|
|
|
|
|
|
std::string CreateFamilySignature (const std::string& family, const IdentHash& ident);
|
|
|
|
// return base64 signature of empty string in case of failure
|
2016-02-18 23:57:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|