QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
gpgkeystate.h File Reference

Parsing of gpg --with-colons key listings into UserInfo records. More...

#include "userinfo.h"
#include <QList>
#include <QString>
#include <QStringList>
Include dependency graph for gpgkeystate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  GpgRecordType {
  Unknown , Pub , Sec , Uid ,
  Fpr , Sub , Ssb , Grp
}
 The record types of a gpg --with-colons listing that the parser tells apart; the first field of each line names one. More...

Functions

GpgRecordType classifyRecord (const QString &record_type)
 Classify a record of a gpg colon listing by its first field.
QList< UserInfo > parseGpgColonOutput (const QString &output, bool secret)
 Parse a gpg colon listing into one UserInfo per key.
QString primaryFingerprintOf (const QString &output, const QString &key)
 The primary key fingerprint of the key that key names.

Detailed Description

Parsing of gpg --with-colons key listings into UserInfo records.

Definition in file gpgkeystate.h.

Enumeration Type Documentation

◆ GpgRecordType

enum class GpgRecordType
strong

The record types of a gpg --with-colons listing that the parser tells apart; the first field of each line names one.

Enumerator
Unknown 

Any record type not listed here; skipped.

Pub 

pub: a public primary key, starting a new key block.

Sec 

sec: a secret primary key, starting a new key block.

Uid 

uid: a user ID of the current key.

Fpr 

fpr: the fingerprint of the key or subkey before it.

Sub 

sub: a public subkey.

Ssb 

ssb: a secret subkey.

Grp 

grp: a keygrip.

Definition at line 21 of file gpgkeystate.h.

Function Documentation

◆ classifyRecord()

GpgRecordType classifyRecord ( const QString & record_type)

Classify a record of a gpg colon listing by its first field.

Parameters
record_typeThe first field of the record (pub, sec, uid, and so on).
Returns
The matching GpgRecordType, or GpgRecordType::Unknown.

Definition at line 34 of file gpgkeystate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseGpgColonOutput()

QList< UserInfo > parseGpgColonOutput ( const QString & output,
bool secret )

Parse a gpg colon listing into one UserInfo per key.

A pub or sec record starts a key; the first uid after it supplies the name when the key record carried none, and an fpr record whose value ends in the key ID replaces the key ID with the full fingerprint. Lines with fewer than ten fields are skipped.

Parameters
outputRaw output of gpg --with-colons --with-fingerprint.
secretTrue when output lists secret keys (--list-secret-keys); the keys are then marked as having a secret part.
Returns
The keys, in the order gpg listed them.

Definition at line 112 of file gpgkeystate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ primaryFingerprintOf()

QString primaryFingerprintOf ( const QString & output,
const QString & key )

The primary key fingerprint of the key that key names.

gpg accepts a signature by a subkey for its primary key, and verification here takes either fingerprint from VALIDSIG: a key written as a subkey's fingerprint, or as a key ID, signs as its primary key. Only the block that holds key is taken, whatever else gpg printed; when several do (a short ID, which collides easily), none is.

Parameters
outputRaw output from GPG –with-colons –with-fingerprint –with-subkey-fingerprint –list-keys.
keyA fingerprint (40 or 64 hex) or a key ID (8 or 16 hex), optionally with 0x; any case. A key ID is matched against the record's own key ID, so it works for v4 keys (the fingerprint's tail) and v5/v6 keys (its head) alike.
Returns
The primary fingerprint in upper case, or empty when no block, or more than one, in output holds key.

Definition at line 160 of file gpgkeystate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: