Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyen Van Nguyen <[email protected]>
  • Loading branch information
nguyennv committed Jan 2, 2024
1 parent 32e0b28 commit e810486
Show file tree
Hide file tree
Showing 27 changed files with 76 additions and 14 deletions.
6 changes: 5 additions & 1 deletion lib/src/armor/armor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import '../enum/armor_type.dart';
import '../helpers.dart';

/// ASCII Armor class
/// OpenPGP's Radix-64 encoding.
/// It is composed of two parts: a base64
/// encoding of the binary data and a checksum.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-6
/// Author Nguyen Van Nguyen <[email protected]>
class Armor {
static const version = 'Dart PG v1.0.0';
static const version = 'Dart PG v1.2.0';
static const comment = 'Dart Privacy Guard';

static const messageBegin = '-----BEGIN PGP MESSAGE';
Expand Down
1 change: 1 addition & 0 deletions lib/src/enum/compression_algorithm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file that was distributed with this source code.

/// Compression algorithm enum
/// See https://www.rfc-editor.org/rfc/rfc4880#section-9.3
/// Author Nguyen Van Nguyen <[email protected]>
enum CompressionAlgorithm {
uncompressed(0),
Expand Down
1 change: 1 addition & 0 deletions lib/src/enum/key_algorithm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file that was distributed with this source code.

/// Public-Key Algorithms
/// See https://www.rfc-editor.org/rfc/rfc4880#section-9.1
/// Author Nguyen Van Nguyen <[email protected]>
enum KeyAlgorithm {
/// RSA (Encrypt or Sign) [HAC]
Expand Down
3 changes: 2 additions & 1 deletion lib/src/packet/signature/embedded_signature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import '../../enum/signature_subpacket_type.dart';
import '../signature_packet.dart';
import '../signature_subpacket.dart';

/// Packet embedded signature
/// This subpacket contains a complete Signature packet body specified in Section 5.2
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.26
/// Author Nguyen Van Nguyen <[email protected]>
class EmbeddedSignature extends SignatureSubpacket {
EmbeddedSignature(final Uint8List data, {super.critical, super.isLong})
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/exportable_certification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import 'dart:typed_data';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// This subpacket denotes whether a certification signature is
/// "exportable", to be used by other users than the signature's issuer.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.11
/// Author Nguyen Van Nguyen <[email protected]>
class ExportableCertification extends SignatureSubpacket {
ExportableCertification(
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import '../../enum/signature_subpacket_type.dart';
import '../../enum/support_feature.dart';
import '../signature_subpacket.dart';

/// The Features subpacket denotes which advanced OpenPGP features a
/// user's implementation supports.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.24
/// Author Nguyen Van Nguyen <[email protected]>
class Features extends SignatureSubpacket {
Features(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/packet/signature/issuer_fingerprint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import '../../enum/signature_subpacket_type.dart';
import '../key_packet.dart';
import '../signature_subpacket.dart';

/// Packet giving the issuer key fingerprint.
/// The OpenPGP Key fingerprint of the key issuing the signature.
/// See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-rfc4880bis#section-5.2.3.28
/// Author Nguyen Van Nguyen <[email protected]>
class IssuerFingerprint extends SignatureSubpacket {
IssuerFingerprint(final Uint8List data, {super.critical, super.isLong})
Expand Down
3 changes: 2 additions & 1 deletion lib/src/packet/signature/issuer_key_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// Packet giving the issuer key ID.
/// The OpenPGP Key ID of the key issuing the signature.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.5
/// Author Nguyen Van Nguyen <[email protected]>
class IssuerKeyID extends SignatureSubpacket {
IssuerKeyID(final Uint8List data, {super.critical, super.isLong})
Expand Down
6 changes: 5 additions & 1 deletion lib/src/packet/signature/key_expiration_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import '../../crypto/math/int_ext.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Packet giving time after creation at which the key expires.
/// The validity period of the key. This is the number of seconds after
/// the key creation time that the key expires. If this is not present
/// or has a value of zero, the key never expires. This is found only on
/// a self-signature.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.6
/// Author Nguyen Van Nguyen <[email protected]>
class KeyExpirationTime extends SignatureSubpacket {
KeyExpirationTime(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/packet/signature/key_flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import '../../enum/key_flag.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Packet holding the key flag values.
/// This subpacket contains a list of binary flags that hold information about a key.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.21
/// Author Nguyen Van Nguyen <[email protected]>
class KeyFlags extends SignatureSubpacket {
KeyFlags(
Expand Down
4 changes: 4 additions & 0 deletions lib/src/packet/signature/key_server_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// This is a list of one-bit flags that indicate preferences that the
/// key holder has about how the key is handled on a key server.
/// All undefined flags MUST be zero.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.17
/// Author Nguyen Van Nguyen <[email protected]>
class KeyServerPreferences extends SignatureSubpacket {
KeyServerPreferences(
Expand Down
4 changes: 3 additions & 1 deletion lib/src/packet/signature/notation_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import 'dart:typed_data';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Class provided a NotationData object according to RFC2440, Chapter 5.2.3.15. Notation Data
/// This subpacket describes a "notation" on the signature that the issuer wishes to make.
/// The notation has a name and a value, each of which are strings of octets.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.16
/// Author Nguyen Van Nguyen <[email protected]>
class NotationData extends SignatureSubpacket {
static const headerFlagLength = 4;
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/policy_uri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// This subpacket contains a URI of a document that describes the policy
/// under which the signature was issued.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.20
/// Author Nguyen Van Nguyen <[email protected]>
class PolicyURI extends SignatureSubpacket {
PolicyURI(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import '../../enum/compression_algorithm.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Compression algorithm numbers that indicate which algorithms the key
/// holder prefers to use.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.9
/// Author Nguyen Van Nguyen <[email protected]>
class PreferredCompressionAlgorithms extends SignatureSubpacket {
PreferredCompressionAlgorithms(
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/preferred_hash_algorithms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import '../../enum/hash_algorithm.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Message digest algorithm numbers that indicate which algorithms the
/// key holder prefers to receive.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.8
/// Author Nguyen Van Nguyen <[email protected]>
class PreferredHashAlgorithms extends SignatureSubpacket {
PreferredHashAlgorithms(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/packet/signature/preferred_key_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// This is a URI of a key server that the key holder prefers be used for updates.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.18
/// Author Nguyen Van Nguyen <[email protected]>
class PreferredKeyServer extends SignatureSubpacket {
PreferredKeyServer(
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/preferred_symmetric_algorithms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import '../../enum/signature_subpacket_type.dart';
import '../../enum/symmetric_algorithm.dart';
import '../signature_subpacket.dart';

/// Symmetric algorithm numbers that indicate which algorithms the key
/// holder prefers to use.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.7
/// Author Nguyen Van Nguyen <[email protected]>
class PreferredSymmetricAlgorithms extends SignatureSubpacket {
PreferredSymmetricAlgorithms(
Expand Down
4 changes: 3 additions & 1 deletion lib/src/packet/signature/primary_user_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import 'dart:typed_data';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Packet giving whether or not the signature is signed using the primary user ID for the key.
/// This is a flag in a User ID's self-signature that states whether this
/// User ID is the main User ID for this key.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.19
/// Author Nguyen Van Nguyen <[email protected]>
class PrimaryUserID extends SignatureSubpacket {
PrimaryUserID(final Uint8List data, {super.critical, super.isLong})
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/regular_expression.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// Used in conjunction with trust Signature packets (of level > 0) to
/// limit the scope of trust that is extended.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.14
/// Author Nguyen Van Nguyen <[email protected]>
class RegularExpression extends SignatureSubpacket {
RegularExpression(final Uint8List data, {super.critical, super.isLong})
Expand Down
4 changes: 3 additions & 1 deletion lib/src/packet/signature/revocable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import 'dart:typed_data';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Packet giving whether or not is revocable.
/// Signature's revocability status. The packet body contains a
/// Boolean flag indicating whether the signature is revocable.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.12
/// Author Nguyen Van Nguyen <[email protected]>
class Revocable extends SignatureSubpacket {
Revocable(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/packet/signature/revocation_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../../enum/revocation_key_tag.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Authorizes the specified key to issue revocation signatures for this key.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.15
/// Author Nguyen Van Nguyen <[email protected]>
class RevocationKey extends SignatureSubpacket {
RevocationKey(final Uint8List data, {super.critical, super.isLong})
Expand Down
4 changes: 3 additions & 1 deletion lib/src/packet/signature/revocation_reason.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import '../../enum/revocation_reason_tag.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Represents revocation reason OpenPGP signature sub packet.
/// This subpacket is used only in key revocation and certification
/// revocation signatures.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.23
/// Author Nguyen Van Nguyen <[email protected]>
class RevocationReason extends SignatureSubpacket {
RevocationReason(final Uint8List data, {super.critical, super.isLong})
Expand Down
3 changes: 3 additions & 0 deletions lib/src/packet/signature/signature_creation_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// The time the signature was made.
/// MUST be present in the hashed area.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.4
/// Author Nguyen Van Nguyen <[email protected]>
class SignatureCreationTime extends SignatureSubpacket {
SignatureCreationTime(
Expand Down
5 changes: 4 additions & 1 deletion lib/src/packet/signature/signature_expiration_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import '../../enum/signature_subpacket_type.dart';
import '../../helpers.dart';
import '../signature_subpacket.dart';

/// Packet giving signature expiration time.
/// The validity period of the signature. This is the number of seconds
/// after the signature creation time that the signature expires.
/// If this is not present or has a value of zero, it never expires.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.10
/// Author Nguyen Van Nguyen <[email protected]>
class SignatureExpirationTime extends SignatureSubpacket {
SignatureExpirationTime(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/packet/signature/signature_target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import '../../enum/key_algorithm.dart';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// RFC 4880, Section 5.2.3.25 - Signature Target subpacket.
/// This subpacket identifies a specific target signature to which a signature refers.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.25
/// Author Nguyen Van Nguyen <[email protected]>
class SignatureTarget extends SignatureSubpacket {
SignatureTarget(final Uint8List data, {super.critical, super.isLong})
Expand Down
4 changes: 3 additions & 1 deletion lib/src/packet/signature/signer_user_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import 'dart:typed_data';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Packet giving the User ID of the signer.
/// This subpacket allows a keyholder to state which User ID is
/// responsible for the signing.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.22
/// Author Nguyen Van Nguyen <[email protected]>
class SignerUserID extends SignatureSubpacket {
SignerUserID(final Uint8List data, {super.critical, super.isLong})
Expand Down
4 changes: 3 additions & 1 deletion lib/src/packet/signature/trust_signature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import 'dart:typed_data';
import '../../enum/signature_subpacket_type.dart';
import '../signature_subpacket.dart';

/// Packet giving trust.
/// Signer asserts that the key is not only valid but also trustworthy at
/// the specified level.
/// See https://www.rfc-editor.org/rfc/rfc4880#section-5.2.3.13
/// Author Nguyen Van Nguyen <[email protected]>
class TrustSignature extends SignatureSubpacket {
TrustSignature(final Uint8List data, {super.critical, super.isLong})
Expand Down

0 comments on commit e810486

Please sign in to comment.