libzypp 17.35.9
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 <zypp/base/Gettext.h>
19#include <zypp/base/String.h>
20#include <zypp/base/Regex.h>
21#include <zypp/PublicKey.h>
23#include <zypp/TmpPath.h>
24#include <zypp/PathInfo.h>
25#include <zypp/base/Exception.h>
26#include <zypp/base/LogTools.h>
27#include <zypp/Date.h>
28#include <zypp/KeyManager.h>
29#include <zypp/ZYppFactory.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
148 shared_ptr<zypp::PublicSubkeyData::Impl> PublicSubkeyData::Impl::nullimpl()
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
186
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
223 shared_ptr<zypp::PublicKeySignatureData::Impl> PublicKeySignatureData::Impl::nullimpl()
224 {
225 static shared_ptr<Impl> _nullimpl( new Impl );
226 return _nullimpl;
227 }
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
265
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
291 { return getZYpp()->keyRing()->isKeyTrusted(id()); }
292
294 { return getZYpp()->keyRing()->isKeyKnown(id()); }
295
302 {
303 std::string _id;
304 std::string _name;
305 std::string _fingerprint;
306 std::string _algoName;
309
310 std::vector<PublicSubkeyData> _subkeys;
311 std::vector<PublicKeySignatureData> _signatures;
312
313 public:
314 bool hasSubkeyId( const std::string & id_r ) const;
315
316 public:
318 static shared_ptr<Impl> nullimpl();
319 static shared_ptr<Impl> fromGpgmeKey(gpgme_key_t rawData);
320
321 private:
322 friend Impl * rwcowClone<Impl>( const Impl * rhs );
324 Impl * clone() const;
325 };
326
327 bool PublicKeyData::Impl::hasSubkeyId( const std::string &id_r) const
328 {
329 bool ret = false;
330 for ( const PublicSubkeyData & sub : _subkeys ) {
331 if ( shorterIsSuffixCI( sub.id(), id_r ) ) {
332 ret = true;
333 break;
334 }
335 }
336 return ret;
337 }
338
339 shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::nullimpl()
340 {
341 static shared_ptr<Impl> _nullimpl( new Impl );
342 return _nullimpl;
343 }
344
345 shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::fromGpgmeKey(gpgme_key_t rawData)
346 {
347 //gpgme stores almost nothing in the top level key
348 //the information we look for is stored in the subkey, where subkey[0]
349 //is always the primary key
350 gpgme_subkey_t sKey = rawData->subkeys;
351 if (sKey) {
352 shared_ptr<PublicKeyData::Impl> data(new Impl);
353 //libzypp expects the date of the latest signature on the first uid
354 if ( rawData->uids && rawData->uids->signatures ) {
355 data->_created = zypp::Date(rawData->uids->signatures->timestamp);
356 // bsc#1179222: The keyring does not order the signatures when multiple
357 // versions of the same key are imported. We take the last signature here,
358 // the one GPGME_EXPORT_MODE_MINIMAL will later use in export.
359 for ( auto t = rawData->uids->signatures->next; t; t = t->next ) {
360 if (t->keyid != nullptr) {
361 data->_signatures.push_back(PublicKeySignatureData(t));
362 }
363
364 if ( t->timestamp > data->_created )
365 data->_created = t->timestamp;
366 }
367 }
368 else
369 data->_created = zypp::Date(sKey->timestamp);
370
371 data->_expires = zypp::Date(sKey->expires);
372 data->_fingerprint = str::asString(sKey->fpr);
373 data->_algoName = keyAlgoName( sKey );
374 data->_id = str::asString(sKey->keyid);
375
376 //get the primary user ID
377 if (rawData->uids) {
378 data->_name = str::asString(rawData->uids->uid);
379 }
380
381 //the rest of the keys
382 sKey = sKey->next;
383 while (sKey) {
384 data->_subkeys.push_back( PublicSubkeyData(sKey) );
385 sKey = sKey->next;
386 }
387 return data;
388 }
389 return nullimpl();
390 }
391
393 {
394 return new Impl( *this );
395 }
396
400
402 : _pimpl( Impl::nullimpl() )
403 {}
404
405 PublicKeyData::PublicKeyData(shared_ptr<Impl> data)
406 : _pimpl( std::move(data) )
407 {}
408
411
414
415 PublicKeyData::operator bool() const
416 { return !_pimpl->_fingerprint.empty(); }
417
418 std::string PublicKeyData::id() const
419 { return _pimpl->_id; }
420
421 std::string PublicKeyData::name() const
422 { return _pimpl->_name; }
423
424 std::string PublicKeyData::fingerprint() const
425 { return _pimpl->_fingerprint; }
426
427 std::string PublicKeyData::algoName() const
428 { return _pimpl->_algoName; }
429
431 { return _pimpl->_created; }
432
434 { return _pimpl->_expires; }
435
437 { return isExpired( _pimpl->_expires ); }
438
440 { return hasDaysToLive( _pimpl->_expires ); }
441
443 { return expiresDetailVerbose( _pimpl->_expires ); }
444
446 { return _pimpl->_id.empty() ? _pimpl->_id : str::toLower( _pimpl->_id.substr(8,8) ); }
447
449 { return _pimpl->_created ? str::hexstring( _pimpl->_created ).substr(2) : std::string(); }
450
451 std::string PublicKeyData::rpmName() const
452 { return str::Format( "gpg-pubkey-%1%-%2%" ) % gpgPubkeyVersion() % gpgPubkeyRelease(); }
453
454 std::string PublicKeyData::asString() const
455 {
456 if ( not *this )
457 return "[NO_KEY]";
458
460 str << "[" << _pimpl->_id << "-" << gpgPubkeyRelease();
461 for ( auto && sub : _pimpl->_subkeys )
462 str << ", " << sub.id();
463 return str << "] [" << _pimpl->_name.c_str() << "] [" << expiresDetail( _pimpl->_expires ) << "]";
464 }
465
467 { return !_pimpl->_subkeys.empty(); }
468
470 { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
471
473 { return makeIterable( &(*_pimpl->_signatures.begin()), &(*_pimpl->_signatures.end()) ); }
474
475 bool PublicKeyData::providesKey( const std::string & id_r ) const
476 {
477 if ( not isSafeKeyId( id_r ) )
478 return( id_r.size() == 8 && str::endsWithCI( _pimpl->_id, id_r ) );
479
480 if ( str::endsWithCI( _pimpl->_fingerprint, id_r ) )
481 return true;
482
483 return _pimpl->hasSubkeyId( id_r );
484 }
485
488
489 std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj )
490 {
491 str << "[" << obj.name() << "]" << endl;
492 str << " fpr " << obj.fingerprint() << endl;
493 str << " id " << obj.id() << endl;
494 str << " alg " << obj.algoName() << endl;
495 str << " cre " << Date::ValueType(obj.created()) << ' ' << obj.created() << endl;
496 str << " exp " << Date::ValueType(obj.expires()) << ' ' << obj.expiresAsString() << endl;
497 str << " ttl " << obj.daysToLive() << endl;
498 for ( auto && sub : obj._pimpl->_subkeys )
499 str << " sub " << sub << endl;
500 str << " rpm " << obj.gpgPubkeyVersion() << "-" << obj.gpgPubkeyRelease() << endl;
501 return str;
502 }
503
504 bool operator==( const PublicKeyData & lhs, const PublicKeyData & rhs )
505 { return ( lhs.fingerprint() == rhs.fingerprint() && lhs.created() == rhs.created() ); }
506
507
513 {
515 {}
516
517 Impl( const Pathname & keyFile_r )
518 : _dontUseThisPtrDirectly( new filesystem::TmpFile )
519 {
520 PathInfo info( keyFile_r );
521 MIL << "Taking pubkey from " << keyFile_r << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyFile_r, "sha1") << endl;
522
523 if ( !info.isExist() )
524 ZYPP_THROW(Exception("Can't read public key from " + keyFile_r.asString() + ", file not found"));
525
526 if ( filesystem::hardlinkCopy( keyFile_r, path() ) != 0 )
527 ZYPP_THROW(Exception("Can't copy public key data from " + keyFile_r.asString() + " to " + path().asString() ));
528
529 readFromFile();
530 }
531
532 Impl( const filesystem::TmpFile & sharedFile_r )
533 : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
534 { readFromFile(); }
535
536 // private from keyring
537 Impl( const filesystem::TmpFile & sharedFile_r, const PublicKeyData & keyData_r )
538 : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
539 , _keyData( keyData_r )
540 {
541 if ( ! keyData_r )
542 {
543 WAR << "Invalid PublicKeyData supplied: scanning from file" << endl;
544 readFromFile();
545 }
546 }
547
548 // private from keyring
549 Impl( const PublicKeyData & keyData_r )
550 : _keyData( keyData_r )
551 {}
552
553 public:
554 const PublicKeyData & keyData() const
555 { return _keyData; }
556
558 { return( /*the one and only intended use*/_dontUseThisPtrDirectly ? _dontUseThisPtrDirectly->path() : Pathname() ); }
559
560 const std::list<PublicKeyData> & hiddenKeys() const
561 { return _hiddenKeys; }
562
563 protected:
565 {
566 PathInfo info( path() );
567 MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl;
568
569 std::list<PublicKeyData> keys = KeyManagerCtx::createForOpenPGP().readKeyFromFile( path() );
570 switch ( keys.size() )
571 {
572 case 0:
573 ZYPP_THROW( BadKeyException( "File " + path().asString() + " doesn't contain public key data" , path() ) );
574 break;
575
576 case 1:
577 // ok.
578 _keyData = keys.back();
579 _hiddenKeys.clear();
580 break;
581
582 default:
583 WAR << "File " << path().asString() << " contains multiple keys: " << keys << endl;
584 _keyData = keys.back();
585 keys.pop_back();
586 _hiddenKeys.swap( keys );
587 break;
588 }
589
590 MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl;
591 }
592
593 private:
594 shared_ptr<filesystem::TmpFile> _dontUseThisPtrDirectly; // shared_ptr ok because TmpFile itself is a refernce type (no COW)
596 std::list<PublicKeyData> _hiddenKeys;
597
598 public:
600 static shared_ptr<Impl> nullimpl()
601 {
602 static shared_ptr<Impl> _nullimpl( new Impl );
603 return _nullimpl;
604 }
605
606 private:
607 friend Impl * rwcowClone<Impl>( const Impl * rhs );
609 Impl * clone() const
610 { return new Impl( *this ); }
611 };
613
615 // class PublicKey
618 : _pimpl( Impl::nullimpl() )
619 {}
620
622 : _pimpl( new Impl( file ) )
623 {}
624
626 : _pimpl( new Impl( sharedfile ) )
627 {}
628
629 PublicKey::PublicKey( const filesystem::TmpFile & sharedfile, const PublicKeyData & keyData_r )
630 : _pimpl( new Impl( sharedfile, keyData_r ) )
631 {}
632
634 : _pimpl( new Impl( keyData_r ) )
635 {}
636
639
641 try { return PublicKey( keyFile_r ); } catch(...) { return PublicKey(); }
642
644 { return _pimpl->keyData(); }
645
647 { return _pimpl->path(); }
648
649 const std::list<PublicKeyData> & PublicKey::hiddenKeys() const
650 { return _pimpl->hiddenKeys(); }
651
652 bool PublicKey::fileProvidesKey( const std::string & id_r ) const
653 {
654 if ( providesKey( id_r ) )
655 return true;
656 for ( const auto & keydata : hiddenKeys() ) {
657 if ( keydata.providesKey( id_r ) )
658 return true;
659 }
660 return false;
661 }
662
663 std::string PublicKey::id() const
664 { return keyData().id(); }
665
666 std::string PublicKey::name() const
667 { return keyData().name(); }
668
669 std::string PublicKey::fingerprint() const
670 { return keyData().fingerprint(); }
671
672 std::string PublicKey::algoName() const
673 { return keyData().algoName(); }
674
676 { return keyData().created(); }
677
679 { return keyData().expires(); }
680
682 { return keyData().expired(); }
683
685 { return keyData().daysToLive(); }
686
687 std::string PublicKey::expiresAsString() const
688 { return keyData().expiresAsString(); }
689
690 std::string PublicKey::gpgPubkeyVersion() const
691 { return keyData().gpgPubkeyVersion(); }
692
693 std::string PublicKey::gpgPubkeyRelease() const
694 { return keyData().gpgPubkeyRelease(); }
695
696 std::string PublicKey::asString() const
697 { return keyData().asString(); }
698
699 std::string PublicKey::rpmName() const
700 { return keyData().rpmName(); }
701
702 bool PublicKey::operator==( const PublicKey & rhs ) const
703 { return rhs.keyData() == keyData(); }
704
705 bool PublicKey::operator==( const std::string & sid ) const
706 { return ( isSafeKeyId( sid ) || sid.size() == 8 ) && str::endsWithCI( fingerprint(), sid ); }
707
708 std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
709 { return dumpOn( str, obj.keyData() ); }
710
711
712
713
715} // namespace zypp
Exception thrown when the supplied key is not a valid gpg key.
Definition PublicKey.h:50
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:147
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:208
Iterable< KeySignatureIterator > signatures() const
Iterate all key signatures.
Definition PublicKey.cc:472
Date created() const
Creation / last modification date (latest selfsig).
Definition PublicKey.cc:430
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:436
std::string name() const
Key name.
Definition PublicKey.cc:421
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition PublicKey.cc:469
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition PublicKey.cc:439
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
Definition PublicKey.cc:451
bool hasSubkeys() const
Whether subkeys is not empty.
Definition PublicKey.cc:466
PublicKeyData()
Default constructed: empty data.
Definition PublicKey.cc:401
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:433
std::string algoName() const
Key algorithm string like RSA 2048
Definition PublicKey.cc:427
static bool isSafeKeyId(const std::string &id_r)
Whether this is a long id (64bit/16byte) or even better a fingerprint.
Definition PublicKey.h:308
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:329
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:475
std::string id() const
Key ID.
Definition PublicKey.cc:418
std::string fingerprint() const
Key fingerprint.
Definition PublicKey.cc:424
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created)
Definition PublicKey.cc:448
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id)
Definition PublicKey.cc:445
static PublicKeyData fromGpgmeKey(_gpgme_key *data)
Definition PublicKey.cc:412
std::string expiresAsString() const
Definition PublicKey.cc:442
AsciiArt asciiArt() const
Random art fingerprint visualization (base::DrunkenBishop).
Definition PublicKey.cc:486
std::string asString() const
Simple string representation.
Definition PublicKey.cc:454
base::DrunkenBishop AsciiArt
Random art fingerprint visualization type (base::DrunkenBishop).
Definition PublicKey.h:317
Class representing a signature on a GPG Public Key.
Definition PublicKey.h:138
Date created() const
Creation date.
Definition PublicKey.cc:263
std::string asString() const
Simple string representation.
Definition PublicKey.cc:275
bool inKnownRing() const
Whether the key has been seen before.
Definition PublicKey.cc:293
PublicKeySignatureData()
Default constructed: empty data.
Definition PublicKey.cc:238
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:187
bool inTrustedRing() const
Whether the signature is trusted in rpmdb.
Definition PublicKey.cc:290
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:365
Pathname path() const
File containing the ASCII armored key.
Definition PublicKey.cc:646
std::string expiresAsString() const
Definition PublicKey.cc:687
bool fileProvidesKey(const std::string &id_r) const
Extends providesKey to look at the hidden keys too.
Definition PublicKey.cc:652
bool operator==(const PublicKey &rhs) const
Definition PublicKey.cc:702
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition PublicKey.h:470
Date created() const
Definition PublicKey.cc:675
PublicKey()
Default ctor.
Definition PublicKey.cc:617
bool expired() const
Definition PublicKey.cc:681
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob contains multiple keys.
Definition PublicKey.cc:649
static bool isSafeKeyId(const std::string &id_r)
!<
Definition PublicKey.h:432
std::string rpmName() const
Definition PublicKey.cc:699
std::string name() const
Definition PublicKey.cc:666
Date expires() const
Definition PublicKey.cc:678
const PublicKeyData & keyData() const
The public keys data (.
Definition PublicKey.cc:643
std::string gpgPubkeyRelease() const
Definition PublicKey.cc:693
std::string asString() const
Definition PublicKey.cc:696
std::string fingerprint() const
Definition PublicKey.cc:669
std::string id() const
Definition PublicKey.cc:663
std::string algoName() const
Definition PublicKey.cc:672
int daysToLive() const
Definition PublicKey.cc:684
std::string gpgPubkeyVersion() const
Definition PublicKey.cc:690
static PublicKey noThrow(const Pathname &keyFile_r)
Static ctor returning an empty PublicKey rather than throwing.
Definition PublicKey.cc:640
bool providesKey(const std::string &id_r) const
!<
Definition PublicKey.h:429
Class representing a GPG Public Keys subkeys.
Definition PublicKey.h:81
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:121
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
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
Random art fingerprint visualization Visualize fingerprint data on a [17x9] (SSH) or [19x11] (GPG) or...
Wrapper class for stat/lstat.
Definition PathInfo.h:222
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:247
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:282
const std::string & asString() const
String representation.
Definition Pathname.h:93
Provide a new empty temporary file and delete it when no longer needed.
Definition TmpPath.h:128
Definition Arch.h:364
String related utilities and Regular expression matching.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition PathInfo.cc:1056
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition PathInfo.cc:888
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition String.h:139
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition String.cc:178
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
std::string hexstring(char n, int w=4)
Definition String.h:324
bool endsWithCI(const C_Str &str_r, const C_Str &prefix_r)
Definition String.h:1094
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:302
static shared_ptr< Impl > fromGpgmeKey(gpgme_key_t rawData)
Definition PublicKey.cc:345
std::vector< PublicSubkeyData > _subkeys
Definition PublicKey.cc:310
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:339
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:392
bool hasSubkeyId(const std::string &id_r) const
Definition PublicKey.cc:327
friend Impl * rwcowClone(const Impl *rhs)
std::vector< PublicKeySignatureData > _signatures
Definition PublicKey.cc:311
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:513
Impl(const Pathname &keyFile_r)
Definition PublicKey.cc:517
Pathname path() const
Definition PublicKey.cc:557
const PublicKeyData & keyData() const
Definition PublicKey.cc:554
friend Impl * rwcowClone(const Impl *rhs)
std::list< PublicKeyData > _hiddenKeys
Definition PublicKey.cc:596
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:600
Impl(const PublicKeyData &keyData_r)
Definition PublicKey.cc:549
Impl(const filesystem::TmpFile &sharedFile_r)
Definition PublicKey.cc:532
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition PublicKey.cc:537
shared_ptr< filesystem::TmpFile > _dontUseThisPtrDirectly
Definition PublicKey.cc:594
PublicKeyData _keyData
Definition PublicKey.cc:595
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:609
const std::list< PublicKeyData > & hiddenKeys() const
Definition PublicKey.cc:560
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:253
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:212
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:424
#define PL_(MSG1, MSG2, N)
Definition Gettext.h:42
#define _(MSG)
Definition Gettext.h:39
#define MIL
Definition Logger.h:98
#define WAR
Definition Logger.h:99
Interface to gettext.