libzypp  14.48.5
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/TmpPath.h"
28 
29 #include <ctime>
30 
32 #define GPG_BINARY "/usr/bin/gpg2"
33 
34 using std::endl;
35 
37 namespace zypp
38 {
40  namespace
41  {
42  inline bool isExpired( const Date & expires_r )
43  { return( expires_r && expires_r < Date::now() ); }
44 
45  inline int hasDaysToLive( const Date & expires_r )
46  {
47  if ( expires_r )
48  {
49  Date exp( expires_r - Date::now() );
50  int ret = exp / Date::day;
51  if ( exp < 0 ) ret -= 1;
52  return ret;
53  }
54  return INT_MAX;
55  }
56 
57  inline std::string expiresDetail( const Date & expires_r )
58  {
59  str::Str str;
60  if ( ! expires_r )
61  {
62  // translators: an annotation to a gpg keys expiry date
63  str << _("does not expire");
64  }
65  else if ( isExpired( expires_r ) )
66  {
67  // translators: an annotation to a gpg keys expiry date: "expired: 1999-04-12"
68  str << ( str::Format(_("expired: %1%") ) % expires_r.printDate() );
69  }
70  else
71  {
72  // translators: an annotation to a gpg keys expiry date: "expires: 2111-04-12"
73  str << ( str::Format(_("expires: %1%") ) % expires_r.printDate() );
74  }
75  return str;
76  }
77 
78  inline std::string expiresDetailVerbose( const Date & expires_r )
79  {
80  if ( !expires_r )
81  { // translators: an annotation to a gpg keys expiry date
82  return _("(does not expire)");
83  }
84  std::string ret( expires_r.asString() );
85  int ttl( hasDaysToLive( expires_r ) );
86  if ( ttl <= 90 )
87  {
88  ret += " ";
89  if ( ttl < 0 )
90  { // translators: an annotation to a gpg keys expiry date
91  ret += _("(EXPIRED)");
92  }
93  else if ( ttl == 0 )
94  { // translators: an annotation to a gpg keys expiry date
95  ret += _("(expires within 24h)");
96  }
97  else
98  { // translators: an annotation to a gpg keys expiry date
99  ret += str::form( _PL("(expires in %d day)", "(expires in %d days)", ttl ), ttl );
100  }
101  }
102  return ret;
103  }
104 
105  } //namespace
107 
113  {
114  std::string _id;
117 
118  public:
120  static shared_ptr<Impl> nullimpl()
121  {
122  static shared_ptr<Impl> _nullimpl( new Impl );
123  return _nullimpl;
124  }
125 
126  private:
127  friend Impl * rwcowClone<Impl>( const Impl * rhs );
129  Impl * clone() const
130  { return new Impl( *this ); }
131  };
132 
136 
138  : _pimpl( Impl::nullimpl() )
139  {}
140 
142  {}
143 
144  PublicSubkeyData::operator bool() const
145  { return !_pimpl->_id.empty(); }
146 
147  std::string PublicSubkeyData::id() const
148  { return _pimpl->_id; }
149 
151  { return _pimpl->_created; }
152 
154  { return _pimpl->_expires; }
155 
157  { return isExpired( _pimpl->_expires ); }
158 
160  { return hasDaysToLive( _pimpl->_expires ); }
161 
162  std::string PublicSubkeyData::asString() const
163  {
164  return str::Str() << id() << " " << created().printDate() << " [" << expiresDetail( expires() ) << "]";
165  }
166 
172  {
173  std::string _id;
174  std::string _name;
175  std::string _fingerprint;
178 
179  std::vector<PublicSubkeyData> _subkeys;
180 
181  public:
182  bool hasSubkeyId( const std::string & id_r ) const
183  {
184  bool ret = false;
185  for ( const PublicSubkeyData & sub : _subkeys )
186  {
187  if ( sub.id() == id_r )
188  {
189  ret = true;
190  break;
191  }
192  }
193  return ret;
194  }
195 
196  public:
198  static shared_ptr<Impl> nullimpl()
199  {
200  static shared_ptr<Impl> _nullimpl( new Impl );
201  return _nullimpl;
202  }
203 
204  private:
205  friend Impl * rwcowClone<Impl>( const Impl * rhs );
207  Impl * clone() const
208  { return new Impl( *this ); }
209  };
210 
214 
216  : _pimpl( Impl::nullimpl() )
217  {}
218 
220  {}
221 
222  PublicKeyData::operator bool() const
223  { return !_pimpl->_fingerprint.empty(); }
224 
225  std::string PublicKeyData::id() const
226  { return _pimpl->_id; }
227 
228  std::string PublicKeyData::name() const
229  { return _pimpl->_name; }
230 
231  std::string PublicKeyData::fingerprint() const
232  { return _pimpl->_fingerprint; }
233 
235  { return _pimpl->_created; }
236 
238  { return _pimpl->_expires; }
239 
241  { return isExpired( _pimpl->_expires ); }
242 
244  { return hasDaysToLive( _pimpl->_expires ); }
245 
246  std::string PublicKeyData::expiresAsString() const
247  { return expiresDetailVerbose( _pimpl->_expires ); }
248 
250  { return _pimpl->_id.empty() ? _pimpl->_id : str::toLower( _pimpl->_id.substr(8,8) ); }
251 
253  { return _pimpl->_created ? str::hexstring( _pimpl->_created ).substr(2) : std::string(); }
254 
255  std::string PublicKeyData::asString() const
256  {
257  str::Str str;
258  str << "[" << _pimpl->_id << "-" << gpgPubkeyRelease();
259  for ( auto && sub : _pimpl->_subkeys )
260  str << ", " << sub.id();
261  return str << "] [" << _pimpl->_name.c_str() << "] [" << expiresDetail( _pimpl->_expires ) << "]";
262  }
263 
265  { return !_pimpl->_subkeys.empty(); }
266 
268  { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
269 
270  bool PublicKeyData::providesKey( const std::string & id_r ) const
271  { return( id_r == _pimpl->_id || _pimpl->hasSubkeyId( id_r ) ); }
272 
273  std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj )
274  {
275  str << "[" << obj.name() << "]" << endl;
276  str << " fpr " << obj.fingerprint() << endl;
277  str << " id " << obj.id() << endl;
278  str << " cre " << Date::ValueType(obj.created()) << ' ' << obj.created() << endl;
279  str << " exp " << Date::ValueType(obj.expires()) << ' ' << obj.expiresAsString() << endl;
280  str << " ttl " << obj.daysToLive() << endl;
281  for ( auto && sub : obj._pimpl->_subkeys )
282  str << " sub " << sub << endl;
283  str << " rpm " << obj.gpgPubkeyVersion() << "-" << obj.gpgPubkeyRelease() << endl;
284  return str;
285  }
286 
287  bool operator==( const PublicKeyData & lhs, const PublicKeyData & rhs )
288  { return ( lhs.fingerprint() == rhs.fingerprint() && lhs.created() == rhs.created() ); }
289 
290 
296  {
298  std::vector<std::string> _words;
300 
302  : _parseEntry( pNONE )
303  , _keyDataPtr( nullptr )
304  {}
305 
306  void scan( std::string & line_r, std::list<PublicKeyData> & keys_r )
307  {
308  // pub:-:1024:17:A84EDAE89C800ACA:971961473:1214043198::-:SuSE Package Signing Key <build@suse.de>:
309  // fpr:::::::::79C179B2E1C820C1890F9994A84EDAE89C800ACA:
310  // sig:::17:A84EDAE89C800ACA:1087899198:::::[selfsig]::13x:
311  // sig:::17:9E40E310000AABA4:980442706::::[User ID not found]:10x:
312  // sig:::1:77B2E6003D25D3D9:980443247::::[User ID not found]:10x:
313  // sig:::17:A84EDAE89C800ACA:1318348291:::::[selfsig]::13x:
314  // sub:-:2048:16:197448E88495160C:971961490:1214043258::: [expires: 2008-06-21]
315  // sig:::17:A84EDAE89C800ACA:1087899258:::::[keybind]::18x:
316  if ( line_r.empty() )
317  return;
318 
319  // quick check for interesting entries, no parsing in subkeys
320  _parseEntry = pNONE;
321  switch ( line_r[0] )
322  {
323  case 'p':
324  if ( line_r[1] == 'u' && line_r[2] == 'b' && line_r[3] == ':' )
325  {
326  _parseEntry = pPUB;
327  keys_r.push_back( PublicKeyData() ); // reset upon new key
328  _keyDataPtr = keys_r.back()._pimpl.get();
329  }
330  break;
331 
332  case 'f':
333  if ( line_r[1] == 'p' && line_r[2] == 'r' && line_r[3] == ':' )
334  _parseEntry = pFPR;
335  break;
336 
337  case 'u':
338  if ( line_r[1] == 'i' && line_r[2] == 'd' && line_r[3] == ':' )
339  _parseEntry = pUID;
340  break;
341 
342  case 's':
343  if ( line_r[1] == 'i' && line_r[2] == 'g' && line_r[3] == ':' )
344  _parseEntry = pSIG;
345  else if ( line_r[1] == 'u' && line_r[2] == 'b' && line_r[3] == ':' )
346  _parseEntry = pSUB;
347  break;
348 
349  default:
350  return;
351  }
352  if ( _parseEntry == pNONE )
353  return;
354  if ( ! ( _keyDataPtr->_subkeys.empty() || _parseEntry == pSUB ) )
355  return; // collecting subkeys only
356 
357  if ( line_r[line_r.size()-1] == '\n' )
358  line_r.erase( line_r.size()-1 );
359  //DBG << line_r << endl;
360 
361  _words.clear();
362  str::splitFields( line_r, std::back_inserter(_words), ":" );
363 
364  switch ( _parseEntry )
365  {
366  case pPUB:
367  _keyDataPtr->_id = _words[4];
368  _keyDataPtr->_name = str::replaceAll( _words[9], "\\x3a", ":" );
369  _keyDataPtr->_created = Date(str::strtonum<Date::ValueType>(_words[5]));
370  _keyDataPtr->_expires = Date(str::strtonum<Date::ValueType>(_words[6]));
371  break;
372 
373  case pSIG:
374  // Update creation/modification date from signatures type "13x".
375  if ( ( _words.size() > 10 && _words[10] == "13x" && !_words[9].empty() && _words[9] != "[User ID not found]" )
376  || ( _words.size() > 12 && _words[12] == "13x" /* [selfsig] */) )
377  {
378  Date cdate(str::strtonum<Date::ValueType>(_words[5]));
379  if ( _keyDataPtr->_created < cdate )
380  _keyDataPtr->_created = cdate;
381  }
382  break;
383 
384  case pFPR:
385  if ( _keyDataPtr->_fingerprint.empty() )
387  break;
388 
389  case pUID:
390  if ( ! _words[9].empty() && _words[9] != "[User ID not found]" )
391  _keyDataPtr->_name = str::replaceAll( _words[9], "\\x3a", ":" );
392  break;
393 
394  case pSUB:
395  _keyDataPtr->_subkeys.push_back( PublicSubkeyData() );
396  {
397  PublicSubkeyData::Impl * subPtr = _keyDataPtr->_subkeys.back()._pimpl.get();
398  subPtr->_id = _words[4];
399  subPtr->_created = Date(str::strtonum<Date::ValueType>(_words[5]));
400  subPtr->_expires = Date(str::strtonum<Date::ValueType>(_words[6]));
401  }
402  break;
403 
404  case pNONE:
405  break; // intentionally no default:
406  }
407  }
408  };
410 
412  // class PublicKeyScanner
414 
416  : _pimpl( new Impl )
417  {}
418 
420  {}
421 
422  void PublicKeyScanner::scan( std::string line_r )
423  { _pimpl->scan( line_r, _keys ); }
424 
425 
431  {
433  {}
434 
435  Impl( const Pathname & keyFile_r )
436  {
437  PathInfo info( keyFile_r );
438  MIL << "Taking pubkey from " << keyFile_r << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyFile_r, "sha1") << endl;
439 
440  if ( !info.isExist() )
441  ZYPP_THROW(Exception("Can't read public key from " + keyFile_r.asString() + ", file not found"));
442 
443  if ( filesystem::hardlinkCopy( keyFile_r, _dataFile.path() ) != 0 )
444  ZYPP_THROW(Exception("Can't copy public key data from " + keyFile_r.asString() + " to " + _dataFile.path().asString() ));
445 
446  readFromFile();
447  }
448 
449  Impl( const filesystem::TmpFile & sharedFile_r )
450  : _dataFile( sharedFile_r )
451  { readFromFile(); }
452 
453  Impl( const filesystem::TmpFile & sharedFile_r, const PublicKeyData & keyData_r )
454  : _dataFile( sharedFile_r )
455  , _keyData( keyData_r )
456  {
457  if ( ! keyData_r )
458  {
459  WAR << "Invalid PublicKeyData supplied: scanning from file" << endl;
460  readFromFile();
461  }
462  }
463 
464  public:
465  const PublicKeyData & keyData() const
466  { return _keyData; }
467 
468  Pathname path() const
469  { return _dataFile.path(); }
470 
471  const std::list<PublicKeyData> & hiddenKeys() const
472  { return _hiddenKeys; }
473 
474  protected:
476  {
477  PathInfo info( _dataFile.path() );
478  MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl;
479 
480  static filesystem::TmpDir dir;
481  std::string tmppath( dir.path().asString() );
482  std::string datapath( _dataFile.path().asString() );
483 
484  const char* argv[] =
485  {
486  GPG_BINARY,
487  "-v",
488  "--no-default-keyring",
489  "--fixed-list-mode",
490  "--with-fingerprint",
491  "--with-colons",
492  "--homedir",
493  tmppath.c_str(),
494  "--quiet",
495  "--no-tty",
496  "--no-greeting",
497  "--batch",
498  "--status-fd", "1",
499  datapath.c_str(),
500  NULL
501  };
502  ExternalProgram prog( argv, ExternalProgram::Discard_Stderr, false, -1, true );
503 
504  PublicKeyScanner scanner;
505  for ( std::string line = prog.receiveLine(); !line.empty(); line = prog.receiveLine() )
506  {
507  scanner.scan( line );
508  }
509  int ret = prog.close();
510 
511  switch ( scanner._keys.size() )
512  {
513  case 0:
514  if ( ret == 129 )
515  ZYPP_THROW( Exception( std::string("Can't read public key data: ") + GPG_BINARY + " is not installed!" ) );
516  else
517  ZYPP_THROW( BadKeyException( "File " + _dataFile.path().asString() + " doesn't contain public key data" , _dataFile.path() ) );
518  break;
519 
520  case 1:
521  // ok.
522  _keyData = scanner._keys.back();
523  _hiddenKeys.clear();
524  break;
525 
526  default:
527  WAR << "File " << _dataFile.path().asString() << " contains multiple keys: " << scanner._keys << endl;
528  _keyData = scanner._keys.back();
529  scanner._keys.pop_back();
530  _hiddenKeys.swap( scanner._keys );
531  break;
532  }
533 
534  MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl;
535  }
536 
537  private:
540  std::list<PublicKeyData> _hiddenKeys;
541 
542  public:
544  static shared_ptr<Impl> nullimpl()
545  {
546  static shared_ptr<Impl> _nullimpl( new Impl );
547  return _nullimpl;
548  }
549 
550  private:
551  friend Impl * rwcowClone<Impl>( const Impl * rhs );
553  Impl * clone() const
554  { return new Impl( *this ); }
555  };
557 
559  // class PublicKey
562  : _pimpl( Impl::nullimpl() )
563  {}
564 
565  PublicKey::PublicKey( const Pathname & file )
566  : _pimpl( new Impl( file ) )
567  {}
568 
570  : _pimpl( new Impl( sharedfile ) )
571  {}
572 
573  PublicKey::PublicKey( const filesystem::TmpFile & sharedfile, const PublicKeyData & keydata )
574  : _pimpl( new Impl( sharedfile, keydata ) )
575  {}
576 
578  {}
579 
581  { return _pimpl->keyData(); }
582 
583  Pathname PublicKey::path() const
584  { return _pimpl->path(); }
585 
586  const std::list<PublicKeyData> & PublicKey::hiddenKeys() const
587  { return _pimpl->hiddenKeys(); }
588 
589  std::string PublicKey::id() const
590  { return keyData().id(); }
591 
592  std::string PublicKey::name() const
593  { return keyData().name(); }
594 
595  std::string PublicKey::fingerprint() const
596  { return keyData().fingerprint(); }
597 
599  { return keyData().created(); }
600 
602  { return keyData().expires(); }
603 
604  bool PublicKey::expired() const
605  { return keyData().expired(); }
606 
608  { return keyData().daysToLive(); }
609 
610  std::string PublicKey::expiresAsString() const
611  { return keyData().expiresAsString(); }
612 
613  std::string PublicKey::gpgPubkeyVersion() const
614  { return keyData().gpgPubkeyVersion(); }
615 
616  std::string PublicKey::gpgPubkeyRelease() const
617  { return keyData().gpgPubkeyRelease(); }
618 
619  std::string PublicKey::asString() const
620  { return keyData().asString(); }
621 
622  bool PublicKey::operator==( const PublicKey & rhs ) const
623  { return rhs.keyData() == keyData(); }
624 
625  bool PublicKey::operator==( const std::string & sid ) const
626  { return sid == id(); }
627 
628  std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
629  { return dumpOn( str, obj.keyData() ); }
630 
632 } // namespace zypp
std::string name() const
Key name.
Definition: PublicKey.cc:228
static const ValueType day
Definition: Date.h:43
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:237
Interface to gettext.
#define MIL
Definition: Logger.h:47
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition: PublicKey.cc:453
bool hasSubkeyId(const std::string &id_r) const
Definition: PublicKey.cc:182
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created)
Definition: PublicKey.cc:252
Date created() const
Creation date.
Definition: PublicKey.cc:150
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:243
#define GPG_BINARY
Definition: PublicKey.cc:32
std::list< PublicKeyData > _hiddenKeys
Definition: PublicKey.cc:540
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:320
int daysToLive() const
Definition: PublicKey.cc:607
Pathname path() const
Definition: TmpPath.cc:146
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:112
std::list< PublicKeyData > _keys
Extracted keys.
Definition: PublicKey.h:257
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:207
PublicSubkeyData implementation.
Definition: PublicKey.cc:112
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition: PublicKey.cc:267
#define _PL(MSG1, MSG2, N)
Definition: Gettext.h:30
Class representing one GPG Public Keys data.
Definition: PublicKey.h:132
const std::string & asString() const
String representation.
Definition: Pathname.h:90
Exception thrown when the supplied key is not a valid gpg key.
Definition: PublicKey.h:41
bool hasSubkeys() const
Whether subkeys is not empty.
Definition: PublicKey.cc:264
PublicSubkeyData()
Default constructed: empty data.
Definition: PublicKey.cc:137
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob containes multiple keys.
Definition: PublicKey.cc:586
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:153
Date expires() const
Definition: PublicKey.cc:601
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:191
bool providesKey(const std::string &id_r) const
Whether id_r is the id of the primary key or of a subkey.
Definition: PublicKey.cc:270
std::string asString() const
Definition: PublicKey.cc:619
PublicKeyData::Impl * _keyDataPtr
Definition: PublicKey.cc:299
void scan(std::string line_r)
Feed gpg output line by line into scan.
Definition: PublicKey.cc:422
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Definition: PublicKey.h:260
Date created() const
Definition: PublicKey.cc:598
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id)
Definition: PublicKey.cc:249
PublicKeyScanner implementation.
Definition: PublicKey.cc:295
std::string expiresAsString() const
Definition: PublicKey.cc:246
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:126
const std::list< PublicKeyData > & hiddenKeys() const
Definition: PublicKey.cc:471
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:129
PublicKeyData()
Default constructed: empty data.
Definition: PublicKey.cc:215
std::string gpgPubkeyVersion() const
Definition: PublicKey.cc:613
std::string & replaceAll(std::string &str_r, const std::string &from_r, const std::string &to_r)
Replace all occurrences of from_r with to_r in str_r (inplace).
Definition: String.cc:313
std::string id() const
Definition: PublicKey.cc:589
bool expired() const
Definition: PublicKey.cc:604
enum zypp::PublicKeyScanner::Impl::@1 _parseEntry
Pathname path() const
File containig the ASCII armored key.
Definition: PublicKey.cc:583
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: PublicKey.h:355
Store and operate on date (time_t).
Definition: Date.h:32
PublicKeyData _keyData
Definition: PublicKey.cc:539
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition: TmpPath.h:170
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:216
Pathname path() const
Definition: PublicKey.cc:468
Impl(const Pathname &keyFile_r)
Definition: PublicKey.cc:435
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::string fingerprint() const
Key fingerprint.
Definition: PublicKey.cc:231
#define WAR
Definition: Logger.h:48
std::string expiresAsString() const
Definition: PublicKey.cc:610
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:240
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:823
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:544
#define nullptr
Definition: Easy.h:54
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:437
#define _(MSG)
Definition: Gettext.h:29
std::string receiveLine()
Read one line from the input stream.
Scan abstract from 'gpg –with-colons' key listings.
Definition: PublicKey.h:248
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition: String.cc:175
PublicKey()
Default ctor.
Definition: PublicKey.cc:561
std::vector< std::string > _words
Definition: PublicKey.cc:298
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:162
PublicKey implementation.
Definition: PublicKey.cc:430
int close()
Wait for the progamm to complete.
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:159
Class representing a GPG Public Keys subkeys.
Definition: PublicKey.h:72
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:277
Base class for Exception.
Definition: Exception.h:143
Impl(const filesystem::TmpFile &sharedFile_r)
Definition: PublicKey.cc:449
const PublicKeyData & keyData() const
The public keys data (.
Definition: PublicKey.cc:580
static Date now()
Return the current time.
Definition: Date.h:77
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition: PathInfo.cc:989
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:210
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:553
std::string id() const
Key ID.
Definition: PublicKey.cc:225
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:198
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:156
void scan(std::string &line_r, std::list< PublicKeyData > &keys_r)
Definition: PublicKey.cc:306
time_t ValueType
Definition: Date.h:38
PublicKeyData implementation.
Definition: PublicKey.cc:171
std::string fingerprint() const
Definition: PublicKey.cc:595
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:120
std::vector< PublicSubkeyData > _subkeys
Definition: PublicKey.cc:179
filesystem::TmpFile _dataFile
Definition: PublicKey.cc:538
Date created() const
Creation / last modification date (latest selfsig).
Definition: PublicKey.cc:234
std::string gpgPubkeyRelease() const
Definition: PublicKey.cc:616
std::string hexstring(char n, int w=4)
Definition: String.h:346
bool operator==(const PublicKey &rhs) const
Definition: PublicKey.cc:622
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:255
std::string name() const
Definition: PublicKey.cc:592
std::string id() const
Subkey ID.
Definition: PublicKey.cc:147
const PublicKeyData & keyData() const
Definition: PublicKey.cc:465
unsigned splitFields(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=":")
Split line_r into fields.
Definition: String.h:705