|
QtPass 2.0.0
Developer documentation
|
Implements the colon-listing parser: record classification, one handler per record type, and primary-fingerprint lookup. More...
#include "gpgkeystate.h"#include "gpgkeystate_p.h"#include "util.h"#include <QDateTime>#include <QRegularExpression>Go to the source code of this file.
Functions | |
| auto | classifyRecord (const QString &record_type) -> GpgRecordType |
| Classify a record of a gpg colon listing by its first field. | |
| void | handlePubSecRecord (const QStringList &props, bool secret, UserInfo ¤t_user) |
| Start a key from a pub or sec record: key ID, the user ID the record may carry, validity, creation and expiry time. | |
| void | handleUidRecord (const QStringList &props, UserInfo ¤t_user) |
| Handle a uid record in GPG colon output. | |
| void | handleFprRecord (const QStringList &props, UserInfo ¤t_user) |
| Replace the key ID of the key being built with its fingerprint. | |
| auto | parseGpgColonOutput (const QString &output, bool secret) -> QList< UserInfo > |
| Parse a gpg colon listing into one UserInfo per key. | |
| auto | primaryFingerprintOf (const QString &output, const QString &key) -> QString |
The primary key fingerprint of the key that key names. | |
Variables | |
| constexpr int | GPG_MIN_FIELDS = 10 |
| Fewest fields a record must have to be read at all. | |
| constexpr int | GPG_FIELD_VALIDITY = 1 |
| Field index of the validity letter (u, f, r, ...). | |
| constexpr int | GPG_FIELD_KEY_ID = 4 |
| Field index of the key ID. | |
| constexpr int | GPG_FIELD_CREATED = 5 |
| Field index of the creation time, in seconds since the epoch. | |
| constexpr int | GPG_FIELD_EXPIRY = 6 |
| Field index of the expiry time; empty for a key without one. | |
| constexpr int | GPG_FIELD_USERID = 9 |
| Field index of the user ID. | |
| constexpr int | GPG_FIELD_FINGERPRINT = 9 |
| Field 9 of an fpr record: the fingerprint, in the slot the user ID occupies in a uid record. | |
Implements the colon-listing parser: record classification, one handler per record type, and primary-fingerprint lookup.
Definition in file gpgkeystate.cpp.
| auto classifyRecord | ( | const QString & | record_type | ) |
Classify a record of a gpg colon listing by its first field.
| record_type | The first field of the record (pub, sec, uid, and so on). |
Definition at line 34 of file gpgkeystate.cpp.
| void handleFprRecord | ( | const QStringList & | props, |
| UserInfo & | current_user ) |
Replace the key ID of the key being built with its fingerprint.
Only when the fpr record's value is shaped like a fingerprint (40 or 64 hex digits) and ends in the key ID already there, so a subkey's fingerprint is never taken for the primary key's.
| props | The colon-split fields of the record. |
| current_user | The key being built; its key ID may be replaced. |
Definition at line 96 of file gpgkeystate.cpp.
| void handlePubSecRecord | ( | const QStringList & | props, |
| bool | secret, | ||
| UserInfo & | current_user ) |
Start a key from a pub or sec record: key ID, the user ID the record may carry, validity, creation and expiry time.
An empty expiry field (gpg's "no expiry") leaves the date null. A record with fewer than ten fields changes nothing.
| props | The colon-split fields of the record. |
| secret | Whether to mark the key as having a secret part. |
| current_user | The key being built; filled in. |
Definition at line 59 of file gpgkeystate.cpp.
| void handleUidRecord | ( | const QStringList & | props, |
| UserInfo & | current_user ) |
Handle a uid record in GPG colon output.
| props | The colon-split fields of the record |
| current_user | UserInfo to populate with user name |
Definition at line 92 of file gpgkeystate.cpp.
| auto 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.
| output | Raw output of gpg --with-colons --with-fingerprint. |
| secret | True when output lists secret keys (--list-secret-keys); the keys are then marked as having a secret part. |
Definition at line 112 of file gpgkeystate.cpp.
| auto 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.
| output | Raw output from GPG –with-colons –with-fingerprint –with-subkey-fingerprint –list-keys. |
| key | A 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. |
output holds key. Definition at line 160 of file gpgkeystate.cpp.
|
constexpr |
Field index of the creation time, in seconds since the epoch.
Definition at line 23 of file gpgkeystate.cpp.
|
constexpr |
Field index of the expiry time; empty for a key without one.
Definition at line 25 of file gpgkeystate.cpp.
|
constexpr |
Field 9 of an fpr record: the fingerprint, in the slot the user ID occupies in a uid record.
Definition at line 32 of file gpgkeystate.cpp.
|
constexpr |
Field index of the key ID.
Definition at line 21 of file gpgkeystate.cpp.
|
constexpr |
Field index of the user ID.
Definition at line 27 of file gpgkeystate.cpp.
|
constexpr |
Field index of the validity letter (u, f, r, ...).
Definition at line 19 of file gpgkeystate.cpp.
|
constexpr |
Fewest fields a record must have to be read at all.
Definition at line 17 of file gpgkeystate.cpp.