Add help text for attribute S/R.
[qpwmc.git] / pwmdKey.cpp
blob33ed7fb5c706f5372183ad0d8528b4c13bb7bfbc
1 /*
2 Copyright (C) 2017-2024 Ben Kibbey <bjk@luxsci.net>
4 This file is part of qpwmc.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
21 #include "pwmdKey.h"
23 PwmdKey::PwmdKey (bool revoked, bool expired, bool disabled, bool invalid,
24 bool encrypt, bool sign, bool certify, bool secret,
25 bool auth, bool qualified, int protocol, int trust)
27 _revoked = revoked;
28 _expired = expired;
29 _disabled = disabled;
30 _invalid = invalid;
31 _canEncrypt = encrypt;
32 _canSign = sign;
33 _canCertify = certify;
34 _secret = secret;
35 _canAuthenticate = auth;
36 _qualified = qualified;
37 _protocol = protocol;
38 _issuerSerial = QString ();
39 _issuerName = QString ();
40 _chainId = QString ();
41 _ownerTrust = trust;
44 PwmdKey::~PwmdKey()
46 while (!_subKeys.isEmpty ())
48 PwmdSubKey *key = _subKeys.takeFirst ();
49 delete key;
52 while (!_userIds.isEmpty ())
54 PwmdUserId *id = _userIds.takeFirst ();
55 delete id;
59 void
60 PwmdKey::setUserIds (QList <PwmdUserId *> list)
62 _userIds = list;
65 QList <PwmdUserId *>
66 PwmdKey::userIds()
68 return _userIds;
71 void
72 PwmdKey::setSubkeys (QList <PwmdSubKey *> list)
74 _subKeys = list;
77 QList <PwmdSubKey *>
78 PwmdKey::subKeys()
80 return _subKeys;
83 bool
84 PwmdKey::isRevoked()
86 return _revoked;
89 void
90 PwmdKey::setRevoked (bool b)
92 _revoked = b;
95 bool
96 PwmdKey::isExpired ()
98 return _expired;
101 void
102 PwmdKey::setExpired (bool b)
104 _expired = b;
107 bool
108 PwmdKey::isDisabled()
110 return _disabled;
113 void
114 PwmdKey::setDisabled (bool b)
116 _disabled = b;
119 bool
120 PwmdKey::isInvalid()
122 return _invalid;
125 void
126 PwmdKey::setInvalid (bool b)
128 _invalid = b;
131 bool
132 PwmdKey::canEncrypt()
134 return _canEncrypt;
137 void
138 PwmdKey::setCanEncrypt (bool b)
140 _canEncrypt = b;
143 bool
144 PwmdKey::canSign()
146 return _canSign;
149 void
150 PwmdKey::setCanSign (bool b)
152 _canSign = b;
155 bool
156 PwmdKey::canCertify()
158 return _canCertify;
161 void
162 PwmdKey::setCanCertify (bool b)
164 _canCertify = b;
167 bool
168 PwmdKey::isSecret()
170 return _secret;
173 void
174 PwmdKey::setSecret (bool b)
176 _secret = b;
179 bool
180 PwmdKey::canAuthenticate()
182 return _canAuthenticate;
185 void
186 PwmdKey::setCanAuthenticate (bool b)
188 _canAuthenticate = b;
191 bool
192 PwmdKey::isQualified()
194 return _qualified;
197 void
198 PwmdKey::setQualified (bool b)
200 _qualified = b;
204 PwmdKey::protocol()
206 return _protocol;
209 void
210 PwmdKey::setProtocol(int n)
212 _protocol = n;
215 QString
216 PwmdKey::issuerSerial()
218 return _issuerSerial;
221 void
222 PwmdKey::setIssuerSerial (QString s)
224 _issuerSerial = s;
227 QString
228 PwmdKey::issuerName()
230 return _issuerName;
233 void
234 PwmdKey::setIssuerName (QString s)
236 _issuerName = s;
239 QString
240 PwmdKey::chainId()
242 return _chainId;
245 void
246 PwmdKey::setChainId(QString s)
248 _chainId = s;
252 PwmdKey::ownerTrust()
254 return _ownerTrust;
257 void
258 PwmdKey::setOwnerTrust (int n)
260 _ownerTrust = n;
263 PwmdSubKey::PwmdSubKey () : PwmdKey()
265 _isCardKey = false;
266 _pubkeyAlgo = 0;
267 _nbits = 0;
268 _keyId = QString ();
269 _fingerprint = QString ();
270 _keygrip = QString ();
271 _timestamp = 0;
272 _expires = 0;
273 _cardNumber = QString ();
274 _eccCurve = QString ();
277 PwmdSubKey::~PwmdSubKey()
281 bool
282 PwmdSubKey::isCardKey()
284 return _isCardKey;
287 void
288 PwmdSubKey::setCardKey(bool b)
290 _isCardKey = b;
294 PwmdSubKey::pubkeyAlgo()
296 return _pubkeyAlgo;
299 void
300 PwmdSubKey::setPubkeyAlgo(int n)
302 _pubkeyAlgo = n;
305 void
306 PwmdSubKey::setNBits (unsigned n)
308 _nbits = n;
311 unsigned
312 PwmdSubKey::nBits ()
314 return _nbits;
317 QString
318 PwmdSubKey::keyId()
320 return _keyId;
323 void
324 PwmdSubKey::setKeyId (QString s)
326 _keyId = s;
329 QString
330 PwmdSubKey::fingerprint()
332 return _fingerprint;
335 void
336 PwmdSubKey::setFingerprint (QString s)
338 _fingerprint = s;
341 QString
342 PwmdSubKey::keygrip()
344 return _keygrip;
347 void
348 PwmdSubKey::setKeygrip (QString s)
350 _keygrip = s;
353 long
354 PwmdSubKey::created()
356 return _timestamp;
359 void
360 PwmdSubKey::setCreated (long n)
362 _timestamp = n;
365 long
366 PwmdSubKey::expires()
368 return _expires;
371 void
372 PwmdSubKey::setExpires (long n)
374 _expires = n;
377 QString
378 PwmdSubKey::cardNumber()
380 return _cardNumber;
383 void
384 PwmdSubKey::setCardNumber (QString s)
386 _cardNumber = s;
389 QString
390 PwmdSubKey::curve()
392 return _eccCurve;
395 void
396 PwmdSubKey::setCurve (QString s)
398 _eccCurve = s;
401 PwmdUserId::PwmdUserId ()
403 _revoked = false;
404 _invalid = false;
405 _validity = 0;
406 _userId = QString ();
407 _name = QString ();
408 _email = QString ();
409 _comment = QString ();
412 PwmdUserId::~PwmdUserId()
416 bool
417 PwmdUserId::isRevoked()
419 return _revoked;
422 void
423 PwmdUserId::setRevoked (bool b)
425 _revoked = b;
428 bool
429 PwmdUserId::isInvalid()
431 return _invalid;
434 void
435 PwmdUserId::setInvalid (bool b)
437 _invalid = b;
441 PwmdUserId::validity()
443 return _validity;
446 void
447 PwmdUserId::setValidity (int n)
449 _validity = n;
452 QString
453 PwmdUserId::userId()
455 return _userId;
458 void
459 PwmdUserId::setUserId(QString s)
461 _userId = s;
464 QString
465 PwmdUserId::name()
467 return _name;
470 void
471 PwmdUserId::setName (QString s)
473 _name = s;
476 QString
477 PwmdUserId::email()
479 return _email;
482 void
483 PwmdUserId::setEmail (QString s)
485 _email = s;
488 QString
489 PwmdUserId::comment()
491 return _comment;
494 void
495 PwmdUserId::setComment (QString s)
497 _comment = s;
500 PwmdKeyItemData::PwmdKeyItemData (PwmdKey *k, PwmdSubKey *s)
502 _key = k;
503 _subKey = s;
506 PwmdKeyItemData::~PwmdKeyItemData ()
508 if (_key)
509 delete _key;
511 if (_subKey)
512 delete _subKey;
515 void
516 PwmdKeyItemData::setKey (PwmdKey *k)
518 _key = k;
521 PwmdKey *
522 PwmdKeyItemData::key ()
524 return _key;
527 void
528 PwmdKeyItemData::setSubKey (PwmdSubKey *k)
530 _subKey = k;
533 PwmdSubKey *
534 PwmdKeyItemData::subKey ()
536 return _subKey;