libDwmCredence-0.1.32
DwmCredenceEd25519KeyPair.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2022
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
40//---------------------------------------------------------------------------
41
42#ifndef _DWMCREDENCEED25519KEYPAIR_HH_
43#define _DWMCREDENCEED25519KEYPAIR_HH_
44
46
47namespace Dwm {
48
49 namespace Credence {
50
51 //------------------------------------------------------------------------
62 //------------------------------------------------------------------------
64 {
65 public:
66 //----------------------------------------------------------------------
70 //----------------------------------------------------------------------
71 Ed25519KeyPair(const std::string & id = "");
72
73 //----------------------------------------------------------------------
75 //----------------------------------------------------------------------
76 Ed25519KeyPair(const Ed25519KeyPair &) = default;
77
78 //----------------------------------------------------------------------
80 //----------------------------------------------------------------------
82
83 //----------------------------------------------------------------------
85 //----------------------------------------------------------------------
86 const ShortString & Id() const;
87
88 //----------------------------------------------------------------------
90 //----------------------------------------------------------------------
91 const ShortString & Id(const ShortString & id);
92
93 //----------------------------------------------------------------------
96 //----------------------------------------------------------------------
97 const std::string & PublicKey() const;
98
99 //----------------------------------------------------------------------
101 //----------------------------------------------------------------------
102 const std::string & PublicKey(const std::string & publicKey);
103
104 //----------------------------------------------------------------------
107 //----------------------------------------------------------------------
108 const std::string & SecretKey() const;
109
110 //----------------------------------------------------------------------
112 //----------------------------------------------------------------------
113 const std::string & SecretKey(const std::string & secretKey);
114
115 //----------------------------------------------------------------------
118 //----------------------------------------------------------------------
119 bool IsValid() const;
120
121 //----------------------------------------------------------------------
123 //----------------------------------------------------------------------
124 void Clear();
125
126 //----------------------------------------------------------------------
128 //----------------------------------------------------------------------
129 bool operator == (const Ed25519KeyPair & keyPair) const;
130
131 private:
132 ShortString _id;
133 std::string _publicKey;
134 std::string _secretKey;
135 };
136
137 } // namespace Credence
138
139} // namespace Dwm
140
141#endif // _DWMCREDENCEED25519KEYPAIR_HH_
Dwm::Credence::ShortString class declaration.
Encapsulates an Ed25519 key pair.
Definition DwmCredenceEd25519KeyPair.hh:64
bool IsValid() const
Returns true if they keypair is valid (i.e.
const std::string & PublicKey(const std::string &publicKey)
Sets and returns the public key.
const std::string & PublicKey() const
Returns the public key.
Ed25519KeyPair(const Ed25519KeyPair &)=default
Copy constructor.
Ed25519KeyPair(const std::string &id="")
Default constructor.
void Clear()
Clears the contents of the key pair.
const std::string & SecretKey() const
Returns the secret key.
const ShortString & Id(const ShortString &id)
Sets and returns the owner of the keypair.
bool operator==(const Ed25519KeyPair &keyPair) const
operator ==
const std::string & SecretKey(const std::string &secretKey)
Sets and returns the secret key.
~Ed25519KeyPair()
Destructor. Clears the contents of the keys before deallocation.
const ShortString & Id() const
Returns the owner of the keypair.
Encapsulates a string that is restricted to 255 bytes or less.
Definition DwmCredenceShortString.hh:57