libdrmconf  0.12.0
A library to program DMR radios.
encryptionextension.hh
1 #ifndef ENCRYPTIONEXTENSION_HH
2 #define ENCRYPTIONEXTENSION_HH
3 
4 #include "configobject.hh"
5 
6 
10 {
11  Q_OBJECT
12  Q_CLASSINFO("IdPrefix", "key")
13 
14 
15  Q_PROPERTY(QString key READ toHex WRITE fromHex)
16 
17 protected:
19  explicit EncryptionKey(QObject *parent=nullptr);
20 
21 public:
22  void clear();
23 
25  virtual bool fromHex(const QString &hex, const ErrorStack &err=ErrorStack());
27  virtual QString toHex() const;
28 
30  const QByteArray &key() const;
32  virtual bool setKey(const QByteArray &key, const ErrorStack &err=ErrorStack());
33 
34 protected:
37  QByteArray _key;
38 };
39 
40 
47 {
48  Q_OBJECT
49  Q_CLASSINFO("description", "A basic DMR encryption key.")
50  Q_CLASSINFO("longDescription",
51  "This is a variable sized pre-shared key that can be used to encrypt/decrypt traffic "
52  "on DMR channels. Encryption is forbidden in HAM radio context!")
53 
54 public:
56  Q_INVOKABLE explicit BasicEncryptionKey(QObject *parent=nullptr);
57 
58  ConfigItem *clone() const;
59 
60 public:
61  YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
62  bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
63 };
64 
65 
72 {
73  Q_OBJECT
74  Q_CLASSINFO("description", "An enhanced DMR encryption key.")
75  Q_CLASSINFO("longDescription",
76  "This is a 40bit pre-shared RC4 key, that can be used to encrypt/decrypt traffic on "
77  "DMR channels. Encryption is forbidden in HAM radio context!")
78 
79 public:
81  Q_INVOKABLE explicit EnhancedEncryptionKey(QObject *parent=nullptr);
82 
83  ConfigItem *clone() const;
84  bool fromHex(const QString &hex, const ErrorStack &err=ErrorStack());
85 
86  bool setKey(const QByteArray &key, const ErrorStack &err);
87 
88 public:
89  YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
90  bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
91 };
92 
93 
100 {
101  Q_OBJECT
102 
103  Q_CLASSINFO("description", "An AES (advanced) DMR encryption key.")
104  Q_CLASSINFO("longDescription",
105  "This is a variable sized (usually 128-256bit) pre-shared key that can be used to "
106  "encrypt/decrypt traffic on DMR channels. Encryption is forbidden in HAM radio "
107  "context!")
108 
109 public:
111  Q_INVOKABLE explicit AESEncryptionKey(QObject *parent=nullptr);
112 
113  ConfigItem *clone() const;
114 
115  bool setKey(const QByteArray &key, const ErrorStack &err);
116 
117 public:
118  YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
119  bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
120 };
121 
122 Q_DECLARE_OPAQUE_POINTER(AESEncryptionKey*)
123 
124 
125 
133 {
134  Q_OBJECT
135 
136 public:
138  explicit EncryptionKeys(QObject *parent=nullptr);
139 
140  int add(ConfigObject *obj, int row=-1, bool unique=true);
141 
142  EncryptionKey *key(int index) const;
143 
144  ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
145 };
146 
147 
148 
149 #endif // ENCRYPTIONEXTENSION_HH
Represents an AES (enhanced) encryption key.
Definition: encryptionextension.hh:100
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: encryptionextension.cc:191
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition: encryptionextension.cc:202
Represents a DMR (basic) encryption key.
Definition: encryptionextension.hh:47
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: encryptionextension.cc:71
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition: encryptionextension.cc:82
Parse context for config objects.
Definition: configobject.hh:48
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
virtual ConfigItem * clone() const =0
Clones this item.
List class for config objects.
Definition: configobject.hh:349
Base class of all labeled and named objects.
Definition: configobject.hh:199
Base class of all encryption keys.
Definition: encryptionextension.hh:10
QString key
The key representation as a hex string.
Definition: encryptionextension.hh:15
void clear()
Clears the config object.
Definition: encryptionextension.cc:15
virtual bool setKey(const QByteArray &key, const ErrorStack &err=ErrorStack())
Sets the binary key.
Definition: encryptionextension.cc:35
virtual QString toHex() const
Converts a key to a hex string.
Definition: encryptionextension.cc:25
EncryptionKey(QObject *parent=nullptr)
Hidden constructor.
Definition: encryptionextension.cc:8
QByteArray _key
Holds the key data.
Definition: encryptionextension.hh:37
virtual bool fromHex(const QString &hex, const ErrorStack &err=ErrorStack())
Creates a key from the given hex-string.
Definition: encryptionextension.cc:20
The list of encryption keys.
Definition: encryptionextension.hh:133
Represents an (enhanced) RC4 encryption key.
Definition: encryptionextension.hh:72
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition: encryptionextension.cc:147
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: encryptionextension.cc:136
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41