libzypp 17.38.3
PublicKey.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <climits>
13
14#include <iostream>
15#include <utility>
16#include <vector>
17
18#include "PublicKey.h"
19#include "KeyManager.h"
20
25#include <zypp/TmpPath.h>
26#include <zypp/PathInfo.h>
29#include <zypp-core/Date.h>
30
31#include <gpgme.h>
32
33using std::endl;
34
35#undef ZYPP_BASE_LOGGER_LOGGROUP
36#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::gpg"
37
39namespace zypp
40{
42 namespace
43 {
44 inline bool isExpired( const Date & expires_r )
45 { return( expires_r && expires_r < Date::now() ); }
46
47 inline int hasDaysToLive( const Date & expires_r )
48 {
49 if ( expires_r )
50 {
51 Date exp( expires_r - Date::now() );
52 int ret = exp / Date::day;
53 if ( exp < 0 ) ret -= 1;
54 return ret;
55 }
56 return INT_MAX;
57 }
58
59 inline std::string expiresDetail( const Date & expires_r )
60 {
61 str::Str str;
62 if ( ! expires_r )
63 {
64 // translators: an annotation to a gpg keys expiry date
65 str << _("does not expire");
66 }
67 else if ( isExpired( expires_r ) )
68 {
69 // translators: an annotation to a gpg keys expiry date: "expired: 1999-04-12"
70 str << ( str::Format(_("expired: %1%") ) % expires_r.printDate() );
71 }
72 else
73 {
74 // translators: an annotation to a gpg keys expiry date: "expires: 2111-04-12"
75 str << ( str::Format(_("expires: %1%") ) % expires_r.printDate() );
76 }
77 return str;
78 }
79
80 inline std::string expiresDetailVerbose( const Date & expires_r )
81 {
82 if ( !expires_r )
83 { // translators: an annotation to a gpg keys expiry date
84 return _("(does not expire)");
85 }
86 std::string ret( expires_r.asString() );
87 int ttl( hasDaysToLive( expires_r ) );
88 if ( ttl <= 90 )
89 {
90 ret += " ";
91 if ( ttl < 0 )
92 { // translators: an annotation to a gpg keys expiry date
93 ret += _("(EXPIRED)");
94 }
95 else if ( ttl == 0 )
96 { // translators: an annotation to a gpg keys expiry date
97 ret += _("(expires within 24h)");
98 }
99 else
100 { // translators: an annotation to a gpg keys expiry date
101 ret += str::form( PL_("(expires in %d day)", "(expires in %d days)", ttl ), ttl );
102 }
103 }
104 return ret;
105 }
106
107 inline std::string keyAlgoName( const gpgme_subkey_t & key_r )
108 {
109 std::string ret;
110 if ( const char * n = ::gpgme_pubkey_algo_name( key_r->pubkey_algo ) )
111 ret = str::Str() << n << ' ' << key_r->length;
112 else
113 ret = "?";
114 return ret;
115 }
116
117 inline bool shorterIsSuffixCI( const std::string & lhs, const std::string & rhs )
118 {
119 if ( lhs.size() >= rhs.size() )
120 return str::endsWithCI( lhs, rhs );
121 return str::endsWithCI( rhs, lhs );
122 }
123 } //namespace
125
126
131
133 {
134 std::string _id;
137
138 public:
140 static shared_ptr<Impl> nullimpl();
141
142 private:
143 friend Impl * rwcowClone<Impl>( const Impl * rhs );
145 Impl * clone() const;
146 };
147
149 {
150 static shared_ptr<Impl> _nullimpl( new Impl );
151 return _nullimpl;
152 }
153
155 {
156 return new Impl( *this );
157 }
158
162
164 : _pimpl( Impl::nullimpl() )
165 {}
166
167 PublicSubkeyData::PublicSubkeyData(const _gpgme_subkey *rawSubKeyData)
168 : _pimpl (new Impl)
169 {
170 _pimpl->_created = zypp::Date(rawSubKeyData->timestamp);
171 _pimpl->_expires = zypp::Date(rawSubKeyData->expires);
172 _pimpl->_id = str::asString(rawSubKeyData->keyid);
173 }
174
177
178 PublicSubkeyData::operator bool() const
179 { return !_pimpl->_id.empty(); }
180
181 std::string PublicSubkeyData::id() const
182 { return _pimpl->_id; }
183
185 { return _pimpl->_created; }
186
188 { return _pimpl->_expires; }
189
191 { return isExpired( _pimpl->_expires ); }
192
194 { return hasDaysToLive( _pimpl->_expires ); }
195
196 std::string PublicSubkeyData::asString() const
197 {
198 return str::Str() << id() << " " << created().printDate() << " [" << expiresDetail( expires() ) << "]";
199 }
200
205
207 {
208 std::string _keyid;
209 std::string _name;
212
213 public:
215 static shared_ptr<Impl> nullimpl();
216
217 private:
218 friend Impl * rwcowClone<Impl>( const Impl * rhs );
220 Impl * clone() const;
221 };
222
228
233
237
241
242 PublicKeySignatureData::PublicKeySignatureData(const _gpgme_key_sig *rawKeySignatureData)
243 : _pimpl (new Impl)
244 {
245 _pimpl->_keyid = str::asString(rawKeySignatureData->keyid);
246 _pimpl->_name = str::asString(rawKeySignatureData->uid);
247 _pimpl->_created = zypp::Date(rawKeySignatureData->timestamp);
248 _pimpl->_expires = zypp::Date(rawKeySignatureData->expires);
249 }
250
253
254 PublicKeySignatureData::operator bool() const
255 { return !_pimpl->_keyid.empty(); }
256
257 std::string PublicKeySignatureData::id() const
258 { return _pimpl->_keyid; }
259
261 { return _pimpl->_name; }
262
264 { return _pimpl->_created; }
265
267 { return _pimpl->_expires; }
268
270 { return isExpired( _pimpl->_expires ); }
271
273 { return hasDaysToLive( _pimpl->_expires ); }
274
276 {
277 std::string nameStr;
278 if (!name().empty()) {
279 nameStr = str::Str() << name() << " ";
280 }
281 else {
282 nameStr = "[User ID not found] ";
283 }
284 return str::Str() << nameStr
285 << id() << " "
286 << created().printDate()
287 << " [" << expiresDetail( expires() ) << "]";
288 }
289
296 {
297 std::string _id;
298 std::string _name;
299 std::string _fingerprint;
300 std::string _algoName;
303
304 std::vector<PublicSubkeyData> _subkeys;
305 std::vector<PublicKeySignatureData> _signatures;
306
307 public:
308 bool hasSubkeyId( const std::string & id_r ) const;
309
310 public:
312 static shared_ptr<Impl> nullimpl();
313 static shared_ptr<Impl> fromGpgmeKey(gpgme_key_t rawData);
314
315 private:
316 friend Impl * rwcowClone<Impl>( const Impl * rhs );
318 Impl * clone() const;
319 };
320
321 bool PublicKeyData::Impl::hasSubkeyId( const std::string &id_r) const
322 {
323 bool ret = false;
324 for ( const PublicSubkeyData & sub : _subkeys ) {
325 if ( shorterIsSuffixCI( sub.id(), id_r ) ) {
326 ret = true;
327 break;
328 }
329 }
330 return ret;
331 }
332
334 {
335 static shared_ptr<Impl> _nullimpl( new Impl );
336 return _nullimpl;
337 }
338
340 {
341 //gpgme stores almost nothing in the top level key
342 //the information we look for is stored in the subkey, where subkey[0]
343 //is always the primary key
344 gpgme_subkey_t sKey = rawData->subkeys;
345 if (sKey) {
347 //libzypp expects the date of the latest signature on the first uid
348 if ( rawData->uids && rawData->uids->signatures ) {
349 data->_created = zypp::Date(rawData->uids->signatures->timestamp);
350 // bsc#1179222: The keyring does not order the signatures when multiple
351 // versions of the same key are imported. We take the last signature here,
352 // the one GPGME_EXPORT_MODE_MINIMAL will later use in export.
353 for ( auto t = rawData->uids->signatures->next; t; t = t->next ) {
354 if (t->keyid != nullptr) {
355 data->_signatures.push_back(PublicKeySignatureData(t));
356 }
357
358 if ( t->timestamp > data->_created )
359 data->_created = t->timestamp;
360 }
361 }
362 else
363 data->_created = zypp::Date(sKey->timestamp);
364
365 data->_expires = zypp::Date(sKey->expires);
366 data->_fingerprint = str::asString(sKey->fpr);
367 data->_algoName = keyAlgoName( sKey );
368 data->_id = str::asString(sKey->keyid);
369
370 //get the primary user ID
371 if (rawData->uids) {
372 data->_name = str::asString(rawData->uids->uid);
373 }
374
375 //the rest of the keys
376 sKey = sKey->next;
377 while (sKey) {
378 data->_subkeys.push_back( PublicSubkeyData(sKey) );
379 sKey = sKey->next;
380 }
381 return data;
382 }
383 return nullimpl();
384 }
385
387 {
388 return new Impl( *this );
389 }
390
394
396 : _pimpl( Impl::nullimpl() )
397 {}
398
400 : _pimpl( std::move(data) )
401 {}
402
405
408
409 PublicKeyData::operator bool() const
410 { return !_pimpl->_fingerprint.empty(); }
411
412 std::string PublicKeyData::id() const
413 { return _pimpl->_id; }
414
415 std::string PublicKeyData::name() const
416 { return _pimpl->_name; }
417
418 std::string PublicKeyData::fingerprint() const
419 { return _pimpl->_fingerprint; }
420
421 std::string PublicKeyData::algoName() const
422 { return _pimpl->_algoName; }
423
425 { return _pimpl->_created; }
426
428 { return _pimpl->_expires; }
429
431 { return isExpired( _pimpl->_expires ); }
432
434 { return hasDaysToLive( _pimpl->_expires ); }
435
437 { return expiresDetailVerbose( _pimpl->_expires ); }
438
440 { return _pimpl->_id.empty() ? _pimpl->_id : str::toLower( _pimpl->_id.substr(8,8) ); }
441
443 { return _pimpl->_created ? str::hexstring( _pimpl->_created ).substr(2) : std::string(); }
444
445 std::string PublicKeyData::rpmName() const
446 { return str::Format( "gpg-pubkey-%1%-%2%" ) % gpgPubkeyVersion() % gpgPubkeyRelease(); }
447
448 std::string PublicKeyData::asString() const
449 {
450 if ( not *this )
451 return "[NO_KEY]";
452
454 str << "[" << _pimpl->_id << "-" << gpgPubkeyRelease();
455 for ( auto && sub : _pimpl->_subkeys )
456 str << ", " << sub.id();
457 return str << "] [" << _pimpl->_name.c_str() << "] [" << expiresDetail( _pimpl->_expires ) << "]";
458 }
459
461 { return !_pimpl->_subkeys.empty(); }
462
464 { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
465
467 { return makeIterable( &(*_pimpl->_signatures.begin()), &(*_pimpl->_signatures.end()) ); }
468
469 bool PublicKeyData::providesKey( const std::string & id_r ) const
470 {
471 if ( not isSafeKeyId( id_r ) )
472 return( id_r.size() == 8 && str::endsWithCI( _pimpl->_id, id_r ) );
473
474 if ( str::endsWithCI( _pimpl->_fingerprint, id_r ) )
475 return true;
476
477 return _pimpl->hasSubkeyId( id_r );
478 }
479
482
483 std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj )
484 {
485 str << "[" << obj.name() << "]" << endl;
486 str << " fpr " << obj.fingerprint() << endl;
487 str << " id " << obj.id() << endl;
488 str << " alg " << obj.algoName() << endl;
489 str << " cre " << Date::ValueType(obj.created()) << ' ' << obj.created() << endl;
490 str << " exp " << Date::ValueType(obj.expires()) << ' ' << obj.expiresAsString() << endl;
491 str << " ttl " << obj.daysToLive() << endl;
492 for ( auto && sub : obj._pimpl->_subkeys )
493 str << " sub " << sub << endl;
494 str << " rpm " << obj.gpgPubkeyVersion() << "-" << obj.gpgPubkeyRelease() << endl;
495 return str;
496 }
497
498 bool operator==( const PublicKeyData & lhs, const PublicKeyData & rhs )
499 { return ( lhs.fingerprint() == rhs.fingerprint() && lhs.created() == rhs.created() ); }
500
501
507 {
509 {}
510
511 Impl( const Pathname & keyFile_r )
512 : _dontUseThisPtrDirectly( new filesystem::TmpFile )
513 {
514 PathInfo info( keyFile_r );
515 MIL << "Taking pubkey from " << keyFile_r << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyFile_r, "sha1") << endl;
516
517 if ( !info.isExist() )
518 ZYPP_THROW(Exception("Can't read public key from " + keyFile_r.asString() + ", file not found"));
519
520 if ( filesystem::hardlinkCopy( keyFile_r, path() ) != 0 )
521 ZYPP_THROW(Exception("Can't copy public key data from " + keyFile_r.asString() + " to " + path().asString() ));
522
523 readFromFile();
524 }
525
526 Impl( const filesystem::TmpFile & sharedFile_r )
527 : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
528 { readFromFile(); }
529
530 // private from keyring
531 Impl( const filesystem::TmpFile & sharedFile_r, const PublicKeyData & keyData_r )
532 : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
533 , _keyData( keyData_r )
534 {
535 if ( ! keyData_r )
536 {
537 WAR << "Invalid PublicKeyData supplied: scanning from file" << endl;
538 readFromFile();
539 }
540 }
541
542 // private from keyring
543 Impl( const PublicKeyData & keyData_r )
544 : _keyData( keyData_r )
545 {}
546
547 public:
548 const PublicKeyData & keyData() const
549 { return _keyData; }
550
552 { return( /*the one and only intended use*/_dontUseThisPtrDirectly ? _dontUseThisPtrDirectly->path() : Pathname() ); }
553
554 const std::list<PublicKeyData> & hiddenKeys() const
555 { return _hiddenKeys; }
556
557 protected:
559 {
560 PathInfo info( path() );
561 MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl;
562
563 std::list<PublicKeyData> keys = KeyManagerCtx::createForOpenPGP().readKeyFromFile( path() );
564 switch ( keys.size() )
565 {
566 case 0:
567 ZYPP_THROW( BadKeyException( "File " + path().asString() + " doesn't contain public key data" , path() ) );
568 break;
569
570 case 1:
571 // ok.
572 _keyData = keys.back();
573 _hiddenKeys.clear();
574 break;
575
576 default:
577 WAR << "File " << path().asString() << " contains multiple keys: " << keys << endl;
578 _keyData = keys.back();
579 keys.pop_back();
580 _hiddenKeys.swap( keys );
581 break;
582 }
583
584 MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl;
585 }
586
587 private:
588 shared_ptr<filesystem::TmpFile> _dontUseThisPtrDirectly; // shared_ptr ok because TmpFile itself is a refernce type (no COW)
590 std::list<PublicKeyData> _hiddenKeys;
591
592 public:
595 {
596 static shared_ptr<Impl> _nullimpl( new Impl );
597 return _nullimpl;
598 }
599
600 private:
601 friend Impl * rwcowClone<Impl>( const Impl * rhs );
603 Impl * clone() const
604 { return new Impl( *this ); }
605 };
606
607
609 // class PublicKey
612 : _pimpl( Impl::nullimpl() )
613 {}
614
616 : _pimpl( new Impl( file ) )
617 {}
618
620 : _pimpl( new Impl( sharedfile ) )
621 {}
622
623 PublicKey::PublicKey( const filesystem::TmpFile & sharedfile, const PublicKeyData & keyData_r )
624 : _pimpl( new Impl( sharedfile, keyData_r ) )
625 {}
626
628 : _pimpl( new Impl( keyData_r ) )
629 {}
630
633
635 try { return PublicKey( keyFile_r ); } catch(...) { return PublicKey(); }
636
638 { return _pimpl->keyData(); }
639
641 { return _pimpl->path(); }
642
643 const std::list<PublicKeyData> & PublicKey::hiddenKeys() const
644 { return _pimpl->hiddenKeys(); }
645
646 bool PublicKey::fileProvidesKey( const std::string & id_r ) const
647 {
648 if ( providesKey( id_r ) )
649 return true;
650 for ( const auto & keydata : hiddenKeys() ) {
651 if ( keydata.providesKey( id_r ) )
652 return true;
653 }
654 return false;
655 }
656
657 std::string PublicKey::id() const
658 { return keyData().id(); }
659
660 std::string PublicKey::name() const
661 { return keyData().name(); }
662
663 std::string PublicKey::fingerprint() const
664 { return keyData().fingerprint(); }
665
666 std::string PublicKey::algoName() const
667 { return keyData().algoName(); }
668
670 { return keyData().created(); }
671
673 { return keyData().expires(); }
674
676 { return keyData().expired(); }
677
679 { return keyData().daysToLive(); }
680
681 std::string PublicKey::expiresAsString() const
682 { return keyData().expiresAsString(); }
683
684 std::string PublicKey::gpgPubkeyVersion() const
685 { return keyData().gpgPubkeyVersion(); }
686
687 std::string PublicKey::gpgPubkeyRelease() const
688 { return keyData().gpgPubkeyRelease(); }
689
690 std::string PublicKey::asString() const
691 { return keyData().asString(); }
692
693 std::string PublicKey::rpmName() const
694 { return keyData().rpmName(); }
695
696 bool PublicKey::operator==( const PublicKey & rhs ) const
697 { return rhs.keyData() == keyData(); }
698
699 bool PublicKey::operator==( const std::string & sid ) const
700 { return ( isSafeKeyId( sid ) || sid.size() == 8 ) && str::endsWithCI( fingerprint(), sid ); }
701
702 std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
703 { return dumpOn( str, obj.keyData() ); }
704
706} // namespace zypp
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
#define PL_(MSG1, MSG2, N)
Definition Gettext.h:42
#define _(MSG)
Definition Gettext.h:39
#define MIL
Definition Logger.h:100
#define WAR
Definition Logger.h:101
Exception thrown when the supplied key is not a valid gpg key.
Definition PublicKey.h:49
Store and operate on date (time_t).
Definition Date.h:33
static const ValueType day
Definition Date.h:44
time_t ValueType
Definition Date.h:38
static Date now()
Return the current time.
Definition Date.h:78
std::string printDate(DateFormat dateFormat_r=DateFormat::calendar, TimeBase base_r=TB_LOCALTIME) const
Convenience for printing the date only ['2014-02-07'] The default is DateFormat::calendar and TB_LOCA...
Definition Date.h:192
Base class for Exception.
Definition Exception.h:153
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
static KeyManagerCtx createForOpenPGP()
Creates a new KeyManagerCtx for PGP using a volatile temp.
std::list< PublicKeyData > readKeyFromFile(const Pathname &file)
Returns a list of all PublicKeyData found in file.
Class representing one GPG Public Keys data.
Definition PublicKey.h:201
Iterable< KeySignatureIterator > signatures() const
Iterate all key signatures.
Definition PublicKey.cc:466
Date created() const
Creation / last modification date (latest selfsig).
Definition PublicKey.cc:424
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:430
std::string name() const
Key name.
Definition PublicKey.cc:415
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition PublicKey.cc:463
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition PublicKey.cc:433
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
Definition PublicKey.cc:445
bool hasSubkeys() const
Whether subkeys is not empty.
Definition PublicKey.cc:460
PublicKeyData()
Default constructed: empty data.
Definition PublicKey.cc:395
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:427
std::string algoName() const
Key algorithm string like RSA 2048.
Definition PublicKey.cc:421
static bool isSafeKeyId(const std::string &id_r)
Whether this is a long id (64bit/16byte) or even better a fingerprint.
Definition PublicKey.h:301
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:322
bool providesKey(const std::string &id_r) const
Whether id_r is the id or fingerprint of the primary key or of a subkey.
Definition PublicKey.cc:469
std::string id() const
Key ID.
Definition PublicKey.cc:412
std::string fingerprint() const
Key fingerprint.
Definition PublicKey.cc:418
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created).
Definition PublicKey.cc:442
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id).
Definition PublicKey.cc:439
static PublicKeyData fromGpgmeKey(_gpgme_key *data)
Definition PublicKey.cc:406
std::string expiresAsString() const
Definition PublicKey.cc:436
AsciiArt asciiArt() const
Random art fingerprint visualization (base::DrunkenBishop).
Definition PublicKey.cc:480
std::string asString() const
Simple string representation.
Definition PublicKey.cc:448
base::DrunkenBishop AsciiArt
Random art fingerprint visualization type (base::DrunkenBishop).
Definition PublicKey.h:310
Class representing a signature on a GPG Public Key.
Definition PublicKey.h:137
Date created() const
Creation date.
Definition PublicKey.cc:263
std::string asString() const
Simple string representation.
Definition PublicKey.cc:275
PublicKeySignatureData()
Default constructed: empty data.
Definition PublicKey.cc:238
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:180
int daysToLive() const
Number of days (24h) until the key expires (or since it expired).
Definition PublicKey.cc:272
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:269
std::string id() const
The key ID of key used to create the signature.
Definition PublicKey.cc:257
std::string name() const
The user ID associated with this key, if present.
Definition PublicKey.cc:260
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:266
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition PublicKey.h:358
Pathname path() const
File containing the ASCII armored key.
Definition PublicKey.cc:640
std::string expiresAsString() const
Definition PublicKey.cc:681
bool fileProvidesKey(const std::string &id_r) const
Extends providesKey to look at the hidden keys too.
Definition PublicKey.cc:646
bool operator==(const PublicKey &rhs) const
Definition PublicKey.cc:696
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition PublicKey.h:463
Date created() const
Definition PublicKey.cc:669
PublicKey()
Default ctor.
Definition PublicKey.cc:611
bool expired() const
Definition PublicKey.cc:675
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob contains multiple keys.
Definition PublicKey.cc:643
static bool isSafeKeyId(const std::string &id_r)
!<
Definition PublicKey.h:425
std::string rpmName() const
Definition PublicKey.cc:693
std::string name() const
Definition PublicKey.cc:660
Date expires() const
Definition PublicKey.cc:672
const PublicKeyData & keyData() const
The public keys data (.
Definition PublicKey.cc:637
std::string gpgPubkeyRelease() const
Definition PublicKey.cc:687
std::string asString() const
Definition PublicKey.cc:690
std::string fingerprint() const
Definition PublicKey.cc:663
std::string id() const
Definition PublicKey.cc:657
std::string algoName() const
Definition PublicKey.cc:666
int daysToLive() const
Definition PublicKey.cc:678
std::string gpgPubkeyVersion() const
Definition PublicKey.cc:684
static PublicKey noThrow(const Pathname &keyFile_r)
Static ctor returning an empty PublicKey rather than throwing.
Definition PublicKey.cc:634
bool providesKey(const std::string &id_r) const
!<
Definition PublicKey.h:422
Class representing a GPG Public Keys subkeys.
Definition PublicKey.h:80
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:120
std::string id() const
Subkey ID.
Definition PublicKey.cc:181
PublicSubkeyData()
Default constructed: empty data.
Definition PublicKey.cc:163
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition PublicKey.cc:193
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:187
friend class PublicKeyData
Definition PublicKey.h:121
std::string asString() const
Simple string representation.
Definition PublicKey.cc:196
Date created() const
Creation date.
Definition PublicKey.cc:184
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:190
Wrapper class for stat/lstat.
Definition PathInfo.h:226
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:251
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:286
const std::string & asString() const
String representation.
Definition Pathname.h:94
Provide a new empty temporary file and delete it when no longer needed.
Definition TmpPath.h:118
Definition ansi.h:855
String related utilities and Regular expression matching.
Types and functions for filesystem operations.
Definition Glob.cc:24
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition PathInfo.cc:1070
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition PathInfo.cc:902
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition String.h:140
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition String.cc:180
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
std::string hexstring(char n, int w=4)
Definition String.h:325
bool endsWithCI(const C_Str &str_r, const C_Str &prefix_r)
Definition String.h:1165
Easy-to use interface to the ZYPP dependency resolver.
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
PublicKeyData implementation.
Definition PublicKey.cc:296
static shared_ptr< Impl > fromGpgmeKey(gpgme_key_t rawData)
Definition PublicKey.cc:339
std::vector< PublicSubkeyData > _subkeys
Definition PublicKey.cc:304
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:333
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:386
bool hasSubkeyId(const std::string &id_r) const
Definition PublicKey.cc:321
friend Impl * rwcowClone(const Impl *rhs)
std::vector< PublicKeySignatureData > _signatures
Definition PublicKey.cc:305
PublicKeySignatureData implementation.
Definition PublicKey.cc:207
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:223
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:229
friend Impl * rwcowClone(const Impl *rhs)
PublicKey implementation.
Definition PublicKey.cc:507
Impl(const Pathname &keyFile_r)
Definition PublicKey.cc:511
Pathname path() const
Definition PublicKey.cc:551
const PublicKeyData & keyData() const
Definition PublicKey.cc:548
friend Impl * rwcowClone(const Impl *rhs)
std::list< PublicKeyData > _hiddenKeys
Definition PublicKey.cc:590
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:594
Impl(const PublicKeyData &keyData_r)
Definition PublicKey.cc:543
Impl(const filesystem::TmpFile &sharedFile_r)
Definition PublicKey.cc:526
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition PublicKey.cc:531
shared_ptr< filesystem::TmpFile > _dontUseThisPtrDirectly
Definition PublicKey.cc:588
PublicKeyData _keyData
Definition PublicKey.cc:589
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:603
const std::list< PublicKeyData > & hiddenKeys() const
Definition PublicKey.cc:554
PublicSubkeyData implementation.
Definition PublicKey.cc:133
friend Impl * rwcowClone(const Impl *rhs)
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:148
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:154
Convenient building of std::string with boost::format.
Definition String.h:254
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213