libzypp: zypp-common/PublicKey.cc Source File

libzypp 17.38.13

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
21#include <zypp-core/base/Gettext.h>
22#include <zypp-core/base/String.h>
23#include <zypp-core/base/Regex.h>
24#include <zypp-core/ExternalProgram.h>
25#include <zypp-core/fs/TmpPath.h>
26#include <zypp-core/fs/PathInfo.h>
27#include <zypp-core/base/Exception.h>
28#include <zypp-core/base/LogTools.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
132 struct PublicSubkeyData::Impl
133 {
134 std::string _id;
135 Date _created;
136 Date _expires;
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
154 zypp::PublicSubkeyData::Impl *PublicSubkeyData::Impl::clone() const
155 {
156 return new Impl( *this );
157 }
158
162
163 PublicSubkeyData::PublicSubkeyData()
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
175 PublicSubkeyData::~PublicSubkeyData()
176 {}
177
178 PublicSubkeyData::operator bool() const
179 { return !_pimpl->_id.empty(); }
180
181 std::string PublicSubkeyData::id() const
182 { return _pimpl->_id; }
183
184 Date PublicSubkeyData::created() const
185 { return _pimpl->_created; }
186
187 Date PublicSubkeyData::expires() const
188 { return _pimpl->_expires; }
189
190 bool PublicSubkeyData::expired() const
191 { return isExpired( _pimpl->_expires ); }
192
193 int PublicSubkeyData::daysToLive() const
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
206 struct PublicKeySignatureData::Impl
207 {
208 std::string _keyid;
209 std::string _name;
210 Date _created;
211 Date _expires;
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
229 zypp::PublicKeySignatureData::Impl *PublicKeySignatureData::Impl::clone() const
230 {
231 return new Impl( *this );
232 }
233
237
238 PublicKeySignatureData::PublicKeySignatureData()
239 : _pimpl( Impl::nullimpl() )
240 {}
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
251 PublicKeySignatureData::~PublicKeySignatureData()
252 {}
253
254 PublicKeySignatureData::operator bool() const
255 { return !_pimpl->_keyid.empty(); }
256
257 std::string PublicKeySignatureData::id() const
258 { return _pimpl->_keyid; }
259
260 std::string PublicKeySignatureData::name() const
261 { return _pimpl->_name; }
262
263 Date PublicKeySignatureData::created() const
264 { return _pimpl->_created; }
265
266 Date PublicKeySignatureData::expires() const
267 { return _pimpl->_expires; }
268
269 bool PublicKeySignatureData::expired() const
270 { return isExpired( _pimpl->_expires ); }
271
272 int PublicKeySignatureData::daysToLive() const
273 { return hasDaysToLive( _pimpl->_expires ); }
274
275 std::string PublicKeySignatureData::asString() const
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
295 struct PublicKeyData::Impl
296 {
297 std::string _id;
298 std::string _name;
299 std::string _fingerprint;
300 std::string _algoName;
301 Date _created;
302 Date _expires;
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
333 shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::nullimpl()
334 {
335 static shared_ptr<Impl> _nullimpl( new Impl );
336 return _nullimpl;
337 }
338
339 shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::fromGpgmeKey(gpgme_key_t rawData)
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) {
346 shared_ptr<PublicKeyData::Impl> data(new Impl);
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
386 zypp::PublicKeyData::Impl *PublicKeyData::Impl::clone() const
387 {
388 return new Impl( *this );
389 }
390
394
395 PublicKeyData::PublicKeyData()
396 : _pimpl( Impl::nullimpl() )
397 {}
398
399 PublicKeyData::PublicKeyData(shared_ptr<Impl> data)
400 : _pimpl( std::move(data) )
401 {}
402
403 PublicKeyData::~PublicKeyData()
404 {}
405
406 PublicKeyData PublicKeyData::fromGpgmeKey(_gpgme_key *data)
407 { return PublicKeyData(Impl::fromGpgmeKey(data)); }
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
424 Date PublicKeyData::created() const
425 { return _pimpl->_created; }
426
427 Date PublicKeyData::expires() const
428 { return _pimpl->_expires; }
429
430 bool PublicKeyData::expired() const
431 { return isExpired( _pimpl->_expires ); }
432
433 int PublicKeyData::daysToLive() const
434 { return hasDaysToLive( _pimpl->_expires ); }
435
436 std::string PublicKeyData::expiresAsString() const
437 { return expiresDetailVerbose( _pimpl->_expires ); }
438
439 std::string PublicKeyData::gpgPubkeyVersion() const
440 { return _pimpl->_id.empty() ? _pimpl->_id : str::toLower( _pimpl->_id.substr(8,8) ); }
441
442 std::string PublicKeyData::gpgPubkeyRelease() const
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
453 str::Str str;
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
460 bool PublicKeyData::hasSubkeys() const
461 { return !_pimpl->_subkeys.empty(); }
462
463 Iterable<PublicKeyData::SubkeyIterator> PublicKeyData::subkeys() const
464 { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
465
466 Iterable<PublicKeyData::KeySignatureIterator> PublicKeyData::signatures() const
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
480 PublicKeyData::AsciiArt PublicKeyData::asciiArt() const
481 { return AsciiArt( fingerprint(), algoName() ); }
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
506 struct PublicKey::Impl
507 {
508 Impl()
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
551 Pathname path() const
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:
558 void readFromFile()
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)
589 PublicKeyData _keyData;
590 std::list<PublicKeyData> _hiddenKeys;
591
592 public:
594 static shared_ptr<Impl> nullimpl()
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
611 PublicKey::PublicKey()
612 : _pimpl( Impl::nullimpl() )
613 {}
614
615 PublicKey::PublicKey( const Pathname & file )
616 : _pimpl( new Impl( file ) )
617 {}
618
619 PublicKey::PublicKey( const filesystem::TmpFile & sharedfile )
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
627 PublicKey::PublicKey( const PublicKeyData & keyData_r )
628 : _pimpl( new Impl( keyData_r ) )
629 {}
630
631 PublicKey::~PublicKey()
632 {}
633
634 PublicKey PublicKey::noThrow( const Pathname & keyFile_r )
635 try { return PublicKey( keyFile_r ); } catch(...) { return PublicKey(); }
636
637 const PublicKeyData & PublicKey::keyData() const
638 { return _pimpl->keyData(); }
639
640 Pathname PublicKey::path() const
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
669 Date PublicKey::created() const
670 { return keyData().created(); }
671
672 Date PublicKey::expires() const
673 { return keyData().expires(); }
674
675 bool PublicKey::expired() const
676 { return keyData().expired(); }
677
678 int PublicKey::daysToLive() const
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
Date.h
Exception.h
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
ExternalProgram.h
Gettext.h
PL_
#define PL_(MSG1, MSG2, N)
Definition Gettext.h:42
_
#define _(MSG)
Definition Gettext.h:39
KeyManager.h
LogTools.h
MIL
#define MIL
Definition Logger.h:103
WAR
#define WAR
Definition Logger.h:104
PublicKey.h
Regex.h
String.h
bool
shared_ptr
zypp::BadKeyException
Exception thrown when the supplied key is not a valid gpg key.
Definition PublicKey.h:49
zypp::Date
Store and operate on date (time_t).
Definition Date.h:33
zypp::Date::day
static const ValueType day
Definition Date.h:44
zypp::Date::ValueType
time_t ValueType
Definition Date.h:38
zypp::Date::now
static Date now()
Return the current time.
Definition Date.h:78
zypp::Date::printDate
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
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::Iterable
Definition Iterable.h:37
zypp::KeyManagerCtx::createForOpenPGP
static KeyManagerCtx createForOpenPGP()
Creates a new KeyManagerCtx for PGP using a volatile temp.
Definition KeyManager.cc:324
zypp::KeyManagerCtx::readKeyFromFile
std::list< PublicKeyData > readKeyFromFile(const Pathname &file)
Returns a list of all PublicKeyData found in file.
Definition KeyManager.cc:409
zypp::PublicKeyData
Class representing one GPG Public Keys data.
Definition PublicKey.h:201
zypp::PublicKeyData::signatures
Iterable< KeySignatureIterator > signatures() const
Iterate all key signatures.
Definition PublicKey.cc:466
zypp::PublicKeyData::created
Date created() const
Creation / last modification date (latest selfsig).
Definition PublicKey.cc:424
zypp::PublicKeyData::expired
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:430
zypp::PublicKeyData::name
std::string name() const
Key name.
Definition PublicKey.cc:415
zypp::PublicKeyData::subkeys
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition PublicKey.cc:463
zypp::PublicKeyData::daysToLive
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition PublicKey.cc:433
zypp::PublicKeyData::rpmName
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
Definition PublicKey.cc:445
zypp::PublicKeyData::hasSubkeys
bool hasSubkeys() const
Whether subkeys is not empty.
Definition PublicKey.cc:460
zypp::PublicKeyData::PublicKeyData
PublicKeyData()
Default constructed: empty data.
Definition PublicKey.cc:395
zypp::PublicKeyData::expires
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:427
zypp::PublicKeyData::algoName
std::string algoName() const
Key algorithm string like RSA 2048.
Definition PublicKey.cc:421
zypp::PublicKeyData::isSafeKeyId
static bool isSafeKeyId(const std::string &id_r)
Whether this is a long id (64bit/16byte) or even better a fingerprint.
Definition PublicKey.h:318
zypp::PublicKeyData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:339
zypp::PublicKeyData::providesKey
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
zypp::PublicKeyData::id
std::string id() const
Key ID.
Definition PublicKey.cc:412
zypp::PublicKeyData::fingerprint
std::string fingerprint() const
Key fingerprint.
Definition PublicKey.cc:418
zypp::PublicKeyData::gpgPubkeyRelease
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created).
Definition PublicKey.cc:442
zypp::PublicKeyData::gpgPubkeyVersion
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id).
Definition PublicKey.cc:439
zypp::PublicKeyData::fromGpgmeKey
static PublicKeyData fromGpgmeKey(_gpgme_key *data)
Definition PublicKey.cc:406
zypp::PublicKeyData::expiresAsString
std::string expiresAsString() const
Definition PublicKey.cc:436
zypp::PublicKeyData::asciiArt
AsciiArt asciiArt() const
Random art fingerprint visualization (base::DrunkenBishop).
Definition PublicKey.cc:480
zypp::PublicKeyData::asString
std::string asString() const
Simple string representation.
Definition PublicKey.cc:448
zypp::PublicKeyData::~PublicKeyData
~PublicKeyData()
Definition PublicKey.cc:403
zypp::PublicKeyData::AsciiArt
base::DrunkenBishop AsciiArt
Random art fingerprint visualization type (base::DrunkenBishop).
Definition PublicKey.h:327
zypp::PublicKeySignatureData
Class representing a signature on a GPG Public Key.
Definition PublicKey.h:137
zypp::PublicKeySignatureData::created
Date created() const
Creation date.
Definition PublicKey.cc:263
zypp::PublicKeySignatureData::~PublicKeySignatureData
~PublicKeySignatureData()
Definition PublicKey.cc:251
zypp::PublicKeySignatureData::asString
std::string asString() const
Simple string representation.
Definition PublicKey.cc:275
zypp::PublicKeySignatureData::PublicKeySignatureData
PublicKeySignatureData()
Default constructed: empty data.
Definition PublicKey.cc:238
zypp::PublicKeySignatureData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:180
zypp::PublicKeySignatureData::daysToLive
int daysToLive() const
Number of days (24h) until the key expires (or since it expired).
Definition PublicKey.cc:272
zypp::PublicKeySignatureData::expired
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:269
zypp::PublicKeySignatureData::id
std::string id() const
The key ID of key used to create the signature.
Definition PublicKey.cc:257
zypp::PublicKeySignatureData::name
std::string name() const
The user ID associated with this key, if present.
Definition PublicKey.cc:260
zypp::PublicKeySignatureData::expires
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:266
zypp::PublicKey
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition PublicKey.h:375
zypp::PublicKey::path
Pathname path() const
File containing the ASCII armored key.
Definition PublicKey.cc:640
zypp::PublicKey::expiresAsString
std::string expiresAsString() const
Definition PublicKey.cc:681
zypp::PublicKey::fileProvidesKey
bool fileProvidesKey(const std::string &id_r) const
Extends providesKey to look at the hidden keys too.
Definition PublicKey.cc:646
zypp::PublicKey::operator==
bool operator==(const PublicKey &rhs) const
Definition PublicKey.cc:696
zypp::PublicKey::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition PublicKey.h:483
zypp::PublicKey::created
Date created() const
Definition PublicKey.cc:669
zypp::PublicKey::PublicKey
PublicKey()
Default ctor.
Definition PublicKey.cc:611
zypp::PublicKey::expired
bool expired() const
Definition PublicKey.cc:675
zypp::PublicKey::hiddenKeys
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob contains multiple keys.
Definition PublicKey.cc:643
zypp::PublicKey::isSafeKeyId
static bool isSafeKeyId(const std::string &id_r)
!<
Definition PublicKey.h:442
zypp::PublicKey::rpmName
std::string rpmName() const
Definition PublicKey.cc:693
zypp::PublicKey::name
std::string name() const
Definition PublicKey.cc:660
zypp::PublicKey::expires
Date expires() const
Definition PublicKey.cc:672
zypp::PublicKey::keyData
const PublicKeyData & keyData() const
The public keys data (.
Definition PublicKey.cc:637
zypp::PublicKey::gpgPubkeyRelease
std::string gpgPubkeyRelease() const
Definition PublicKey.cc:687
zypp::PublicKey::asString
std::string asString() const
Definition PublicKey.cc:690
zypp::PublicKey::fingerprint
std::string fingerprint() const
Definition PublicKey.cc:663
zypp::PublicKey::id
std::string id() const
Definition PublicKey.cc:657
zypp::PublicKey::algoName
std::string algoName() const
Definition PublicKey.cc:666
zypp::PublicKey::daysToLive
int daysToLive() const
Definition PublicKey.cc:678
zypp::PublicKey::gpgPubkeyVersion
std::string gpgPubkeyVersion() const
Definition PublicKey.cc:684
zypp::PublicKey::~PublicKey
~PublicKey()
Definition PublicKey.cc:631
zypp::PublicKey::noThrow
static PublicKey noThrow(const Pathname &keyFile_r)
Static ctor returning an empty PublicKey rather than throwing.
Definition PublicKey.cc:634
zypp::PublicKey::providesKey
bool providesKey(const std::string &id_r) const
!<
Definition PublicKey.h:439
zypp::PublicSubkeyData
Class representing a GPG Public Keys subkeys.
Definition PublicKey.h:80
zypp::PublicSubkeyData::~PublicSubkeyData
~PublicSubkeyData()
Definition PublicKey.cc:175
zypp::PublicSubkeyData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition PublicKey.h:120
zypp::PublicSubkeyData::id
std::string id() const
Subkey ID.
Definition PublicKey.cc:181
zypp::PublicSubkeyData::PublicSubkeyData
PublicSubkeyData()
Default constructed: empty data.
Definition PublicKey.cc:163
zypp::PublicSubkeyData::daysToLive
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition PublicKey.cc:193
zypp::PublicSubkeyData::expires
Date expires() const
Expiry date, or Date() if the key never expires.
Definition PublicKey.cc:187
zypp::PublicSubkeyData::PublicKeyData
friend class PublicKeyData
Definition PublicKey.h:121
zypp::PublicSubkeyData::asString
std::string asString() const
Simple string representation.
Definition PublicKey.cc:196
zypp::PublicSubkeyData::created
Date created() const
Creation date.
Definition PublicKey.cc:184
zypp::PublicSubkeyData::expired
bool expired() const
Whether the key has expired.
Definition PublicKey.cc:190
zypp::filesystem::PathInfo
Wrapper class for stat/lstat.
Definition PathInfo.h:226
zypp::filesystem::PathInfo::path
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:251
zypp::filesystem::PathInfo::size
off_t size() const
Definition PathInfo.h:376
zypp::filesystem::PathInfo::isExist
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:286
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::filesystem::Pathname::asString
const std::string & asString() const
String representation.
Definition Pathname.h:94
zypp::filesystem::TmpFile
Provide a new empty temporary file and delete it when no longer needed.
Definition TmpPath.h:118
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp::filesystem
Types and functions for filesystem operations.
Definition Glob.cc:24
zypp::filesystem::checksum
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition PathInfo.cc:1070
zypp::filesystem::hardlinkCopy
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition PathInfo.cc:902
zypp::str::asString
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition String.h:140
zypp::str::toLower
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition String.cc:180
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
zypp::str::hexstring
std::string hexstring(char n, int w=4)
Definition String.h:325
zypp::str::endsWithCI
bool endsWithCI(const C_Str &str_r, const C_Str &prefix_r)
Definition String.h:1165
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::makeIterable
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
relates: Iterable convenient construction.
Definition Iterable.h:88
zypp::operator==
bool operator==(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition Capability.h:309
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589
zypp::PublicKeyData::Impl
PublicKeyData implementation.
Definition PublicKey.cc:296
zypp::PublicKeyData::Impl::fromGpgmeKey
static shared_ptr< Impl > fromGpgmeKey(gpgme_key_t rawData)
Definition PublicKey.cc:339
zypp::PublicKeyData::Impl::_subkeys
std::vector< PublicSubkeyData > _subkeys
Definition PublicKey.cc:304
zypp::PublicKeyData::Impl::_fingerprint
std::string _fingerprint
Definition PublicKey.cc:299
zypp::PublicKeyData::Impl::_id
std::string _id
Definition PublicKey.cc:297
zypp::PublicKeyData::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:333
zypp::PublicKeyData::Impl::_expires
Date _expires
Definition PublicKey.cc:302
zypp::PublicKeyData::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:386
zypp::PublicKeyData::Impl::hasSubkeyId
bool hasSubkeyId(const std::string &id_r) const
Definition PublicKey.cc:321
zypp::PublicKeyData::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::PublicKeyData::Impl::_created
Date _created
Definition PublicKey.cc:301
zypp::PublicKeyData::Impl::_algoName
std::string _algoName
Definition PublicKey.cc:300
zypp::PublicKeyData::Impl::_signatures
std::vector< PublicKeySignatureData > _signatures
Definition PublicKey.cc:305
zypp::PublicKeyData::Impl::_name
std::string _name
Definition PublicKey.cc:298
zypp::PublicKeySignatureData::Impl
PublicKeySignatureData implementation.
Definition PublicKey.cc:207
zypp::PublicKeySignatureData::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:223
zypp::PublicKeySignatureData::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:229
zypp::PublicKeySignatureData::Impl::_name
std::string _name
Definition PublicKey.cc:209
zypp::PublicKeySignatureData::Impl::_expires
Date _expires
Definition PublicKey.cc:211
zypp::PublicKeySignatureData::Impl::_keyid
std::string _keyid
Definition PublicKey.cc:208
zypp::PublicKeySignatureData::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::PublicKeySignatureData::Impl::_created
Date _created
Definition PublicKey.cc:210
zypp::PublicKey::Impl
PublicKey implementation.
Definition PublicKey.cc:507
zypp::PublicKey::Impl::Impl
Impl(const Pathname &keyFile_r)
Definition PublicKey.cc:511
zypp::PublicKey::Impl::path
Pathname path() const
Definition PublicKey.cc:551
zypp::PublicKey::Impl::Impl
Impl()
Definition PublicKey.cc:508
zypp::PublicKey::Impl::readFromFile
void readFromFile()
Definition PublicKey.cc:558
zypp::PublicKey::Impl::keyData
const PublicKeyData & keyData() const
Definition PublicKey.cc:548
zypp::PublicKey::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::PublicKey::Impl::_hiddenKeys
std::list< PublicKeyData > _hiddenKeys
Definition PublicKey.cc:590
zypp::PublicKey::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:594
zypp::PublicKey::Impl::Impl
Impl(const PublicKeyData &keyData_r)
Definition PublicKey.cc:543
zypp::PublicKey::Impl::Impl
Impl(const filesystem::TmpFile &sharedFile_r)
Definition PublicKey.cc:526
zypp::PublicKey::Impl::Impl
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition PublicKey.cc:531
zypp::PublicKey::Impl::_dontUseThisPtrDirectly
shared_ptr< filesystem::TmpFile > _dontUseThisPtrDirectly
Definition PublicKey.cc:588
zypp::PublicKey::Impl::_keyData
PublicKeyData _keyData
Definition PublicKey.cc:589
zypp::PublicKey::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:603
zypp::PublicKey::Impl::hiddenKeys
const std::list< PublicKeyData > & hiddenKeys() const
Definition PublicKey.cc:554
zypp::PublicSubkeyData::Impl
PublicSubkeyData implementation.
Definition PublicKey.cc:133
zypp::PublicSubkeyData::Impl::_id
std::string _id
Definition PublicKey.cc:134
zypp::PublicSubkeyData::Impl::_created
Date _created
Definition PublicKey.cc:135
zypp::PublicSubkeyData::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::PublicSubkeyData::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition PublicKey.cc:148
zypp::PublicSubkeyData::Impl::_expires
Date _expires
Definition PublicKey.cc:136
zypp::PublicSubkeyData::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition PublicKey.cc:154
zypp::str::Format
Convenient building of std::string with boost::format.
Definition String.h:254
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213
PathInfo.h
TmpPath.h