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