2008-06-13 11:26:31 -04:00
|
|
|
#ifndef RS_TLV_KEY_TYPES_H
|
|
|
|
#define RS_TLV_KEY_TYPES_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rstlvkeys.h
|
|
|
|
*
|
|
|
|
* RetroShare Serialiser.
|
|
|
|
*
|
|
|
|
* Copyright 2008 by Robert Fernie
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* These are the Compound TLV structures that must be (un)packed.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include "serialiser/rstlvtypes.h"
|
|
|
|
|
|
|
|
const uint32_t RSTLV_KEY_TYPE_MASK = 0x000f;
|
|
|
|
const uint32_t RSTLV_KEY_DISTRIB_MASK = 0x00f0;
|
|
|
|
|
|
|
|
const uint32_t RSTLV_KEY_TYPE_PUBLIC_ONLY = 0x0001;
|
|
|
|
const uint32_t RSTLV_KEY_TYPE_FULL = 0x0002;
|
|
|
|
const uint32_t RSTLV_KEY_DISTRIB_PUBLIC = 0x0010;
|
|
|
|
const uint32_t RSTLV_KEY_DISTRIB_PRIVATE = 0x0020;
|
|
|
|
const uint32_t RSTLV_KEY_DISTRIB_ADMIN = 0x0040;
|
|
|
|
|
|
|
|
|
|
|
|
class RsTlvSecurityKey: public RsTlvItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsTlvSecurityKey();
|
|
|
|
virtual ~RsTlvSecurityKey() { return; }
|
2009-09-08 16:18:43 -04:00
|
|
|
virtual uint32_t TlvSize();
|
2008-06-13 11:26:31 -04:00
|
|
|
virtual void TlvClear();
|
|
|
|
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset); /* serialise */
|
|
|
|
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deserialise */
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
|
|
|
/* clears KeyData - but doesn't delete - to transfer ownership */
|
|
|
|
void ShallowClear();
|
|
|
|
|
|
|
|
std::string keyId; // Mandatory :
|
|
|
|
uint32_t keyFlags; // Mandatory ;
|
|
|
|
uint32_t startTS; // Mandatory :
|
|
|
|
uint32_t endTS; // Mandatory :
|
|
|
|
RsTlvBinaryData keyData; // Mandatory :
|
|
|
|
};
|
|
|
|
|
|
|
|
class RsTlvSecurityKeySet: public RsTlvItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsTlvSecurityKeySet() { return; }
|
|
|
|
virtual ~RsTlvSecurityKeySet() { return; }
|
2009-09-08 16:18:43 -04:00
|
|
|
virtual uint32_t TlvSize();
|
2008-06-13 11:26:31 -04:00
|
|
|
virtual void TlvClear();
|
|
|
|
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset); /* serialise */
|
|
|
|
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deserialise */
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
|
|
|
std::string groupId; // Mandatory :
|
|
|
|
std::map<std::string, RsTlvSecurityKey> keys; // Mandatory :
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RsTlvKeySignature: public RsTlvItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsTlvKeySignature();
|
|
|
|
virtual ~RsTlvKeySignature() { return; }
|
2009-09-08 16:18:43 -04:00
|
|
|
virtual uint32_t TlvSize();
|
2008-06-13 11:26:31 -04:00
|
|
|
virtual void TlvClear();
|
|
|
|
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset); /* serialise */
|
|
|
|
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deserialise */
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
|
|
|
|
|
|
|
void ShallowClear(); /* clears signData - but doesn't delete */
|
|
|
|
|
|
|
|
std::string keyId; // Mandatory :
|
2010-02-03 16:21:04 -05:00
|
|
|
RsTlvBinaryData signData; // Mandatory :
|
|
|
|
std::string sslCert; // Mandatory :
|
2008-06-13 11:26:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|