diff --git a/lib/src/message/literal_message.dart b/lib/src/message/literal_message.dart index 8a1b055c..2d738692 100644 --- a/lib/src/message/literal_message.dart +++ b/lib/src/message/literal_message.dart @@ -145,7 +145,7 @@ final class LiteralMessage extends BaseMessage implements LiteralMessageInterfac [ CompressedDataPacket.fromPacketList( _unwrapCompressed(), - algorithm: algorithm, + algorithm, ) ], ), diff --git a/lib/src/packet/aead_encrypted_data.dart b/lib/src/packet/aead_encrypted_data.dart index 6467b596..52db3d5d 100644 --- a/lib/src/packet/aead_encrypted_data.dart +++ b/lib/src/packet/aead_encrypted_data.dart @@ -147,7 +147,7 @@ class AeadEncryptedDataPacket extends BasePacket implements EncryptedDataPacketI final Uint8List data, { final Uint8List? finalChunk, final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, - AeadAlgorithm aead = AeadAlgorithm.gcm, + final AeadAlgorithm aead = AeadAlgorithm.ocb, final chunkSizeByte = 0, final Uint8List? iv, }) { diff --git a/lib/src/packet/compressed_data.dart b/lib/src/packet/compressed_data.dart index c69ffea8..67062761 100644 --- a/lib/src/packet/compressed_data.dart +++ b/lib/src/packet/compressed_data.dart @@ -45,9 +45,9 @@ class CompressedDataPacket extends BasePacket { } factory CompressedDataPacket.fromPacketList( - final PacketListInterface packets, { + final PacketListInterface packets, [ final CompressionAlgorithm algorithm = CompressionAlgorithm.uncompressed, - }) => + ]) => CompressedDataPacket( _compress(packets, algorithm), packets, diff --git a/lib/src/packet/image_user_attribute.dart b/lib/src/packet/image_user_attribute.dart index cbbb3046..67f40362 100644 --- a/lib/src/packet/image_user_attribute.dart +++ b/lib/src/packet/image_user_attribute.dart @@ -19,9 +19,9 @@ class ImageUserAttribute extends UserAttributeSubpacket { }) : super(jpeg, data); factory ImageUserAttribute.fromBytes( - final Uint8List imageData, { + final Uint8List imageData, [ final int imageType = jpeg, - }) { + ]) { return ImageUserAttribute(Uint8List.fromList([ 0x10, 0x00, diff --git a/lib/src/packet/literal_data.dart b/lib/src/packet/literal_data.dart index e5859426..6e7e03ce 100644 --- a/lib/src/packet/literal_data.dart +++ b/lib/src/packet/literal_data.dart @@ -68,9 +68,9 @@ class LiteralDataPacket extends BasePacket implements LiteralDataInterface { } factory LiteralDataPacket.fromText( - final String text, { + final String text, [ final DateTime? time, - }) => + ]) => LiteralDataPacket( Uint8List(0), text: text, diff --git a/lib/src/packet/one_pass_signature.dart b/lib/src/packet/one_pass_signature.dart index 9f1a7c32..c12eb60e 100644 --- a/lib/src/packet/one_pass_signature.dart +++ b/lib/src/packet/one_pass_signature.dart @@ -46,7 +46,9 @@ class OnePassSignaturePacket extends BasePacket { } } - factory OnePassSignaturePacket.fromBytes(final Uint8List bytes) { + factory OnePassSignaturePacket.fromBytes( + final Uint8List bytes, + ) { var pos = 0; /// A one-octet version number (4 or 6). diff --git a/lib/src/packet/packet_list.dart b/lib/src/packet/packet_list.dart index f7a2fb15..f8e24079 100644 --- a/lib/src/packet/packet_list.dart +++ b/lib/src/packet/packet_list.dart @@ -108,15 +108,15 @@ class PacketList extends ListBase implements PacketListInterfac get length => packets.length; @override - operator [](int index) => packets[index]; + operator [](final int index) => packets[index]; @override - operator []=(int index, PacketInterface packet) { + operator []=(final int index, PacketInterface packet) { packets[index] = packet; } @override - set length(int newLength) { + set length(final int newLength) { packets.length = newLength; } } diff --git a/lib/src/packet/packet_reader.dart b/lib/src/packet/packet_reader.dart index fe9457c3..3b3b9d35 100644 --- a/lib/src/packet/packet_reader.dart +++ b/lib/src/packet/packet_reader.dart @@ -20,7 +20,10 @@ final class PacketReader { PacketReader(this.type, this.data, this.offset); - factory PacketReader.read(final Uint8List bytes, [final int offset = 0]) { + factory PacketReader.read( + final Uint8List bytes, [ + final int offset = 0, + ]) { if (bytes.length <= offset || bytes.sublist(offset).length < 2 || (bytes[offset] & 0x80) == 0) { throw ArgumentError( 'Error during parsing.' diff --git a/lib/src/packet/padding.dart b/lib/src/packet/padding.dart index 15863ada..15d954c4 100644 --- a/lib/src/packet/padding.dart +++ b/lib/src/packet/padding.dart @@ -19,7 +19,7 @@ class PaddingPacket extends BasePacket { PaddingPacket(this.padding) : super(PacketType.marker); - factory PaddingPacket.createPadding(int lengh) { + factory PaddingPacket.createPadding(final int lengh) { assert(paddingMin <= lengh && lengh <= paddingMax); return PaddingPacket(Helper.randomBytes(lengh)); } diff --git a/lib/src/packet/secret_key.dart b/lib/src/packet/secret_key.dart index e2f102e6..7c456483 100644 --- a/lib/src/packet/secret_key.dart +++ b/lib/src/packet/secret_key.dart @@ -79,14 +79,14 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { /// Generate secret key packet factory SecretKeyPacket.generate( final KeyAlgorithm algorithm, { - final RSAKeySize rsaKeySize = RSAKeySize.normal, final Ecc curve = Ecc.secp521r1, + final RSAKeySize rsaKeySize = RSAKeySize.normal, final DateTime? time, }) { final keyMaterial = generateKeyMaterial( algorithm, - rsaKeySize: rsaKeySize, curve: curve, + rsaKeySize: rsaKeySize, ); return SecretKeyPacket( @@ -103,8 +103,8 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { static SecretKeyMaterialInterface generateKeyMaterial( final KeyAlgorithm algorithm, { - final RSAKeySize rsaKeySize = RSAKeySize.normal, final Ecc curve = Ecc.secp521r1, + final RSAKeySize rsaKeySize = RSAKeySize.normal, }) { return switch (algorithm) { KeyAlgorithm.rsaEncryptSign || @@ -353,7 +353,9 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { ); } - SecretKeyMaterialInterface decryptKeyData(final String passphrase) { + SecretKeyMaterialInterface decryptKeyData( + final String passphrase, + ) { final Uint8List clearText; if (isEncrypted) { final kek = _produceEncryptionKey( @@ -566,7 +568,7 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { return keyMaterial; } - static Uint8List _computeChecksum(Uint8List keyData) { + static Uint8List _computeChecksum(final Uint8List keyData) { var sum = 0; for (var i = 0; i < keyData.length; i++) { sum = (sum + keyData[i]) & 0xffff; diff --git a/lib/src/packet/secret_subkey.dart b/lib/src/packet/secret_subkey.dart index 6f7868d9..7af9f9aa 100644 --- a/lib/src/packet/secret_subkey.dart +++ b/lib/src/packet/secret_subkey.dart @@ -55,14 +55,14 @@ class SecretSubkeyPacket extends SecretKeyPacket implements SubkeyPacketInterfac /// Generate secret subkey packet factory SecretSubkeyPacket.generate( final KeyAlgorithm algorithm, { - final RSAKeySize rsaKeySize = RSAKeySize.normal, final Ecc curve = Ecc.secp521r1, + final RSAKeySize rsaKeySize = RSAKeySize.normal, final DateTime? time, }) { final keyMaterial = SecretKeyPacket.generateKeyMaterial( algorithm, - rsaKeySize: rsaKeySize, curve: curve, + rsaKeySize: rsaKeySize, ); return SecretSubkeyPacket( PublicSubkeyPacket( diff --git a/lib/src/packet/signature.dart b/lib/src/packet/signature.dart index 175b7f2d..3fcbf77f 100644 --- a/lib/src/packet/signature.dart +++ b/lib/src/packet/signature.dart @@ -166,9 +166,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { /// Create signature factory SignaturePacket.createSignature( - SecretKeyPacketInterface signKey, - SignatureType signatureType, - Uint8List dataToSign, { + final SecretKeyPacketInterface signKey, + final SignatureType signatureType, + final Uint8List dataToSign, { final HashAlgorithm? preferredHash, final Iterable subpackets = const [], final DateTime? time, @@ -227,9 +227,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { /// Create direct key signature factory SignaturePacket.createDirectKeySignature( - SecretKeyPacketInterface signKey, { - int keyExpiry = 0, - DateTime? time, + final SecretKeyPacketInterface signKey, { + final int keyExpiry = 0, + final DateTime? time, }) { final subpackets = _keySubpackets(signKey.keyVersion); if (keyExpiry > 0) { @@ -246,11 +246,11 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { /// Create self signature factory SignaturePacket.createSelfCertificate( - SecretKeyPacketInterface signKey, - UserIDPacketInterface userID, { - bool isPrimaryUser = false, - int keyExpiry = 0, - DateTime? time, + final SecretKeyPacketInterface signKey, + final UserIDPacketInterface userID, { + final bool isPrimaryUser = false, + final int keyExpiry = 0, + final DateTime? time, }) { final subpackets = signKey.keyVersion == KeyVersion.v4.value ? _keySubpackets( @@ -277,11 +277,11 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { /// Create subkey binding signature factory SignaturePacket.createSubkeyBinding( - SecretKeyPacketInterface signKey, - SubkeyPacketInterface subkey, { - int keyExpiry = 0, - bool forSigning = false, - DateTime? time, + final SecretKeyPacketInterface signKey, + final SubkeyPacketInterface subkey, { + final int keyExpiry = 0, + final bool forSigning = false, + final DateTime? time, }) { final subpackets = []; if (keyExpiry > 0) { @@ -325,11 +325,11 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { /// Create literal data signature factory SignaturePacket.createLiteralData( - SecretKeyPacketInterface signKey, - LiteralDataInterface literalData, { - Iterable recipients = const [], - NotationDataInterface? notationData, - DateTime? time, + final SecretKeyPacketInterface signKey, + final LiteralDataInterface literalData, { + final Iterable recipients = const [], + final NotationDataInterface? notationData, + final DateTime? time, }) { final signatureType = switch (literalData.format) { LiteralFormat.text || LiteralFormat.utf8 => SignatureType.text, @@ -485,7 +485,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { } } - static List _keySubpackets(final int version) { + static List _keySubpackets( + final int version, + ) { final subpackets = [ KeyFlags.fromFlags( KeyFlag.certifyKeys.value | KeyFlag.signData.value, @@ -550,7 +552,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { } } - static List _readSubpackets(final Uint8List bytes) { + static List _readSubpackets( + final Uint8List bytes, + ) { final subpackets = []; var offset = 0; while (offset < bytes.length) { @@ -775,7 +779,7 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { /// Encode subpacket to bytes static Uint8List _encodeSubpackets( final Iterable subpackets, - bool isV6, + final bool isV6, ) { final bytes = subpackets .map( diff --git a/lib/src/packet/sym_encrypted_data.dart b/lib/src/packet/sym_encrypted_data.dart index 623105a5..b4526d22 100644 --- a/lib/src/packet/sym_encrypted_data.dart +++ b/lib/src/packet/sym_encrypted_data.dart @@ -37,9 +37,9 @@ class SymEncryptedDataPacket extends BasePacket implements EncryptedDataPacketIn factory SymEncryptedDataPacket.encryptPackets( final Uint8List key, - final PacketListInterface packets, { + final PacketListInterface packets, [ final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, - }) { + ]) { final cipher = BufferedCipher(symmetric.cfbCipherEngine) ..init( true, diff --git a/lib/src/packet/sym_encrypted_integrity_protected_data.dart b/lib/src/packet/sym_encrypted_integrity_protected_data.dart index ec9e2811..79fe6f15 100644 --- a/lib/src/packet/sym_encrypted_integrity_protected_data.dart +++ b/lib/src/packet/sym_encrypted_integrity_protected_data.dart @@ -262,7 +262,7 @@ class SymEncryptedIntegrityProtectedDataPacket extends BasePacket implements Enc final Uint8List data, { final Uint8List? finalChunk, final SymmetricAlgorithm symmetric = SymmetricAlgorithm.aes128, - final AeadAlgorithm aead = AeadAlgorithm.gcm, + final AeadAlgorithm aead = AeadAlgorithm.ocb, final chunkSizeByte = 0, final Uint8List? salt, }) { diff --git a/lib/src/packet/sym_encrypted_session_key.dart b/lib/src/packet/sym_encrypted_session_key.dart index 3f5f5a1f..27d0d9e1 100644 --- a/lib/src/packet/sym_encrypted_session_key.dart +++ b/lib/src/packet/sym_encrypted_session_key.dart @@ -62,7 +62,9 @@ class SymEncryptedSessionKeyPacket extends BasePacket { } } - factory SymEncryptedSessionKeyPacket.fromBytes(final Uint8List bytes) { + factory SymEncryptedSessionKeyPacket.fromBytes( + final Uint8List bytes, + ) { var pos = 0; /// A one-octet version number. @@ -185,7 +187,7 @@ class SymEncryptedSessionKeyPacket extends BasePacket { iv, encrypted, symmetric: symmetric, - aead: aeadProtect ? aead : null, + aead: aead, sessionKey: sessionKey ?? SessionKey(key, symmetric), ); } diff --git a/lib/src/packet/trust.dart b/lib/src/packet/trust.dart index c87160b9..f2ee76b8 100644 --- a/lib/src/packet/trust.dart +++ b/lib/src/packet/trust.dart @@ -19,9 +19,10 @@ class TrustPacket extends BasePacket { Uint8List.fromList([trustCode & 0xff]), ); - factory TrustPacket.fromBytes(final Uint8List bytes) => TrustPacket.fromTrustCode( - bytes[0], - ); + factory TrustPacket.fromBytes( + final Uint8List bytes, + ) => + TrustPacket.fromTrustCode(bytes[0]); @override get data => levelAndTrustAmount; diff --git a/lib/src/packet/user_attribute.dart b/lib/src/packet/user_attribute.dart index fbf393cd..a3fd4dd2 100644 --- a/lib/src/packet/user_attribute.dart +++ b/lib/src/packet/user_attribute.dart @@ -23,9 +23,7 @@ class UserAttributePacket extends BasePacket implements UserIDPacketInterface { factory UserAttributePacket.fromBytes( final Uint8List bytes, ) => - UserAttributePacket( - _readSubpackets(bytes), - ); + UserAttributePacket(_readSubpackets(bytes)); @override get data => Uint8List.fromList( diff --git a/test/packet/compression_test.dart b/test/packet/compression_test.dart index 3c2f8096..4419cc2c 100644 --- a/test/packet/compression_test.dart +++ b/test/packet/compression_test.dart @@ -12,7 +12,7 @@ void main() { test('zip test', () { final compressedPacket = CompressedDataPacket.fromPacketList( PacketList([literalData]), - algorithm: CompressionAlgorithm.zip, + CompressionAlgorithm.zip, ); final decompressedPacket = CompressedDataPacket.fromBytes( @@ -36,7 +36,7 @@ void main() { test('zlib test', () { final compressedPacket = CompressedDataPacket.fromPacketList( PacketList([literalData]), - algorithm: CompressionAlgorithm.zlib, + CompressionAlgorithm.zlib, ); final decompressedPacket = CompressedDataPacket.fromBytes( @@ -61,7 +61,7 @@ void main() { expect( () => CompressedDataPacket.fromPacketList( PacketList([literalData]), - algorithm: CompressionAlgorithm.bzip2, + CompressionAlgorithm.bzip2, ), throwsUnsupportedError, ); diff --git a/test/packet/encryption_test.dart b/test/packet/encryption_test.dart index f08d1d35..e22741f2 100644 --- a/test/packet/encryption_test.dart +++ b/test/packet/encryption_test.dart @@ -199,7 +199,7 @@ void main() { final encrypted = SymEncryptedDataPacket.encryptPackets( key, packets, - symmetric: SymmetricAlgorithm.aes128, + SymmetricAlgorithm.aes128, ); final encrypt = SymEncryptedDataPacket.fromBytes( encrypted.data,