diff --git a/lib/src/common/config.dart b/lib/src/common/config.dart index cb1742a8..192b0861 100644 --- a/lib/src/common/config.dart +++ b/lib/src/common/config.dart @@ -29,7 +29,7 @@ final class Config { static HashAlgorithm preferredHash = HashAlgorithm.sha256; - static SymmetricAlgorithm preferredSymmetric = SymmetricAlgorithm.aes128; + static SymmetricAlgorithm preferredSymmetric = SymmetricAlgorithm.aes256; static CompressionAlgorithm preferredCompression = CompressionAlgorithm.uncompressed; diff --git a/lib/src/cryptor/aead/eax.dart b/lib/src/cryptor/aead/eax.dart index 0c0c6164..afd3259a 100644 --- a/lib/src/cryptor/aead/eax.dart +++ b/lib/src/cryptor/aead/eax.dart @@ -5,7 +5,6 @@ library; import 'dart:typed_data'; - import 'package:pointycastle/export.dart'; import '../../enum/symmetric_algorithm.dart'; diff --git a/lib/src/cryptor/aead/gcm.dart b/lib/src/cryptor/aead/gcm.dart index 81211ed9..a91c520b 100644 --- a/lib/src/cryptor/aead/gcm.dart +++ b/lib/src/cryptor/aead/gcm.dart @@ -5,7 +5,6 @@ library; import 'dart:typed_data'; - import 'package:pointycastle/export.dart'; import '../../enum/symmetric_algorithm.dart'; diff --git a/lib/src/cryptor/symmetric/buffered_cipher.dart b/lib/src/cryptor/symmetric/buffered_cipher.dart index 0acd0709..6b8fc3f0 100644 --- a/lib/src/cryptor/symmetric/buffered_cipher.dart +++ b/lib/src/cryptor/symmetric/buffered_cipher.dart @@ -5,7 +5,6 @@ library; import 'dart:typed_data'; - import 'package:pointycastle/api.dart'; /// Buffered cipher. diff --git a/lib/src/cryptor/symmetric/camellia.dart b/lib/src/cryptor/symmetric/camellia.dart index 9eee7101..6d5bd99b 100644 --- a/lib/src/cryptor/symmetric/camellia.dart +++ b/lib/src/cryptor/symmetric/camellia.dart @@ -7,8 +7,8 @@ library; import 'dart:typed_data'; import 'package:pointycastle/api.dart'; -import 'base_engine.dart'; import '../../common/extensions.dart'; +import 'base_engine.dart'; /// Camellia - based on RFC 3713. /// Author Nguyen Van Nguyen diff --git a/lib/src/cryptor/symmetric/cast5.dart b/lib/src/cryptor/symmetric/cast5.dart index 57189a62..953fce34 100644 --- a/lib/src/cryptor/symmetric/cast5.dart +++ b/lib/src/cryptor/symmetric/cast5.dart @@ -7,8 +7,8 @@ library; import 'dart:typed_data'; import 'package:pointycastle/api.dart'; -import 'base_engine.dart'; import '../../common/extensions.dart'; +import 'base_engine.dart'; /// A class that provides CAST key encryption operations, such as encoding data and generating keys. /// All the algorithms herein are from the Internet RFC's diff --git a/lib/src/cryptor/symmetric/idea.dart b/lib/src/cryptor/symmetric/idea.dart index 78585641..d5f963ea 100644 --- a/lib/src/cryptor/symmetric/idea.dart +++ b/lib/src/cryptor/symmetric/idea.dart @@ -7,8 +7,8 @@ library; import 'dart:typed_data'; import 'package:pointycastle/api.dart'; -import 'base_engine.dart'; import '../../common/extensions.dart'; +import 'base_engine.dart'; /// A class that provides a basic International Data Encryption Algorithm (IDEA) engine. /// Author Nguyen Van Nguyen diff --git a/lib/src/cryptor/symmetric/twofish.dart b/lib/src/cryptor/symmetric/twofish.dart index 2cc716b3..1eb8750a 100644 --- a/lib/src/cryptor/symmetric/twofish.dart +++ b/lib/src/cryptor/symmetric/twofish.dart @@ -7,8 +7,8 @@ library; import 'dart:typed_data'; import 'package:pointycastle/api.dart'; -import 'base_engine.dart'; import '../../common/extensions.dart'; +import 'base_engine.dart'; /// A class that provides Twofish encryption operations. /// Author Nguyen Van Nguyen diff --git a/lib/src/enum/signature_type.dart b/lib/src/enum/signature_type.dart index e28da968..c000e16c 100644 --- a/lib/src/enum/signature_type.dart +++ b/lib/src/enum/signature_type.dart @@ -6,14 +6,14 @@ library; export 'aead_algorithm.dart'; export 'compression_algorithm.dart'; +export 'hash_algorithm.dart'; +export 'key_algorithm.dart'; export 'key_flag.dart'; export 'key_version.dart'; export 'literal_format.dart'; +export 'signature_subpacket_type.dart'; export 'support_feature.dart'; export 'symmetric_algorithm.dart'; -export 'hash_algorithm.dart'; -export 'key_algorithm.dart'; -export 'signature_subpacket_type.dart'; ///Signature types enum /// Author Nguyen Van Nguyen diff --git a/lib/src/message/cleartext_message.dart b/lib/src/message/cleartext_message.dart index 3f5eb722..82deef4d 100644 --- a/lib/src/message/cleartext_message.dart +++ b/lib/src/message/cleartext_message.dart @@ -5,13 +5,13 @@ library; import '../common/helpers.dart'; -import '../message/signature.dart'; -import '../message/signed_message.dart'; import '../packet/base_packet.dart'; import '../type/cleartext_message.dart'; import '../type/key.dart'; import '../type/notation_data.dart'; import '../type/signature.dart'; +import 'signature.dart'; +import 'signed_message.dart'; /// Cleartext message class that represents an OpenPGP cleartext message. /// See RFC 9580, section 7. diff --git a/lib/src/message/encrypted_message.dart b/lib/src/message/encrypted_message.dart index ad104444..104c9298 100644 --- a/lib/src/message/encrypted_message.dart +++ b/lib/src/message/encrypted_message.dart @@ -7,13 +7,13 @@ library; import '../common/armor.dart'; import '../common/helpers.dart'; import '../enum/armor_type.dart'; -import '../message/base_message.dart'; import '../packet/base_packet.dart'; import '../type/encrypted_data_packet.dart'; import '../type/encrypted_message.dart'; import '../type/packet_list.dart'; import '../type/private_key.dart'; import '../type/session_key.dart'; +import 'base_message.dart'; /// OpenPGP encrypted message class /// Author Nguyen Van Nguyen diff --git a/lib/src/message/literal_message.dart b/lib/src/message/literal_message.dart index 5ac61d74..7cccf0f3 100644 --- a/lib/src/message/literal_message.dart +++ b/lib/src/message/literal_message.dart @@ -13,7 +13,6 @@ import '../enum/aead_algorithm.dart'; import '../enum/armor_type.dart'; import '../enum/compression_algorithm.dart'; import '../enum/symmetric_algorithm.dart'; -import '../message/base_message.dart'; import '../packet/base_packet.dart'; import '../packet/key/session_key.dart'; import '../type/key.dart'; @@ -22,6 +21,7 @@ import '../type/literal_message.dart'; import '../type/packet_list.dart'; import '../type/session_key.dart'; import '../type/signature_packet.dart'; +import 'base_message.dart'; /// OpenPGP literal message class /// Author Nguyen Van Nguyen @@ -59,7 +59,7 @@ final class LiteralMessage extends BaseMessage /// Taking the algorithm preferences of the passed encryption keys, if any. static SessionKeyInterface generateSessionKey( final Iterable encryptionKeys, [ - final SymmetricAlgorithm defaultSymmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm defaultSymmetric = SymmetricAlgorithm.aes256, ]) { final SymmetricAlgorithm symmetric; if (encryptionKeys.isNotEmpty) { @@ -163,7 +163,7 @@ final class LiteralMessage extends BaseMessage encrypt({ final Iterable encryptionKeys = const [], final Iterable passwords = const [], - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, }) { final sessionKey = generateSessionKey( encryptionKeys, diff --git a/lib/src/message/signature.dart b/lib/src/message/signature.dart index 82330d87..57fc733a 100644 --- a/lib/src/message/signature.dart +++ b/lib/src/message/signature.dart @@ -8,7 +8,6 @@ import '../common/armor.dart'; import '../common/helpers.dart'; import '../enum/armor_type.dart'; import '../enum/hash_algorithm.dart'; -import '../message/verification.dart'; import '../packet/base_packet.dart'; import '../type/cleartext_message.dart'; import '../type/key.dart'; @@ -16,6 +15,7 @@ import '../type/literal_data.dart'; import '../type/signature.dart'; import '../type/signature_packet.dart'; import '../type/verification.dart'; +import 'verification.dart'; /// Signature class /// Author Nguyen Van Nguyen diff --git a/lib/src/message/signed_message.dart b/lib/src/message/signed_message.dart index e3cd8d9c..fd01f615 100644 --- a/lib/src/message/signed_message.dart +++ b/lib/src/message/signed_message.dart @@ -6,13 +6,13 @@ library; import '../common/armor.dart'; import '../enum/armor_type.dart'; -import '../message/signature.dart'; import '../packet/packet_list.dart'; import '../type/key.dart'; import '../type/signature.dart'; import '../type/signature_packet.dart'; import '../type/signed_cleartext_message.dart'; import 'cleartext_message.dart'; +import 'signature.dart'; /// Signed message class that represents an OpenPGP cleartext signed message. /// See RFC 9580, section 7. diff --git a/lib/src/packet/aead_encrypted_data.dart b/lib/src/packet/aead_encrypted_data.dart index 81bb0208..e5820b5a 100644 --- a/lib/src/packet/aead_encrypted_data.dart +++ b/lib/src/packet/aead_encrypted_data.dart @@ -81,7 +81,7 @@ final class AeadEncryptedDataPacket extends BasePacket factory AeadEncryptedDataPacket.encryptPackets( final Uint8List key, final PacketListInterface packets, { - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, final AeadAlgorithm aead = AeadAlgorithm.ocb, final int chunkSize = 12, }) { @@ -117,7 +117,7 @@ final class AeadEncryptedDataPacket extends BasePacket @override decrypt( final Uint8List key, [ - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, ]) { final length = encrypted.length; final data = encrypted.sublist(0, length - aead.tagLength); @@ -147,7 +147,7 @@ final class AeadEncryptedDataPacket extends BasePacket final Uint8List key, final Uint8List data, { final Uint8List? finalChunk, - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, final AeadAlgorithm aead = AeadAlgorithm.ocb, final chunkSizeByte = 0, final Uint8List? iv, diff --git a/lib/src/packet/key/dsa_public_material.dart b/lib/src/packet/key/dsa_public_material.dart index e1b99f13..565513bc 100644 --- a/lib/src/packet/key/dsa_public_material.dart +++ b/lib/src/packet/key/dsa_public_material.dart @@ -5,7 +5,6 @@ library; import 'dart:typed_data'; - import 'package:pointycastle/export.dart'; import '../../common/helpers.dart'; diff --git a/lib/src/packet/key/rsa_secret_material.dart b/lib/src/packet/key/rsa_secret_material.dart index 94c103aa..0637c6df 100644 --- a/lib/src/packet/key/rsa_secret_material.dart +++ b/lib/src/packet/key/rsa_secret_material.dart @@ -5,7 +5,6 @@ library; import 'dart:typed_data'; - import 'package:pointycastle/pointycastle.dart'; import '../../common/helpers.dart'; diff --git a/lib/src/packet/signature.dart b/lib/src/packet/signature.dart index b6728c55..294b8476 100644 --- a/lib/src/packet/signature.dart +++ b/lib/src/packet/signature.dart @@ -501,8 +501,8 @@ final class SignaturePacket extends BasePacket KeyFlag.certifyKeys.value | KeyFlag.signData.value, ), PreferredSymmetricAlgorithms(Uint8List.fromList([ - SymmetricAlgorithm.aes128.value, SymmetricAlgorithm.aes256.value, + SymmetricAlgorithm.aes128.value, ])), PreferredAeadAlgorithms(Uint8List.fromList([ AeadAlgorithm.ocb.value, @@ -529,18 +529,18 @@ final class SignaturePacket extends BasePacket if (version == KeyVersion.v6.value) { subpackets.add(PreferredAeadCiphers(Uint8List.fromList([ ...[ - SymmetricAlgorithm.aes128.value, + SymmetricAlgorithm.aes256.value, AeadAlgorithm.ocb.value, - SymmetricAlgorithm.aes128.value, + SymmetricAlgorithm.aes256.value, AeadAlgorithm.gcm.value, - SymmetricAlgorithm.aes128.value, - AeadAlgorithm.eax.value, ], ...[ - SymmetricAlgorithm.aes256.value, + SymmetricAlgorithm.aes128.value, AeadAlgorithm.ocb.value, - SymmetricAlgorithm.aes256.value, + SymmetricAlgorithm.aes128.value, AeadAlgorithm.gcm.value, + SymmetricAlgorithm.aes128.value, + AeadAlgorithm.eax.value, ], ]))); } diff --git a/lib/src/packet/sym_encrypted_data.dart b/lib/src/packet/sym_encrypted_data.dart index cf3716cc..5426a891 100644 --- a/lib/src/packet/sym_encrypted_data.dart +++ b/lib/src/packet/sym_encrypted_data.dart @@ -70,7 +70,7 @@ final class SymEncryptedDataPacket extends BasePacket @override decrypt( final Uint8List key, [ - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, ]) { if (!Config.allowUnauthenticated) { throw AssertionError( diff --git a/lib/src/packet/sym_encrypted_integrity_protected_data.dart b/lib/src/packet/sym_encrypted_integrity_protected_data.dart index ae3effb0..598c8a6d 100644 --- a/lib/src/packet/sym_encrypted_integrity_protected_data.dart +++ b/lib/src/packet/sym_encrypted_integrity_protected_data.dart @@ -131,7 +131,7 @@ final class SymEncryptedIntegrityProtectedDataPacket extends BasePacket factory SymEncryptedIntegrityProtectedDataPacket.encryptPackets( final Uint8List key, final PacketListInterface packets, { - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, final AeadAlgorithm? aead, }) { Helper.assertSymmetric(symmetric); diff --git a/lib/src/packet/sym_encrypted_session_key.dart b/lib/src/packet/sym_encrypted_session_key.dart index 61949739..cb9361b3 100644 --- a/lib/src/packet/sym_encrypted_session_key.dart +++ b/lib/src/packet/sym_encrypted_session_key.dart @@ -43,7 +43,7 @@ final class SymEncryptedSessionKeyPacket extends BasePacket { this.s2k, this.iv, this.encrypted, { - this.symmetric = SymmetricAlgorithm.aes128, + this.symmetric = SymmetricAlgorithm.aes256, this.aead, this.sessionKey, }) : super(PacketType.symEncryptedSessionKey) { @@ -126,9 +126,9 @@ final class SymEncryptedSessionKeyPacket extends BasePacket { factory SymEncryptedSessionKeyPacket.encryptSessionKey( final String password, { - final SessionKeyInterface? sessionKey, - final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, + final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes256, final AeadAlgorithm? aead, + final SessionKeyInterface? sessionKey, }) { Helper.assertSymmetric(symmetric); diff --git a/lib/src/packet/user_attribute.dart b/lib/src/packet/user_attribute.dart index f0816df9..a8cbdec1 100644 --- a/lib/src/packet/user_attribute.dart +++ b/lib/src/packet/user_attribute.dart @@ -6,8 +6,8 @@ library; import 'dart:typed_data'; -import '../type/user_id_packet.dart'; import '../common/extensions.dart'; +import '../type/user_id_packet.dart'; import 'base_packet.dart'; import 'image_user_attribute.dart'; import 'subpacket_reader.dart';