diff --git a/CHANGELOG.md b/CHANGELOG.md index 129461db..c810e574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,3 +70,6 @@ ## 1.5.5 (2024-12-6) - Fix read public key list ignore last index + +## 2.0.0 (2024-12-11) +- Release to major version 2 diff --git a/lib/src/common/armor.dart b/lib/src/common/armor.dart index 7920499f..3a59d414 100644 --- a/lib/src/common/armor.dart +++ b/lib/src/common/armor.dart @@ -37,7 +37,8 @@ class Armor { static const endOfLine = '-----\n'; static const splitPattern = r'^-----[^-]+-----$'; - static const emptyLinePattern = r'^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$'; + static const emptyLinePattern = + r'^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$'; static const headerPattern = r'^([^\s:]|[^\s:][^:]*[^\s:]): .+$'; static const base64Chunk = 76; @@ -105,7 +106,8 @@ class Armor { final text = textLines.join('\r\n'); final data = base64.decode(dataLines.join().trim()); - if ((checksum != _crc24Checksum(data)) && (checksum.isNotEmpty || Config.checksumRequired)) { + if ((checksum != _crc24Checksum(data)) && + (checksum.isNotEmpty || Config.checksumRequired)) { throw AssertionError('Ascii armor integrity check failed'); } diff --git a/lib/src/common/config.dart b/lib/src/common/config.dart index a55323d1..cb1742a8 100644 --- a/lib/src/common/config.dart +++ b/lib/src/common/config.dart @@ -31,7 +31,8 @@ final class Config { static SymmetricAlgorithm preferredSymmetric = SymmetricAlgorithm.aes128; - static CompressionAlgorithm preferredCompression = CompressionAlgorithm.uncompressed; + static CompressionAlgorithm preferredCompression = + CompressionAlgorithm.uncompressed; static AeadAlgorithm preferredAead = AeadAlgorithm.ocb; } diff --git a/lib/src/common/extensions.dart b/lib/src/common/extensions.dart index 2b6e7027..643ee5d7 100644 --- a/lib/src/common/extensions.dart +++ b/lib/src/common/extensions.dart @@ -25,7 +25,8 @@ extension BigIntExt on BigInt { if (sign > 0) { rawSize = (bitLength + 7) >> 3; - needsPaddingByte = ((this >> (rawSize - 1) * 8) & negativeFlag) == negativeFlag ? 1 : 0; + needsPaddingByte = + ((this >> (rawSize - 1) * 8) & negativeFlag) == negativeFlag ? 1 : 0; } else { needsPaddingByte = 0; rawSize = (bitLength + 8) >> 3; diff --git a/lib/src/cryptor/asymmetric/dsa.dart b/lib/src/cryptor/asymmetric/dsa.dart index 1d0deb5d..678fe97f 100644 --- a/lib/src/cryptor/asymmetric/dsa.dart +++ b/lib/src/cryptor/asymmetric/dsa.dart @@ -60,7 +60,8 @@ class DSASigner implements Signer { @override DSASignature generateSignature(final Uint8List message) { if (!_forSigning) { - throw AssertionError('DSA signer not initialised for signature generation'); + throw AssertionError( + 'DSA signer not initialised for signature generation'); } final pri = _key as DSAPrivateKey; diff --git a/lib/src/cryptor/asymmetric/elgamal.dart b/lib/src/cryptor/asymmetric/elgamal.dart index 49f1b580..145d8383 100644 --- a/lib/src/cryptor/asymmetric/elgamal.dart +++ b/lib/src/cryptor/asymmetric/elgamal.dart @@ -52,11 +52,13 @@ class ElGamalEngine implements AsymmetricBlockCipher { /// Return the maximum size for an input block to this engine. @override - get inputBlockSize => _forEncryption ? (_bitSize - 1) ~/ 8 : 2 * ((_bitSize + 7) >> 3); + get inputBlockSize => + _forEncryption ? (_bitSize - 1) ~/ 8 : 2 * ((_bitSize + 7) >> 3); /// Return the maximum size for an output block to this engine. @override - get outputBlockSize => _forEncryption ? 2 * ((_bitSize + 7) >> 3) : (_bitSize - 1) ~/ 8; + get outputBlockSize => + _forEncryption ? 2 * ((_bitSize + 7) >> 3) : (_bitSize - 1) ~/ 8; @override process(final Uint8List data) { @@ -89,14 +91,17 @@ class ElGamalEngine implements AsymmetricBlockCipher { final phi = input.sublist(inLength ~/ 2).toBigIntWithSign(1); final priv = _key as ElGamalPrivateKey; - final m = (gamma.modPow(prime - (BigInt.one + priv.x), prime) * phi) % prime; + final m = + (gamma.modPow(prime - (BigInt.one + priv.x), prime) * phi) % prime; output.setAll( outOff, m.toUnsignedBytes().sublist(0, output.length - outOff), ); } else { /// encryption - final block = (inOff != 0 || inLength != input.length) ? input.sublist(0, inLength) : input; + final block = (inOff != 0 || inLength != input.length) + ? input.sublist(0, inLength) + : input; final inp = block.toBigIntWithSign(1); if (inp > prime) { diff --git a/lib/src/cryptor/math/fp448.dart b/lib/src/cryptor/math/fp448.dart index c6212d8b..828d44b2 100644 --- a/lib/src/cryptor/math/fp448.dart +++ b/lib/src/cryptor/math/fp448.dart @@ -163,11 +163,14 @@ final class Fp448 { final t7 = y7 + v7; final f0 = x0 * y0; - final f8 = x7 * y1 + x6 * y2 + x5 * y3 + x4 * y4 + x3 * y5 + x2 * y6 + x1 * y7; + final f8 = + x7 * y1 + x6 * y2 + x5 * y3 + x4 * y4 + x3 * y5 + x2 * y6 + x1 * y7; final g0 = u0 * v0; - final g8 = u7 * v1 + u6 * v2 + u5 * v3 + u4 * v4 + u3 * v5 + u2 * v6 + u1 * v7; + final g8 = + u7 * v1 + u6 * v2 + u5 * v3 + u4 * v4 + u3 * v5 + u2 * v6 + u1 * v7; final h0 = s0 * t0; - final h8 = s7 * t1 + s6 * t2 + s5 * t3 + s4 * t4 + s3 * t5 + s2 * t6 + s1 * t7; + final h8 = + s7 * t1 + s6 * t2 + s5 * t3 + s4 * t4 + s3 * t5 + s2 * t6 + s1 * t7; var c = f0 + g0 + h8 - f8; var z0 = c & m28; @@ -246,11 +249,14 @@ final class Fp448 { var z13 = d & m28; d >>>= 28; - final f6 = x6 * y0 + x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + x0 * y6; + final f6 = + x6 * y0 + x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + x0 * y6; final f14 = x7 * y7; - final g6 = u6 * v0 + u5 * v1 + u4 * v2 + u3 * v3 + u2 * v4 + u1 * v5 + u0 * v6; + final g6 = + u6 * v0 + u5 * v1 + u4 * v2 + u3 * v3 + u2 * v4 + u1 * v5 + u0 * v6; final g14 = u7 * v7; - final h6 = s6 * t0 + s5 * t1 + s4 * t2 + s3 * t3 + s2 * t4 + s1 * t5 + s0 * t6; + final h6 = + s6 * t0 + s5 * t1 + s4 * t2 + s3 * t3 + s2 * t4 + s1 * t5 + s0 * t6; final h14 = s7 * t7; c += f6 + g6 + h14 - f14; @@ -260,9 +266,30 @@ final class Fp448 { var z14 = d & m28; d >>>= 28; - final f7 = x7 * y0 + x6 * y1 + x5 * y2 + x4 * y3 + x3 * y4 + x2 * y5 + x1 * y6 + x0 * y7; - final g7 = u7 * v0 + u6 * v1 + u5 * v2 + u4 * v3 + u3 * v4 + u2 * v5 + u1 * v6 + u0 * v7; - final h7 = s7 * t0 + s6 * t1 + s5 * t2 + s4 * t3 + s3 * t4 + s2 * t5 + s1 * t6 + s0 * t7; + final f7 = x7 * y0 + + x6 * y1 + + x5 * y2 + + x4 * y3 + + x3 * y4 + + x2 * y5 + + x1 * y6 + + x0 * y7; + final g7 = u7 * v0 + + u6 * v1 + + u5 * v2 + + u4 * v3 + + u3 * v4 + + u2 * v5 + + u1 * v6 + + u0 * v7; + final h7 = s7 * t0 + + s6 * t1 + + s5 * t2 + + s4 * t3 + + s3 * t4 + + s2 * t5 + + s1 * t6 + + s0 * t7; c += f7 + g7; var z7 = c & m28; diff --git a/lib/src/cryptor/symmetric/blowfish.dart b/lib/src/cryptor/symmetric/blowfish.dart index 97c10e46..54ff69f9 100644 --- a/lib/src/cryptor/symmetric/blowfish.dart +++ b/lib/src/cryptor/symmetric/blowfish.dart @@ -356,7 +356,9 @@ class BlowfishEngine extends BaseEngine { } int _f(final int x) { - return ((_s0[(x >> 24) & 0xff] + _s1[(x >> 16) & 0xff]) ^ _s2[(x >> 8) & 0xff]) + _s3[x & 0xff]; + return ((_s0[(x >> 24) & 0xff] + _s1[(x >> 16) & 0xff]) ^ + _s2[(x >> 8) & 0xff]) + + _s3[x & 0xff]; } /// apply the encryption cycle to each value pair in the table. diff --git a/lib/src/cryptor/symmetric/buffered_cipher.dart b/lib/src/cryptor/symmetric/buffered_cipher.dart index 2af7a09e..8dc36143 100644 --- a/lib/src/cryptor/symmetric/buffered_cipher.dart +++ b/lib/src/cryptor/symmetric/buffered_cipher.dart @@ -155,4 +155,4 @@ class BufferedCipher { _bufOff = 0; _underlyingCipher.reset(); } -} \ No newline at end of file +} diff --git a/lib/src/cryptor/symmetric/camellia.dart b/lib/src/cryptor/symmetric/camellia.dart index ab489c3d..7e848d5c 100644 --- a/lib/src/cryptor/symmetric/camellia.dart +++ b/lib/src/cryptor/symmetric/camellia.dart @@ -278,10 +278,14 @@ class CamelliaEngine extends BaseEngine { List ko, int outOff, ) { - ko[outOff] = _shiftLeft32(ki[inOff], rot) | _shiftRight32(ki[1 + inOff], 32 - rot); - ko[1 + outOff] = _shiftLeft32(ki[1 + inOff], rot) | _shiftRight32(ki[2 + inOff], 32 - rot); - ko[2 + outOff] = _shiftLeft32(ki[2 + inOff], rot) | _shiftRight32(ki[3 + inOff], 32 - rot); - ko[3 + outOff] = _shiftLeft32(ki[3 + inOff], rot) | _shiftRight32(ki[inOff], 32 - rot); + ko[outOff] = + _shiftLeft32(ki[inOff], rot) | _shiftRight32(ki[1 + inOff], 32 - rot); + ko[1 + outOff] = _shiftLeft32(ki[1 + inOff], rot) | + _shiftRight32(ki[2 + inOff], 32 - rot); + ko[2 + outOff] = _shiftLeft32(ki[2 + inOff], rot) | + _shiftRight32(ki[3 + inOff], 32 - rot); + ko[3 + outOff] = + _shiftLeft32(ki[3 + inOff], rot) | _shiftRight32(ki[inOff], 32 - rot); ki[inOff] = ko[outOff]; ki[1 + inOff] = ko[1 + outOff]; ki[2 + inOff] = ko[2 + outOff]; @@ -295,10 +299,14 @@ class CamelliaEngine extends BaseEngine { List ko, int outOff, ) { - ko[2 + outOff] = _shiftLeft32(ki[inOff], rot) | _shiftRight32(ki[1 + inOff], 32 - rot); - ko[3 + outOff] = _shiftLeft32(ki[1 + inOff], rot) | _shiftRight32(ki[2 + inOff], 32 - rot); - ko[outOff] = _shiftLeft32(ki[2 + inOff], rot) | _shiftRight32(ki[3 + inOff], 32 - rot); - ko[1 + outOff] = _shiftLeft32(ki[3 + inOff], rot) | _shiftRight32(ki[inOff], 32 - rot); + ko[2 + outOff] = + _shiftLeft32(ki[inOff], rot) | _shiftRight32(ki[1 + inOff], 32 - rot); + ko[3 + outOff] = _shiftLeft32(ki[1 + inOff], rot) | + _shiftRight32(ki[2 + inOff], 32 - rot); + ko[outOff] = _shiftLeft32(ki[2 + inOff], rot) | + _shiftRight32(ki[3 + inOff], 32 - rot); + ko[1 + outOff] = + _shiftLeft32(ki[3 + inOff], rot) | _shiftRight32(ki[inOff], 32 - rot); ki[inOff] = ko[2 + outOff]; ki[1 + inOff] = ko[3 + outOff]; ki[2 + inOff] = ko[outOff]; @@ -312,10 +320,14 @@ class CamelliaEngine extends BaseEngine { List ko, int outOff, ) { - ko[outOff] = _shiftLeft32(ki[1 + inOff], rot - 32) | _shiftRight32(ki[2 + inOff], 64 - rot); - ko[1 + outOff] = _shiftLeft32(ki[2 + inOff], rot - 32) | _shiftRight32(ki[3 + inOff], 64 - rot); - ko[2 + outOff] = _shiftLeft32(ki[3 + inOff], rot - 32) | _shiftRight32(ki[inOff], 64 - rot); - ko[3 + outOff] = _shiftLeft32(ki[inOff], rot - 32) | _shiftRight32(ki[1 + inOff], 64 - rot); + ko[outOff] = _shiftLeft32(ki[1 + inOff], rot - 32) | + _shiftRight32(ki[2 + inOff], 64 - rot); + ko[1 + outOff] = _shiftLeft32(ki[2 + inOff], rot - 32) | + _shiftRight32(ki[3 + inOff], 64 - rot); + ko[2 + outOff] = _shiftLeft32(ki[3 + inOff], rot - 32) | + _shiftRight32(ki[inOff], 64 - rot); + ko[3 + outOff] = _shiftLeft32(ki[inOff], rot - 32) | + _shiftRight32(ki[1 + inOff], 64 - rot); ki[inOff] = ko[outOff]; ki[1 + inOff] = ko[1 + outOff]; ki[2 + inOff] = ko[2 + outOff]; @@ -329,10 +341,14 @@ class CamelliaEngine extends BaseEngine { List ko, int outOff, ) { - ko[2 + outOff] = _shiftLeft32(ki[1 + inOff], rot - 32) | _shiftRight32(ki[2 + inOff], 64 - rot); - ko[3 + outOff] = _shiftLeft32(ki[2 + inOff], rot - 32) | _shiftRight32(ki[3 + inOff], 64 - rot); - ko[outOff] = _shiftLeft32(ki[3 + inOff], rot - 32) | _shiftRight32(ki[inOff], 64 - rot); - ko[1 + outOff] = _shiftLeft32(ki[inOff], rot - 32) | _shiftRight32(ki[1 + inOff], 64 - rot); + ko[2 + outOff] = _shiftLeft32(ki[1 + inOff], rot - 32) | + _shiftRight32(ki[2 + inOff], 64 - rot); + ko[3 + outOff] = _shiftLeft32(ki[2 + inOff], rot - 32) | + _shiftRight32(ki[3 + inOff], 64 - rot); + ko[outOff] = _shiftLeft32(ki[3 + inOff], rot - 32) | + _shiftRight32(ki[inOff], 64 - rot); + ko[1 + outOff] = _shiftLeft32(ki[inOff], rot - 32) | + _shiftRight32(ki[1 + inOff], 64 - rot); ki[inOff] = ko[2 + outOff]; ki[1 + inOff] = ko[3 + outOff]; ki[2 + inOff] = ko[outOff]; diff --git a/lib/src/cryptor/symmetric/cast5.dart b/lib/src/cryptor/symmetric/cast5.dart index 4aa97be9..d1c12450 100644 --- a/lib/src/cryptor/symmetric/cast5.dart +++ b/lib/src/cryptor/symmetric/cast5.dart @@ -631,137 +631,441 @@ class CAST5Engine extends BaseEngine { var x47 = _intsTo32bits(x, 0x4); var x8B = _intsTo32bits(x, 0x8); var xCF = _intsTo32bits(x, 0xc); - var z03 = x03 ^ _sBox5[x[0xd]] ^ _sBox6[x[0xf]] ^ _sBox7[x[0xc]] ^ _sBox8[x[0xe]] ^ _sBox7[x[0x8]]; + var z03 = x03 ^ + _sBox5[x[0xd]] ^ + _sBox6[x[0xf]] ^ + _sBox7[x[0xc]] ^ + _sBox8[x[0xe]] ^ + _sBox7[x[0x8]]; _bits32ToInts(z03, z, 0x0); - var z47 = x8B ^ _sBox5[z[0x0]] ^ _sBox6[z[0x2]] ^ _sBox7[z[0x1]] ^ _sBox8[z[0x3]] ^ _sBox8[x[0xa]]; + var z47 = x8B ^ + _sBox5[z[0x0]] ^ + _sBox6[z[0x2]] ^ + _sBox7[z[0x1]] ^ + _sBox8[z[0x3]] ^ + _sBox8[x[0xa]]; _bits32ToInts(z47, z, 0x4); - var z8B = xCF ^ _sBox5[z[0x7]] ^ _sBox6[z[0x6]] ^ _sBox7[z[0x5]] ^ _sBox8[z[0x4]] ^ _sBox5[x[0x9]]; + var z8B = xCF ^ + _sBox5[z[0x7]] ^ + _sBox6[z[0x6]] ^ + _sBox7[z[0x5]] ^ + _sBox8[z[0x4]] ^ + _sBox5[x[0x9]]; _bits32ToInts(z8B, z, 0x8); - var zCF = x47 ^ _sBox5[z[0xa]] ^ _sBox6[z[0x9]] ^ _sBox7[z[0xb]] ^ _sBox8[z[0x8]] ^ _sBox6[x[0xb]]; + var zCF = x47 ^ + _sBox5[z[0xa]] ^ + _sBox6[z[0x9]] ^ + _sBox7[z[0xb]] ^ + _sBox8[z[0x8]] ^ + _sBox6[x[0xb]]; _bits32ToInts(zCF, z, 0xc); - _masking[1] = _sBox5[z[0x8]] ^ _sBox6[z[0x9]] ^ _sBox7[z[0x7]] ^ _sBox8[z[0x6]] ^ _sBox5[z[0x2]]; - _masking[2] = _sBox5[z[0xa]] ^ _sBox6[z[0xb]] ^ _sBox7[z[0x5]] ^ _sBox8[z[0x4]] ^ _sBox6[z[0x6]]; - _masking[3] = _sBox5[z[0xc]] ^ _sBox6[z[0xd]] ^ _sBox7[z[0x3]] ^ _sBox8[z[0x2]] ^ _sBox7[z[0x9]]; - _masking[4] = _sBox5[z[0xe]] ^ _sBox6[z[0xf]] ^ _sBox7[z[0x1]] ^ _sBox8[z[0x0]] ^ _sBox8[z[0xc]]; + _masking[1] = _sBox5[z[0x8]] ^ + _sBox6[z[0x9]] ^ + _sBox7[z[0x7]] ^ + _sBox8[z[0x6]] ^ + _sBox5[z[0x2]]; + _masking[2] = _sBox5[z[0xa]] ^ + _sBox6[z[0xb]] ^ + _sBox7[z[0x5]] ^ + _sBox8[z[0x4]] ^ + _sBox6[z[0x6]]; + _masking[3] = _sBox5[z[0xc]] ^ + _sBox6[z[0xd]] ^ + _sBox7[z[0x3]] ^ + _sBox8[z[0x2]] ^ + _sBox7[z[0x9]]; + _masking[4] = _sBox5[z[0xe]] ^ + _sBox6[z[0xf]] ^ + _sBox7[z[0x1]] ^ + _sBox8[z[0x0]] ^ + _sBox8[z[0xc]]; z03 = _intsTo32bits(z, 0x0); z47 = _intsTo32bits(z, 0x4); z8B = _intsTo32bits(z, 0x8); zCF = _intsTo32bits(z, 0xc); - x03 = z8B ^ _sBox5[z[0x5]] ^ _sBox6[z[0x7]] ^ _sBox7[z[0x4]] ^ _sBox8[z[0x6]] ^ _sBox7[z[0x0]]; + x03 = z8B ^ + _sBox5[z[0x5]] ^ + _sBox6[z[0x7]] ^ + _sBox7[z[0x4]] ^ + _sBox8[z[0x6]] ^ + _sBox7[z[0x0]]; _bits32ToInts(x03, x, 0x0); - x47 = z03 ^ _sBox5[x[0x0]] ^ _sBox6[x[0x2]] ^ _sBox7[x[0x1]] ^ _sBox8[x[0x3]] ^ _sBox8[z[0x2]]; + x47 = z03 ^ + _sBox5[x[0x0]] ^ + _sBox6[x[0x2]] ^ + _sBox7[x[0x1]] ^ + _sBox8[x[0x3]] ^ + _sBox8[z[0x2]]; _bits32ToInts(x47, x, 0x4); - x8B = z47 ^ _sBox5[x[0x7]] ^ _sBox6[x[0x6]] ^ _sBox7[x[0x5]] ^ _sBox8[x[0x4]] ^ _sBox5[z[0x1]]; + x8B = z47 ^ + _sBox5[x[0x7]] ^ + _sBox6[x[0x6]] ^ + _sBox7[x[0x5]] ^ + _sBox8[x[0x4]] ^ + _sBox5[z[0x1]]; _bits32ToInts(x8B, x, 0x8); - xCF = zCF ^ _sBox5[x[0xa]] ^ _sBox6[x[0x9]] ^ _sBox7[x[0xb]] ^ _sBox8[x[0x8]] ^ _sBox6[z[0x3]]; + xCF = zCF ^ + _sBox5[x[0xa]] ^ + _sBox6[x[0x9]] ^ + _sBox7[x[0xb]] ^ + _sBox8[x[0x8]] ^ + _sBox6[z[0x3]]; _bits32ToInts(xCF, x, 0xc); - _masking[5] = _sBox5[x[0x3]] ^ _sBox6[x[0x2]] ^ _sBox7[x[0xc]] ^ _sBox8[x[0xd]] ^ _sBox5[x[0x8]]; - _masking[6] = _sBox5[x[0x1]] ^ _sBox6[x[0x0]] ^ _sBox7[x[0xe]] ^ _sBox8[x[0xf]] ^ _sBox6[x[0xd]]; - _masking[7] = _sBox5[x[0x7]] ^ _sBox6[x[0x6]] ^ _sBox7[x[0x8]] ^ _sBox8[x[0x9]] ^ _sBox7[x[0x3]]; - _masking[8] = _sBox5[x[0x5]] ^ _sBox6[x[0x4]] ^ _sBox7[x[0xa]] ^ _sBox8[x[0xb]] ^ _sBox8[x[0x7]]; + _masking[5] = _sBox5[x[0x3]] ^ + _sBox6[x[0x2]] ^ + _sBox7[x[0xc]] ^ + _sBox8[x[0xd]] ^ + _sBox5[x[0x8]]; + _masking[6] = _sBox5[x[0x1]] ^ + _sBox6[x[0x0]] ^ + _sBox7[x[0xe]] ^ + _sBox8[x[0xf]] ^ + _sBox6[x[0xd]]; + _masking[7] = _sBox5[x[0x7]] ^ + _sBox6[x[0x6]] ^ + _sBox7[x[0x8]] ^ + _sBox8[x[0x9]] ^ + _sBox7[x[0x3]]; + _masking[8] = _sBox5[x[0x5]] ^ + _sBox6[x[0x4]] ^ + _sBox7[x[0xa]] ^ + _sBox8[x[0xb]] ^ + _sBox8[x[0x7]]; x03 = _intsTo32bits(x, 0x0); x47 = _intsTo32bits(x, 0x4); x8B = _intsTo32bits(x, 0x8); xCF = _intsTo32bits(x, 0xc); - z03 = x03 ^ _sBox5[x[0xd]] ^ _sBox6[x[0xf]] ^ _sBox7[x[0xc]] ^ _sBox8[x[0xe]] ^ _sBox7[x[0x8]]; + z03 = x03 ^ + _sBox5[x[0xd]] ^ + _sBox6[x[0xf]] ^ + _sBox7[x[0xc]] ^ + _sBox8[x[0xe]] ^ + _sBox7[x[0x8]]; _bits32ToInts(z03, z, 0x0); - z47 = x8B ^ _sBox5[z[0x0]] ^ _sBox6[z[0x2]] ^ _sBox7[z[0x1]] ^ _sBox8[z[0x3]] ^ _sBox8[x[0xa]]; + z47 = x8B ^ + _sBox5[z[0x0]] ^ + _sBox6[z[0x2]] ^ + _sBox7[z[0x1]] ^ + _sBox8[z[0x3]] ^ + _sBox8[x[0xa]]; _bits32ToInts(z47, z, 0x4); - z8B = xCF ^ _sBox5[z[0x7]] ^ _sBox6[z[0x6]] ^ _sBox7[z[0x5]] ^ _sBox8[z[0x4]] ^ _sBox5[x[0x9]]; + z8B = xCF ^ + _sBox5[z[0x7]] ^ + _sBox6[z[0x6]] ^ + _sBox7[z[0x5]] ^ + _sBox8[z[0x4]] ^ + _sBox5[x[0x9]]; _bits32ToInts(z8B, z, 0x8); - zCF = x47 ^ _sBox5[z[0xa]] ^ _sBox6[z[0x9]] ^ _sBox7[z[0xb]] ^ _sBox8[z[0x8]] ^ _sBox6[x[0xb]]; + zCF = x47 ^ + _sBox5[z[0xa]] ^ + _sBox6[z[0x9]] ^ + _sBox7[z[0xb]] ^ + _sBox8[z[0x8]] ^ + _sBox6[x[0xb]]; _bits32ToInts(zCF, z, 0xc); - _masking[9] = _sBox5[z[0x3]] ^ _sBox6[z[0x2]] ^ _sBox7[z[0xc]] ^ _sBox8[z[0xd]] ^ _sBox5[z[0x9]]; - _masking[10] = _sBox5[z[0x1]] ^ _sBox6[z[0x0]] ^ _sBox7[z[0xe]] ^ _sBox8[z[0xf]] ^ _sBox6[z[0xc]]; - _masking[11] = _sBox5[z[0x7]] ^ _sBox6[z[0x6]] ^ _sBox7[z[0x8]] ^ _sBox8[z[0x9]] ^ _sBox7[z[0x2]]; - _masking[12] = _sBox5[z[0x5]] ^ _sBox6[z[0x4]] ^ _sBox7[z[0xa]] ^ _sBox8[z[0xb]] ^ _sBox8[z[0x6]]; + _masking[9] = _sBox5[z[0x3]] ^ + _sBox6[z[0x2]] ^ + _sBox7[z[0xc]] ^ + _sBox8[z[0xd]] ^ + _sBox5[z[0x9]]; + _masking[10] = _sBox5[z[0x1]] ^ + _sBox6[z[0x0]] ^ + _sBox7[z[0xe]] ^ + _sBox8[z[0xf]] ^ + _sBox6[z[0xc]]; + _masking[11] = _sBox5[z[0x7]] ^ + _sBox6[z[0x6]] ^ + _sBox7[z[0x8]] ^ + _sBox8[z[0x9]] ^ + _sBox7[z[0x2]]; + _masking[12] = _sBox5[z[0x5]] ^ + _sBox6[z[0x4]] ^ + _sBox7[z[0xa]] ^ + _sBox8[z[0xb]] ^ + _sBox8[z[0x6]]; z03 = _intsTo32bits(z, 0x0); z47 = _intsTo32bits(z, 0x4); z8B = _intsTo32bits(z, 0x8); zCF = _intsTo32bits(z, 0xc); - x03 = z8B ^ _sBox5[z[0x5]] ^ _sBox6[z[0x7]] ^ _sBox7[z[0x4]] ^ _sBox8[z[0x6]] ^ _sBox7[z[0x0]]; + x03 = z8B ^ + _sBox5[z[0x5]] ^ + _sBox6[z[0x7]] ^ + _sBox7[z[0x4]] ^ + _sBox8[z[0x6]] ^ + _sBox7[z[0x0]]; _bits32ToInts(x03, x, 0x0); - x47 = z03 ^ _sBox5[x[0x0]] ^ _sBox6[x[0x2]] ^ _sBox7[x[0x1]] ^ _sBox8[x[0x3]] ^ _sBox8[z[0x2]]; + x47 = z03 ^ + _sBox5[x[0x0]] ^ + _sBox6[x[0x2]] ^ + _sBox7[x[0x1]] ^ + _sBox8[x[0x3]] ^ + _sBox8[z[0x2]]; _bits32ToInts(x47, x, 0x4); - x8B = z47 ^ _sBox5[x[0x7]] ^ _sBox6[x[0x6]] ^ _sBox7[x[0x5]] ^ _sBox8[x[0x4]] ^ _sBox5[z[0x1]]; + x8B = z47 ^ + _sBox5[x[0x7]] ^ + _sBox6[x[0x6]] ^ + _sBox7[x[0x5]] ^ + _sBox8[x[0x4]] ^ + _sBox5[z[0x1]]; _bits32ToInts(x8B, x, 0x8); - xCF = zCF ^ _sBox5[x[0xa]] ^ _sBox6[x[0x9]] ^ _sBox7[x[0xb]] ^ _sBox8[x[0x8]] ^ _sBox6[z[0x3]]; + xCF = zCF ^ + _sBox5[x[0xa]] ^ + _sBox6[x[0x9]] ^ + _sBox7[x[0xb]] ^ + _sBox8[x[0x8]] ^ + _sBox6[z[0x3]]; _bits32ToInts(xCF, x, 0xc); - _masking[13] = _sBox5[x[0x8]] ^ _sBox6[x[0x9]] ^ _sBox7[x[0x7]] ^ _sBox8[x[0x6]] ^ _sBox5[x[0x3]]; - _masking[14] = _sBox5[x[0xa]] ^ _sBox6[x[0xb]] ^ _sBox7[x[0x5]] ^ _sBox8[x[0x4]] ^ _sBox6[x[0x7]]; - _masking[15] = _sBox5[x[0xc]] ^ _sBox6[x[0xd]] ^ _sBox7[x[0x3]] ^ _sBox8[x[0x2]] ^ _sBox7[x[0x8]]; - _masking[16] = _sBox5[x[0xe]] ^ _sBox6[x[0xf]] ^ _sBox7[x[0x1]] ^ _sBox8[x[0x0]] ^ _sBox8[x[0xd]]; + _masking[13] = _sBox5[x[0x8]] ^ + _sBox6[x[0x9]] ^ + _sBox7[x[0x7]] ^ + _sBox8[x[0x6]] ^ + _sBox5[x[0x3]]; + _masking[14] = _sBox5[x[0xa]] ^ + _sBox6[x[0xb]] ^ + _sBox7[x[0x5]] ^ + _sBox8[x[0x4]] ^ + _sBox6[x[0x7]]; + _masking[15] = _sBox5[x[0xc]] ^ + _sBox6[x[0xd]] ^ + _sBox7[x[0x3]] ^ + _sBox8[x[0x2]] ^ + _sBox7[x[0x8]]; + _masking[16] = _sBox5[x[0xe]] ^ + _sBox6[x[0xf]] ^ + _sBox7[x[0x1]] ^ + _sBox8[x[0x0]] ^ + _sBox8[x[0xd]]; x03 = _intsTo32bits(x, 0x0); x47 = _intsTo32bits(x, 0x4); x8B = _intsTo32bits(x, 0x8); xCF = _intsTo32bits(x, 0xc); - z03 = x03 ^ _sBox5[x[0xd]] ^ _sBox6[x[0xf]] ^ _sBox7[x[0xc]] ^ _sBox8[x[0xe]] ^ _sBox7[x[0x8]]; + z03 = x03 ^ + _sBox5[x[0xd]] ^ + _sBox6[x[0xf]] ^ + _sBox7[x[0xc]] ^ + _sBox8[x[0xe]] ^ + _sBox7[x[0x8]]; _bits32ToInts(z03, z, 0x0); - z47 = x8B ^ _sBox5[z[0x0]] ^ _sBox6[z[0x2]] ^ _sBox7[z[0x1]] ^ _sBox8[z[0x3]] ^ _sBox8[x[0xa]]; + z47 = x8B ^ + _sBox5[z[0x0]] ^ + _sBox6[z[0x2]] ^ + _sBox7[z[0x1]] ^ + _sBox8[z[0x3]] ^ + _sBox8[x[0xa]]; _bits32ToInts(z47, z, 0x4); - z8B = xCF ^ _sBox5[z[0x7]] ^ _sBox6[z[0x6]] ^ _sBox7[z[0x5]] ^ _sBox8[z[0x4]] ^ _sBox5[x[0x9]]; + z8B = xCF ^ + _sBox5[z[0x7]] ^ + _sBox6[z[0x6]] ^ + _sBox7[z[0x5]] ^ + _sBox8[z[0x4]] ^ + _sBox5[x[0x9]]; _bits32ToInts(z8B, z, 0x8); - zCF = x47 ^ _sBox5[z[0xa]] ^ _sBox6[z[0x9]] ^ _sBox7[z[0xb]] ^ _sBox8[z[0x8]] ^ _sBox6[x[0xb]]; + zCF = x47 ^ + _sBox5[z[0xa]] ^ + _sBox6[z[0x9]] ^ + _sBox7[z[0xb]] ^ + _sBox8[z[0x8]] ^ + _sBox6[x[0xb]]; _bits32ToInts(zCF, z, 0xc); - _rotating[1] = (_sBox5[z[0x8]] ^ _sBox6[z[0x9]] ^ _sBox7[z[0x7]] ^ _sBox8[z[0x6]] ^ _sBox5[z[0x2]]) & 0x1f; - _rotating[2] = (_sBox5[z[0xa]] ^ _sBox6[z[0xb]] ^ _sBox7[z[0x5]] ^ _sBox8[z[0x4]] ^ _sBox6[z[0x6]]) & 0x1f; - _rotating[3] = (_sBox5[z[0xc]] ^ _sBox6[z[0xd]] ^ _sBox7[z[0x3]] ^ _sBox8[z[0x2]] ^ _sBox7[z[0x9]]) & 0x1f; - _rotating[4] = (_sBox5[z[0xe]] ^ _sBox6[z[0xf]] ^ _sBox7[z[0x1]] ^ _sBox8[z[0x0]] ^ _sBox8[z[0xc]]) & 0x1f; + _rotating[1] = (_sBox5[z[0x8]] ^ + _sBox6[z[0x9]] ^ + _sBox7[z[0x7]] ^ + _sBox8[z[0x6]] ^ + _sBox5[z[0x2]]) & + 0x1f; + _rotating[2] = (_sBox5[z[0xa]] ^ + _sBox6[z[0xb]] ^ + _sBox7[z[0x5]] ^ + _sBox8[z[0x4]] ^ + _sBox6[z[0x6]]) & + 0x1f; + _rotating[3] = (_sBox5[z[0xc]] ^ + _sBox6[z[0xd]] ^ + _sBox7[z[0x3]] ^ + _sBox8[z[0x2]] ^ + _sBox7[z[0x9]]) & + 0x1f; + _rotating[4] = (_sBox5[z[0xe]] ^ + _sBox6[z[0xf]] ^ + _sBox7[z[0x1]] ^ + _sBox8[z[0x0]] ^ + _sBox8[z[0xc]]) & + 0x1f; z03 = _intsTo32bits(z, 0x0); z47 = _intsTo32bits(z, 0x4); z8B = _intsTo32bits(z, 0x8); zCF = _intsTo32bits(z, 0xc); - x03 = z8B ^ _sBox5[z[0x5]] ^ _sBox6[z[0x7]] ^ _sBox7[z[0x4]] ^ _sBox8[z[0x6]] ^ _sBox7[z[0x0]]; + x03 = z8B ^ + _sBox5[z[0x5]] ^ + _sBox6[z[0x7]] ^ + _sBox7[z[0x4]] ^ + _sBox8[z[0x6]] ^ + _sBox7[z[0x0]]; _bits32ToInts(x03, x, 0x0); - x47 = z03 ^ _sBox5[x[0x0]] ^ _sBox6[x[0x2]] ^ _sBox7[x[0x1]] ^ _sBox8[x[0x3]] ^ _sBox8[z[0x2]]; + x47 = z03 ^ + _sBox5[x[0x0]] ^ + _sBox6[x[0x2]] ^ + _sBox7[x[0x1]] ^ + _sBox8[x[0x3]] ^ + _sBox8[z[0x2]]; _bits32ToInts(x47, x, 0x4); - x8B = z47 ^ _sBox5[x[0x7]] ^ _sBox6[x[0x6]] ^ _sBox7[x[0x5]] ^ _sBox8[x[0x4]] ^ _sBox5[z[0x1]]; + x8B = z47 ^ + _sBox5[x[0x7]] ^ + _sBox6[x[0x6]] ^ + _sBox7[x[0x5]] ^ + _sBox8[x[0x4]] ^ + _sBox5[z[0x1]]; _bits32ToInts(x8B, x, 0x8); - xCF = zCF ^ _sBox5[x[0xa]] ^ _sBox6[x[0x9]] ^ _sBox7[x[0xb]] ^ _sBox8[x[0x8]] ^ _sBox6[z[0x3]]; + xCF = zCF ^ + _sBox5[x[0xa]] ^ + _sBox6[x[0x9]] ^ + _sBox7[x[0xb]] ^ + _sBox8[x[0x8]] ^ + _sBox6[z[0x3]]; _bits32ToInts(xCF, x, 0xc); - _rotating[5] = (_sBox5[x[0x3]] ^ _sBox6[x[0x2]] ^ _sBox7[x[0xc]] ^ _sBox8[x[0xd]] ^ _sBox5[x[0x8]]) & 0x1f; - _rotating[6] = (_sBox5[x[0x1]] ^ _sBox6[x[0x0]] ^ _sBox7[x[0xe]] ^ _sBox8[x[0xf]] ^ _sBox6[x[0xd]]) & 0x1f; - _rotating[7] = (_sBox5[x[0x7]] ^ _sBox6[x[0x6]] ^ _sBox7[x[0x8]] ^ _sBox8[x[0x9]] ^ _sBox7[x[0x3]]) & 0x1f; - _rotating[8] = (_sBox5[x[0x5]] ^ _sBox6[x[0x4]] ^ _sBox7[x[0xa]] ^ _sBox8[x[0xb]] ^ _sBox8[x[0x7]]) & 0x1f; + _rotating[5] = (_sBox5[x[0x3]] ^ + _sBox6[x[0x2]] ^ + _sBox7[x[0xc]] ^ + _sBox8[x[0xd]] ^ + _sBox5[x[0x8]]) & + 0x1f; + _rotating[6] = (_sBox5[x[0x1]] ^ + _sBox6[x[0x0]] ^ + _sBox7[x[0xe]] ^ + _sBox8[x[0xf]] ^ + _sBox6[x[0xd]]) & + 0x1f; + _rotating[7] = (_sBox5[x[0x7]] ^ + _sBox6[x[0x6]] ^ + _sBox7[x[0x8]] ^ + _sBox8[x[0x9]] ^ + _sBox7[x[0x3]]) & + 0x1f; + _rotating[8] = (_sBox5[x[0x5]] ^ + _sBox6[x[0x4]] ^ + _sBox7[x[0xa]] ^ + _sBox8[x[0xb]] ^ + _sBox8[x[0x7]]) & + 0x1f; x03 = _intsTo32bits(x, 0x0); x47 = _intsTo32bits(x, 0x4); x8B = _intsTo32bits(x, 0x8); xCF = _intsTo32bits(x, 0xc); - z03 = x03 ^ _sBox5[x[0xd]] ^ _sBox6[x[0xf]] ^ _sBox7[x[0xc]] ^ _sBox8[x[0xe]] ^ _sBox7[x[0x8]]; + z03 = x03 ^ + _sBox5[x[0xd]] ^ + _sBox6[x[0xf]] ^ + _sBox7[x[0xc]] ^ + _sBox8[x[0xe]] ^ + _sBox7[x[0x8]]; _bits32ToInts(z03, z, 0x0); - z47 = x8B ^ _sBox5[z[0x0]] ^ _sBox6[z[0x2]] ^ _sBox7[z[0x1]] ^ _sBox8[z[0x3]] ^ _sBox8[x[0xa]]; + z47 = x8B ^ + _sBox5[z[0x0]] ^ + _sBox6[z[0x2]] ^ + _sBox7[z[0x1]] ^ + _sBox8[z[0x3]] ^ + _sBox8[x[0xa]]; _bits32ToInts(z47, z, 0x4); - z8B = xCF ^ _sBox5[z[0x7]] ^ _sBox6[z[0x6]] ^ _sBox7[z[0x5]] ^ _sBox8[z[0x4]] ^ _sBox5[x[0x9]]; + z8B = xCF ^ + _sBox5[z[0x7]] ^ + _sBox6[z[0x6]] ^ + _sBox7[z[0x5]] ^ + _sBox8[z[0x4]] ^ + _sBox5[x[0x9]]; _bits32ToInts(z8B, z, 0x8); - zCF = x47 ^ _sBox5[z[0xa]] ^ _sBox6[z[0x9]] ^ _sBox7[z[0xb]] ^ _sBox8[z[0x8]] ^ _sBox6[x[0xb]]; + zCF = x47 ^ + _sBox5[z[0xa]] ^ + _sBox6[z[0x9]] ^ + _sBox7[z[0xb]] ^ + _sBox8[z[0x8]] ^ + _sBox6[x[0xb]]; _bits32ToInts(zCF, z, 0xc); - _rotating[9] = (_sBox5[z[0x3]] ^ _sBox6[z[0x2]] ^ _sBox7[z[0xc]] ^ _sBox8[z[0xd]] ^ _sBox5[z[0x9]]) & 0x1f; - _rotating[10] = (_sBox5[z[0x1]] ^ _sBox6[z[0x0]] ^ _sBox7[z[0xe]] ^ _sBox8[z[0xf]] ^ _sBox6[z[0xc]]) & 0x1f; - _rotating[11] = (_sBox5[z[0x7]] ^ _sBox6[z[0x6]] ^ _sBox7[z[0x8]] ^ _sBox8[z[0x9]] ^ _sBox7[z[0x2]]) & 0x1f; - _rotating[12] = (_sBox5[z[0x5]] ^ _sBox6[z[0x4]] ^ _sBox7[z[0xa]] ^ _sBox8[z[0xb]] ^ _sBox8[z[0x6]]) & 0x1f; + _rotating[9] = (_sBox5[z[0x3]] ^ + _sBox6[z[0x2]] ^ + _sBox7[z[0xc]] ^ + _sBox8[z[0xd]] ^ + _sBox5[z[0x9]]) & + 0x1f; + _rotating[10] = (_sBox5[z[0x1]] ^ + _sBox6[z[0x0]] ^ + _sBox7[z[0xe]] ^ + _sBox8[z[0xf]] ^ + _sBox6[z[0xc]]) & + 0x1f; + _rotating[11] = (_sBox5[z[0x7]] ^ + _sBox6[z[0x6]] ^ + _sBox7[z[0x8]] ^ + _sBox8[z[0x9]] ^ + _sBox7[z[0x2]]) & + 0x1f; + _rotating[12] = (_sBox5[z[0x5]] ^ + _sBox6[z[0x4]] ^ + _sBox7[z[0xa]] ^ + _sBox8[z[0xb]] ^ + _sBox8[z[0x6]]) & + 0x1f; z03 = _intsTo32bits(z, 0x0); z47 = _intsTo32bits(z, 0x4); z8B = _intsTo32bits(z, 0x8); zCF = _intsTo32bits(z, 0xc); - x03 = z8B ^ _sBox5[z[0x5]] ^ _sBox6[z[0x7]] ^ _sBox7[z[0x4]] ^ _sBox8[z[0x6]] ^ _sBox7[z[0x0]]; + x03 = z8B ^ + _sBox5[z[0x5]] ^ + _sBox6[z[0x7]] ^ + _sBox7[z[0x4]] ^ + _sBox8[z[0x6]] ^ + _sBox7[z[0x0]]; _bits32ToInts(x03, x, 0x0); - x47 = z03 ^ _sBox5[x[0x0]] ^ _sBox6[x[0x2]] ^ _sBox7[x[0x1]] ^ _sBox8[x[0x3]] ^ _sBox8[z[0x2]]; + x47 = z03 ^ + _sBox5[x[0x0]] ^ + _sBox6[x[0x2]] ^ + _sBox7[x[0x1]] ^ + _sBox8[x[0x3]] ^ + _sBox8[z[0x2]]; _bits32ToInts(x47, x, 0x4); - x8B = z47 ^ _sBox5[x[0x7]] ^ _sBox6[x[0x6]] ^ _sBox7[x[0x5]] ^ _sBox8[x[0x4]] ^ _sBox5[z[0x1]]; + x8B = z47 ^ + _sBox5[x[0x7]] ^ + _sBox6[x[0x6]] ^ + _sBox7[x[0x5]] ^ + _sBox8[x[0x4]] ^ + _sBox5[z[0x1]]; _bits32ToInts(x8B, x, 0x8); - xCF = zCF ^ _sBox5[x[0xa]] ^ _sBox6[x[0x9]] ^ _sBox7[x[0xb]] ^ _sBox8[x[0x8]] ^ _sBox6[z[0x3]]; + xCF = zCF ^ + _sBox5[x[0xa]] ^ + _sBox6[x[0x9]] ^ + _sBox7[x[0xb]] ^ + _sBox8[x[0x8]] ^ + _sBox6[z[0x3]]; _bits32ToInts(xCF, x, 0xc); - _rotating[13] = (_sBox5[x[0x8]] ^ _sBox6[x[0x9]] ^ _sBox7[x[0x7]] ^ _sBox8[x[0x6]] ^ _sBox5[x[0x3]]) & 0x1f; - _rotating[14] = (_sBox5[x[0xa]] ^ _sBox6[x[0xb]] ^ _sBox7[x[0x5]] ^ _sBox8[x[0x4]] ^ _sBox6[x[0x7]]) & 0x1f; - _rotating[15] = (_sBox5[x[0xc]] ^ _sBox6[x[0xd]] ^ _sBox7[x[0x3]] ^ _sBox8[x[0x2]] ^ _sBox7[x[0x8]]) & 0x1f; - _rotating[16] = (_sBox5[x[0xe]] ^ _sBox6[x[0xf]] ^ _sBox7[x[0x1]] ^ _sBox8[x[0x0]] ^ _sBox8[x[0xd]]) & 0x1f; + _rotating[13] = (_sBox5[x[0x8]] ^ + _sBox6[x[0x9]] ^ + _sBox7[x[0x7]] ^ + _sBox8[x[0x6]] ^ + _sBox5[x[0x3]]) & + 0x1f; + _rotating[14] = (_sBox5[x[0xa]] ^ + _sBox6[x[0xb]] ^ + _sBox7[x[0x5]] ^ + _sBox8[x[0x4]] ^ + _sBox6[x[0x7]]) & + 0x1f; + _rotating[15] = (_sBox5[x[0xc]] ^ + _sBox6[x[0xd]] ^ + _sBox7[x[0x3]] ^ + _sBox8[x[0x2]] ^ + _sBox7[x[0x8]]) & + 0x1f; + _rotating[16] = (_sBox5[x[0xe]] ^ + _sBox6[x[0xf]] ^ + _sBox7[x[0x1]] ^ + _sBox8[x[0x0]] ^ + _sBox8[x[0xd]]) & + 0x1f; } int _encryptBlock( @@ -808,19 +1112,25 @@ class CAST5Engine extends BaseEngine { int _f1(final int d, final int kmi, final int kri) { var i = kmi + d; i = _rotateLeft32(i, kri); - return ((_sBox1[(i >> 24) & 0xff] ^ _sBox2[(i >> 16) & 0xff]) - _sBox3[(i >> 8) & 0xff]) + _sBox4[i & 0xff]; + return ((_sBox1[(i >> 24) & 0xff] ^ _sBox2[(i >> 16) & 0xff]) - + _sBox3[(i >> 8) & 0xff]) + + _sBox4[i & 0xff]; } int _f2(final int d, final int kmi, final int kri) { var i = kmi ^ d; i = _rotateLeft32(i, kri); - return ((_sBox1[(i >> 24) & 0xff] - _sBox2[(i >> 16) & 0xff]) + _sBox3[(i >> 8) & 0xff]) ^ _sBox4[i & 0xff]; + return ((_sBox1[(i >> 24) & 0xff] - _sBox2[(i >> 16) & 0xff]) + + _sBox3[(i >> 8) & 0xff]) ^ + _sBox4[i & 0xff]; } int _f3(final int d, final int kmi, final int kri) { var i = kmi - d; i = _rotateLeft32(i, kri); - return ((_sBox1[(i >> 24) & 0xff] + _sBox2[(i >> 16) & 0xff]) ^ _sBox3[(i >> 8) & 0xff]) - _sBox4[i & 0xff]; + return ((_sBox1[(i >> 24) & 0xff] + _sBox2[(i >> 16) & 0xff]) ^ + _sBox3[(i >> 8) & 0xff]) - + _sBox4[i & 0xff]; } void _encipher(final int l0, final int r0, final List result) { diff --git a/lib/src/cryptor/symmetric/twofish.dart b/lib/src/cryptor/symmetric/twofish.dart index fc79dbc8..58806bc3 100644 --- a/lib/src/cryptor/symmetric/twofish.dart +++ b/lib/src/cryptor/symmetric/twofish.dart @@ -527,13 +527,18 @@ class TwofishEngine extends BaseEngine { ); for (var i = 0, j = 1; i < 40; i += 2, j += 2) { - var a = _m0[_q0[_q0[_q1[_q1[i] ^ key[24]] ^ key[16]] ^ key[8]] ^ key[0]] ^ + var a = _m0[ + _q0[_q0[_q1[_q1[i] ^ key[24]] ^ key[16]] ^ key[8]] ^ key[0]] ^ _m1[_q0[_q1[_q1[_q0[i] ^ key[25]] ^ key[17]] ^ key[9]] ^ key[1]] ^ - _m2[_q1[_q0[_q0[_q0[i] ^ key[26]] ^ key[18]] ^ key[10]] ^ key[2]] ^ + _m2[_q1[_q0[_q0[_q0[i] ^ key[26]] ^ key[18]] ^ key[10]] ^ + key[2]] ^ _m3[_q1[_q1[_q0[_q1[i] ^ key[27]] ^ key[19]] ^ key[11]] ^ key[3]]; - var b = _m0[_q0[_q0[_q1[_q1[j] ^ key[28]] ^ key[20]] ^ key[12]] ^ key[4]] ^ - _m1[_q0[_q1[_q1[_q0[j] ^ key[29]] ^ key[21]] ^ key[13]] ^ key[5]] ^ - _m2[_q1[_q0[_q0[_q0[j] ^ key[30]] ^ key[22]] ^ key[14]] ^ key[6]] ^ + var b = _m0[_q0[_q0[_q1[_q1[j] ^ key[28]] ^ key[20]] ^ key[12]] ^ + key[4]] ^ + _m1[_q0[_q1[_q1[_q0[j] ^ key[29]] ^ key[21]] ^ key[13]] ^ + key[5]] ^ + _m2[_q1[_q0[_q0[_q0[j] ^ key[30]] ^ key[22]] ^ key[14]] ^ + key[6]] ^ _m3[_q1[_q1[_q0[_q1[j] ^ key[31]] ^ key[23]] ^ key[15]] ^ key[7]]; b = (b << 8) | (b >> 24 & 0xff); a = a + b; @@ -543,10 +548,18 @@ class TwofishEngine extends BaseEngine { } for (var i = 0; i < 256; ++i) { - _sTable0[i] = _m0[_q0[_q0[_q1[_q1[i] ^ list1[3]] ^ list2[3]] ^ list3[3]] ^ list4[3]]; - _sTable1[i] = _m1[_q0[_q1[_q1[_q0[i] ^ list1[2]] ^ list2[2]] ^ list3[2]] ^ list4[2]]; - _sTable2[i] = _m2[_q1[_q0[_q0[_q0[i] ^ list1[1]] ^ list2[1]] ^ list3[1]] ^ list4[1]]; - _sTable3[i] = _m3[_q1[_q1[_q0[_q1[i] ^ list1[0]] ^ list2[0]] ^ list3[0]] ^ list4[0]]; + _sTable0[i] = _m0[ + _q0[_q0[_q1[_q1[i] ^ list1[3]] ^ list2[3]] ^ list3[3]] ^ + list4[3]]; + _sTable1[i] = _m1[ + _q0[_q1[_q1[_q0[i] ^ list1[2]] ^ list2[2]] ^ list3[2]] ^ + list4[2]]; + _sTable2[i] = _m2[ + _q1[_q0[_q0[_q0[i] ^ list1[1]] ^ list2[1]] ^ list3[1]] ^ + list4[1]]; + _sTable3[i] = _m3[ + _q1[_q1[_q0[_q1[i] ^ list1[0]] ^ list2[0]] ^ list3[0]] ^ + list4[0]]; } break; default: @@ -569,17 +582,27 @@ class TwofishEngine extends BaseEngine { var ki = 7; while (ki < 39) { - var t0 = - _sTable0[r0 & 0xff] ^ _sTable1[(r0 >> 8) & 0xff] ^ _sTable2[(r0 >> 16) & 0xff] ^ _sTable3[(r0 >> 24) & 0xff]; - var t1 = - _sTable0[(r1 >> 24) & 0xff] ^ _sTable1[r1 & 0xff] ^ _sTable2[(r1 >> 8) & 0xff] ^ _sTable3[(r1 >> 16) & 0xff]; + var t0 = _sTable0[r0 & 0xff] ^ + _sTable1[(r0 >> 8) & 0xff] ^ + _sTable2[(r0 >> 16) & 0xff] ^ + _sTable3[(r0 >> 24) & 0xff]; + var t1 = _sTable0[(r1 >> 24) & 0xff] ^ + _sTable1[r1 & 0xff] ^ + _sTable2[(r1 >> 8) & 0xff] ^ + _sTable3[(r1 >> 16) & 0xff]; r2 ^= t0 + t1 + _subKey[++ki]; r2 = (r2 >> 1 & 0x7fffffff) | (r2 << 31); r3 = (((r3 >> 31) & 1) | (r3 << 1)) ^ (t0 + (t1 << 1) + _subKey[++ki]); - t0 = _sTable0[r2 & 0xff] ^ _sTable1[(r2 >> 8) & 0xff] ^ _sTable2[(r2 >> 16) & 0xff] ^ _sTable3[(r2 >> 24) & 0xff]; - t1 = _sTable0[(r3 >> 24) & 0xff] ^ _sTable1[r3 & 0xff] ^ _sTable2[(r3 >> 8) & 0xff] ^ _sTable3[(r3 >> 16) & 0xff]; + t0 = _sTable0[r2 & 0xff] ^ + _sTable1[(r2 >> 8) & 0xff] ^ + _sTable2[(r2 >> 16) & 0xff] ^ + _sTable3[(r2 >> 24) & 0xff]; + t1 = _sTable0[(r3 >> 24) & 0xff] ^ + _sTable1[r3 & 0xff] ^ + _sTable2[(r3 >> 8) & 0xff] ^ + _sTable3[(r3 >> 16) & 0xff]; r0 ^= t0 + t1 + _subKey[++ki]; r0 = (r0 >> 1 & 0x7fffffff) | (r0 << 31); @@ -608,15 +631,27 @@ class TwofishEngine extends BaseEngine { var ki = 40; while (ki > 8) { - var t0 = _sTable0[r0 & 0xff] ^ _sTable1[r0 >> 8 & 0xff] ^ _sTable2[r0 >> 16 & 0xff] ^ _sTable3[r0 >> 24 & 0xff]; - var t1 = _sTable0[r1 >> 24 & 0xff] ^ _sTable1[r1 & 0xff] ^ _sTable2[r1 >> 8 & 0xff] ^ _sTable3[r1 >> 16 & 0xff]; + var t0 = _sTable0[r0 & 0xff] ^ + _sTable1[r0 >> 8 & 0xff] ^ + _sTable2[r0 >> 16 & 0xff] ^ + _sTable3[r0 >> 24 & 0xff]; + var t1 = _sTable0[r1 >> 24 & 0xff] ^ + _sTable1[r1 & 0xff] ^ + _sTable2[r1 >> 8 & 0xff] ^ + _sTable3[r1 >> 16 & 0xff]; r3 ^= t0 + (t1 << 1) + _subKey[--ki]; r3 = r3 >> 1 & 0x7fffffff | r3 << 31; r2 = (r2 >> 31 & 0x1 | r2 << 1) ^ (t0 + t1 + _subKey[--ki]); - t0 = _sTable0[r2 & 0xff] ^ _sTable1[r2 >> 8 & 0xff] ^ _sTable2[r2 >> 16 & 0xff] ^ _sTable3[r2 >> 24 & 0xff]; - t1 = _sTable0[r3 >> 24 & 0xff] ^ _sTable1[r3 & 0xff] ^ _sTable2[r3 >> 8 & 0xff] ^ _sTable3[r3 >> 16 & 0xff]; + t0 = _sTable0[r2 & 0xff] ^ + _sTable1[r2 >> 8 & 0xff] ^ + _sTable2[r2 >> 16 & 0xff] ^ + _sTable3[r2 >> 24 & 0xff]; + t1 = _sTable0[r3 >> 24 & 0xff] ^ + _sTable1[r3 & 0xff] ^ + _sTable2[r3 >> 8 & 0xff] ^ + _sTable3[r3 >> 16 & 0xff]; r1 ^= t0 + (t1 << 1) + _subKey[--ki]; r1 = r1 >> 1 & 0x7fffffff | r1 << 31; diff --git a/lib/src/enum/ecc.dart b/lib/src/enum/ecc.dart index a8a5de92..5d62b972 100644 --- a/lib/src/enum/ecc.dart +++ b/lib/src/enum/ecc.dart @@ -36,7 +36,11 @@ enum Ecc { }; SymmetricAlgorithm get symmetricAlgorithm => switch (this) { - brainpoolP256r1 || curve25519 || ed25519 || secp256r1 => SymmetricAlgorithm.aes128, + brainpoolP256r1 || + curve25519 || + ed25519 || + secp256r1 => + SymmetricAlgorithm.aes128, brainpoolP384r1 || secp384r1 => SymmetricAlgorithm.aes192, brainpoolP512r1 || secp521r1 => SymmetricAlgorithm.aes256, }; diff --git a/lib/src/enum/key_algorithm.dart b/lib/src/enum/key_algorithm.dart index bc3f4b11..2c3a5448 100644 --- a/lib/src/enum/key_algorithm.dart +++ b/lib/src/enum/key_algorithm.dart @@ -71,6 +71,8 @@ enum KeyAlgorithm { int get keyVersion => switch (this) { x25519 || x448 || ed25519 || ed448 => KeyVersion.v6.value, - _ => Config.presetRfc == PresetRfc.rfc9580 ? KeyVersion.v6.value : KeyVersion.v4.value, + _ => Config.presetRfc == PresetRfc.rfc9580 + ? KeyVersion.v6.value + : KeyVersion.v4.value, }; } diff --git a/lib/src/enum/packet_type.dart b/lib/src/enum/packet_type.dart index 61b5099a..b2ceb9ed 100644 --- a/lib/src/enum/packet_type.dart +++ b/lib/src/enum/packet_type.dart @@ -29,4 +29,4 @@ enum PacketType { final int value; const PacketType(this.value); -} \ No newline at end of file +} diff --git a/lib/src/enum/signature_type.dart b/lib/src/enum/signature_type.dart index 04a70c39..e28da968 100644 --- a/lib/src/enum/signature_type.dart +++ b/lib/src/enum/signature_type.dart @@ -15,7 +15,6 @@ export 'hash_algorithm.dart'; export 'key_algorithm.dart'; export 'signature_subpacket_type.dart'; - ///Signature types enum /// Author Nguyen Van Nguyen enum SignatureType { diff --git a/lib/src/enum/symmetric_algorithm.dart b/lib/src/enum/symmetric_algorithm.dart index f19388ca..80dc8879 100644 --- a/lib/src/enum/symmetric_algorithm.dart +++ b/lib/src/enum/symmetric_algorithm.dart @@ -53,18 +53,29 @@ enum SymmetricAlgorithm { int get blockSize => switch (this) { plaintext => 0, blowfish || cast5 || idea || tripledes => 8, - aes128 || aes192 || aes256 || camellia128 || camellia192 || camellia256 || twofish => 16, + aes128 || + aes192 || + aes256 || + camellia128 || + camellia192 || + camellia256 || + twofish => + 16, }; BlockCipher get cfbCipherEngine => switch (this) { aes128 || aes192 || aes256 => BlockCipher('AES/CFB-${blockSize * 8}'), blowfish => CFBBlockCipher(BlowfishEngine(), blockSize), - camellia128 || camellia192 || camellia256 => CFBBlockCipher(CamelliaEngine(), blockSize), + camellia128 || + camellia192 || + camellia256 => + CFBBlockCipher(CamelliaEngine(), blockSize), cast5 => CFBBlockCipher(CAST5Engine(), blockSize), idea => CFBBlockCipher(IDEAEngine(), blockSize), tripledes => BlockCipher('DESede/CFB-${blockSize * 8}'), twofish => CFBBlockCipher(TwofishEngine(), blockSize), - _ => throw UnsupportedError('Unsupported symmetric algorithm encountered'), + _ => + throw UnsupportedError('Unsupported symmetric algorithm encountered'), }; BlockCipher get cipherEngine => switch (this) { @@ -75,6 +86,7 @@ enum SymmetricAlgorithm { idea => IDEAEngine(), tripledes => DESedeEngine(), twofish => TwofishEngine(), - _ => throw UnsupportedError('Unsupported symmetric algorithm encountered'), + _ => + throw UnsupportedError('Unsupported symmetric algorithm encountered'), }; } diff --git a/lib/src/key/base_key.dart b/lib/src/key/base_key.dart index 005217ff..714ef20d 100644 --- a/lib/src/key/base_key.dart +++ b/lib/src/key/base_key.dart @@ -135,7 +135,8 @@ abstract class BaseKey implements KeyInterface { for (final user in users) { if (user.isPrimary && !user.isRevoked()) { for (final signature in user.selfSignatures) { - final subpacket = signature.getSubpacket(); + final subpacket = + signature.getSubpacket(); if (subpacket?.preferences.isNotEmpty ?? false) { return subpacket!.preferences; } diff --git a/lib/src/key/private_key.dart b/lib/src/key/private_key.dart index 0f08205e..a7b72682 100644 --- a/lib/src/key/private_key.dart +++ b/lib/src/key/private_key.dart @@ -53,7 +53,8 @@ final class PrivateKey extends BaseKey implements PrivateKeyInterface { } final KeyAlgorithm keyAlgorithm = switch (type) { KeyType.rsa => KeyAlgorithm.rsaEncryptSign, - KeyType.ecc => curve == Ecc.ed25519 ? KeyAlgorithm.eddsaLegacy : KeyAlgorithm.ecdsa, + KeyType.ecc => + curve == Ecc.ed25519 ? KeyAlgorithm.eddsaLegacy : KeyAlgorithm.ecdsa, KeyType.curve25519 => KeyAlgorithm.ed25519, KeyType.curve448 => KeyAlgorithm.ed448, }; @@ -64,7 +65,8 @@ final class PrivateKey extends BaseKey implements PrivateKeyInterface { curve: curve, time: time, ); - final aead = secretKey.isV6Key && Config.aeadProtect ? Config.preferredAead : null; + final aead = + secretKey.isV6Key && Config.aeadProtect ? Config.preferredAead : null; final packets = [ secretKey.encrypt( passphrase, @@ -106,7 +108,8 @@ final class PrivateKey extends BaseKey implements PrivateKeyInterface { KeyType.curve25519 => KeyAlgorithm.x25519, KeyType.curve448 => KeyAlgorithm.x448, }; - final subkeyCurve = keyAlgorithm == KeyAlgorithm.eddsaLegacy ? Ecc.curve25519 : curve; + final subkeyCurve = + keyAlgorithm == KeyAlgorithm.eddsaLegacy ? Ecc.curve25519 : curve; final secretSubkey = SecretSubkeyPacket.generate( subkeyAlgorithm, rsaKeySize: rsaKeySize, @@ -162,7 +165,8 @@ final class PrivateKey extends BaseKey implements PrivateKeyInterface { } @override - getDecryptionKeyPacket([Uint8List? keyID]) => getEncryptionKeyPacket(keyID) as SecretKeyPacketInterface; + getDecryptionKeyPacket([Uint8List? keyID]) => + getEncryptionKeyPacket(keyID) as SecretKeyPacketInterface; @override armor() => Armor.encode(ArmorType.privateKey, packetList.encode()); @@ -183,7 +187,8 @@ final class PrivateKey extends BaseKey implements PrivateKeyInterface { ); } - final aead = aeadProtected && Config.aeadProtect ? Config.preferredAead : null; + final aead = + aeadProtected && Config.aeadProtect ? Config.preferredAead : null; final subkeys = this.subkeys.map((subkey) { final index = this.subkeys.indexOf(subkey); final subkeyPass = subkeyPassphrases.elementAtOrNull(index) ?? passphrase; diff --git a/lib/src/key/subkey.dart b/lib/src/key/subkey.dart index 65246187..7e75e3c6 100644 --- a/lib/src/key/subkey.dart +++ b/lib/src/key/subkey.dart @@ -58,7 +58,8 @@ final class Subkey implements SubkeyInterface { if (keyPacket.isEncryptionKey) { for (final signature in bindingSignatures) { final keyFlags = signature.getSubpacket(); - if (keyFlags != null && !(keyFlags.isEncryptStorage || keyFlags.isEncryptCommunication)) { + if (keyFlags != null && + !(keyFlags.isEncryptStorage || keyFlags.isEncryptCommunication)) { return false; } } diff --git a/lib/src/key/user.dart b/lib/src/key/user.dart index e81c4dd4..a941184a 100644 --- a/lib/src/key/user.dart +++ b/lib/src/key/user.dart @@ -63,7 +63,9 @@ final class User implements UserInterface { ]); @override - get userID => (userIDPacket is UserIDPacket) ? (userIDPacket as UserIDPacket).userID : ""; + get userID => (userIDPacket is UserIDPacket) + ? (userIDPacket as UserIDPacket).userID + : ""; @override isRevoked([final DateTime? time]) { diff --git a/lib/src/message/base_message.dart b/lib/src/message/base_message.dart index 7a10197b..bfa9073f 100644 --- a/lib/src/message/base_message.dart +++ b/lib/src/message/base_message.dart @@ -19,7 +19,8 @@ export 'verification.dart'; /// Base abstract OpenPGP message class /// Author Nguyen Van Nguyen -abstract class BaseMessage implements ArmorableInterface, PacketContainerInterface { +abstract class BaseMessage + implements ArmorableInterface, PacketContainerInterface { @override final PacketListInterface packetList; diff --git a/lib/src/message/encrypted_message.dart b/lib/src/message/encrypted_message.dart index 39f59b46..0f9fe595 100644 --- a/lib/src/message/encrypted_message.dart +++ b/lib/src/message/encrypted_message.dart @@ -17,7 +17,8 @@ import '../type/session_key.dart'; /// OpenPGP encrypted message class /// Author Nguyen Van Nguyen -final class EncryptedMessage extends BaseMessage implements EncryptedMessageInterface { +final class EncryptedMessage extends BaseMessage + implements EncryptedMessageInterface { SessionKeyInterface? _sessionKey; EncryptedMessage(super.packetList) { @@ -61,7 +62,8 @@ final class EncryptedMessage extends BaseMessage implements EncryptedMessageInte } } if (sessionKeys.isEmpty && decryptionKeys.isNotEmpty) { - final pkeskPackets = packetList.whereType(); + final pkeskPackets = + packetList.whereType(); for (final pkesk in pkeskPackets) { for (final key in decryptionKeys) { final keyPacket = key.getDecryptionKeyPacket(); @@ -85,10 +87,16 @@ final class EncryptedMessage extends BaseMessage implements EncryptedMessageInte } @override - get encryptedPacket => packetList.whereType().first; + get encryptedPacket => + packetList.whereType().first; @override - get aeadProtected => packetList.whereType().firstOrNull?.aead != null; + get aeadProtected => + packetList + .whereType() + .firstOrNull + ?.aead != + null; @override get sessionKey => _sessionKey; diff --git a/lib/src/message/literal_message.dart b/lib/src/message/literal_message.dart index 0c9a0994..30d6c17b 100644 --- a/lib/src/message/literal_message.dart +++ b/lib/src/message/literal_message.dart @@ -25,7 +25,8 @@ import '../type/signature_packet.dart'; /// OpenPGP literal message class /// Author Nguyen Van Nguyen -final class LiteralMessage extends BaseMessage implements LiteralMessageInterface, SignedMessageInterface { +final class LiteralMessage extends BaseMessage + implements LiteralMessageInterface, SignedMessageInterface { LiteralMessage(super.packetList) { if (_unwrapCompressed().whereType().isEmpty) { throw AssertionError( @@ -114,17 +115,19 @@ final class LiteralMessage extends BaseMessage implements LiteralMessageInterfac sessionKey, ), ), - ...passwords.map((password) => SymEncryptedSessionKeyPacket.encryptSessionKey( - password, - sessionKey: sessionKey, - symmetric: sessionKey.symmetric, - aead: sessionKey.aead, - )), + ...passwords + .map((password) => SymEncryptedSessionKeyPacket.encryptSessionKey( + password, + sessionKey: sessionKey, + symmetric: sessionKey.symmetric, + aead: sessionKey.aead, + )), ]); } @override - get literalData => _unwrapCompressed().whereType().first; + get literalData => + _unwrapCompressed().whereType().first; @override get signature => Signature( @@ -282,6 +285,7 @@ final class LiteralMessage extends BaseMessage implements LiteralMessageInterfac } PacketListInterface _unwrapCompressed() { - return packetList.whereType().firstOrNull?.packets ?? packetList; + return packetList.whereType().firstOrNull?.packets ?? + packetList; } } diff --git a/lib/src/message/signed_message.dart b/lib/src/message/signed_message.dart index d4814263..e3cd8d9c 100644 --- a/lib/src/message/signed_message.dart +++ b/lib/src/message/signed_message.dart @@ -17,7 +17,8 @@ import 'cleartext_message.dart'; /// Signed message class that represents an OpenPGP cleartext signed message. /// See RFC 9580, section 7. /// Author Nguyen Van Nguyen -final class SignedMessage extends CleartextMessage implements SignedCleartextMessageInterface { +final class SignedMessage extends CleartextMessage + implements SignedCleartextMessageInterface { @override final SignatureInterface signature; diff --git a/lib/src/packet/aead_encrypted_data.dart b/lib/src/packet/aead_encrypted_data.dart index 52db3d5d..5ef5759e 100644 --- a/lib/src/packet/aead_encrypted_data.dart +++ b/lib/src/packet/aead_encrypted_data.dart @@ -16,7 +16,8 @@ import 'base_packet.dart'; /// Implementation of the Symmetrically Encrypted Authenticated Encryption with /// Additional Data (AEAD) Protected Data Packet - Type 20 /// Author Nguyen Van Nguyen -class AeadEncryptedDataPacket extends BasePacket implements EncryptedDataPacketInterface { +class AeadEncryptedDataPacket extends BasePacket + implements EncryptedDataPacketInterface { static const version = 1; final SymmetricAlgorithm symmetric; diff --git a/lib/src/packet/compressed_data.dart b/lib/src/packet/compressed_data.dart index 67062761..cf9dbce8 100644 --- a/lib/src/packet/compressed_data.dart +++ b/lib/src/packet/compressed_data.dart @@ -65,7 +65,9 @@ class CompressedDataPacket extends BasePacket { final CompressionAlgorithm algorithm, ) => switch (algorithm) { - CompressionAlgorithm.zip || CompressionAlgorithm.zlib => Uint8List.fromList( + CompressionAlgorithm.zip || + CompressionAlgorithm.zlib => + Uint8List.fromList( ZLibCodec( level: deflateLevel, raw: algorithm == CompressionAlgorithm.zip, @@ -82,7 +84,9 @@ class CompressedDataPacket extends BasePacket { final CompressionAlgorithm algorithm, ) => switch (algorithm) { - CompressionAlgorithm.zip || CompressionAlgorithm.zlib => PacketList.decode( + CompressionAlgorithm.zip || + CompressionAlgorithm.zlib => + PacketList.decode( Uint8List.fromList(ZLibCodec( level: deflateLevel, raw: algorithm == CompressionAlgorithm.zip, diff --git a/lib/src/packet/key/dsa_secret_material.dart b/lib/src/packet/key/dsa_secret_material.dart index 4beceb38..5641ed27 100644 --- a/lib/src/packet/key/dsa_secret_material.dart +++ b/lib/src/packet/key/dsa_secret_material.dart @@ -67,7 +67,8 @@ class DSASecretMaterial implements SigningKeyMaterialInterface { } /// Check that subgroup order q divides p-1 - if (((publicMaterial.prime - BigInt.one) % publicMaterial.order).sign != 0) { + if (((publicMaterial.prime - BigInt.one) % publicMaterial.order).sign != + 0) { return false; } diff --git a/lib/src/packet/key/ecdh_secret_material.dart b/lib/src/packet/key/ecdh_secret_material.dart index 407b0cfa..d6e4c47d 100644 --- a/lib/src/packet/key/ecdh_secret_material.dart +++ b/lib/src/packet/key/ecdh_secret_material.dart @@ -17,7 +17,8 @@ import 'ecdh_public_material.dart'; /// ECDH secret key material /// Author Nguyen Van Nguyen -class ECDHSecretMaterial extends ECSecretMaterial implements SecretKeyMaterialInterface { +class ECDHSecretMaterial extends ECSecretMaterial + implements SecretKeyMaterialInterface { @override final ECDHPublicMaterial publicMaterial; diff --git a/lib/src/packet/key/ecdsa_public_material.dart b/lib/src/packet/key/ecdsa_public_material.dart index 09674ff9..c347535a 100644 --- a/lib/src/packet/key/ecdsa_public_material.dart +++ b/lib/src/packet/key/ecdsa_public_material.dart @@ -14,7 +14,8 @@ import '../../type/verification_key_material.dart'; /// ECDSA public key material /// Author Nguyen Van Nguyen -class ECDSAPublicMaterial extends ECPublicMaterial implements VerificationKeyMaterial { +class ECDSAPublicMaterial extends ECPublicMaterial + implements VerificationKeyMaterial { ECDSAPublicMaterial(super.oid, super.q); factory ECDSAPublicMaterial.fromBytes(final Uint8List bytes) { diff --git a/lib/src/packet/key/ecdsa_secret_material.dart b/lib/src/packet/key/ecdsa_secret_material.dart index 7324312f..07f34c98 100644 --- a/lib/src/packet/key/ecdsa_secret_material.dart +++ b/lib/src/packet/key/ecdsa_secret_material.dart @@ -16,7 +16,8 @@ import 'ecdsa_public_material.dart'; /// ECDSA secret key material /// Author Nguyen Van Nguyen -class ECDSASecretMaterial extends ECSecretMaterial implements SigningKeyMaterialInterface { +class ECDSASecretMaterial extends ECSecretMaterial + implements SigningKeyMaterialInterface { @override final ECDSAPublicMaterial publicMaterial; diff --git a/lib/src/packet/key/eddsa_legacy_public_material.dart b/lib/src/packet/key/eddsa_legacy_public_material.dart index be958a92..0babea81 100644 --- a/lib/src/packet/key/eddsa_legacy_public_material.dart +++ b/lib/src/packet/key/eddsa_legacy_public_material.dart @@ -14,7 +14,8 @@ import 'ec_public_material.dart'; /// EdDSA legacy public key material /// Author Nguyen Van Nguyen -class EdDSALegacyPublicMaterial extends ECPublicMaterial implements VerificationKeyMaterial { +class EdDSALegacyPublicMaterial extends ECPublicMaterial + implements VerificationKeyMaterial { EdDSALegacyPublicMaterial(super.oid, super.q); factory EdDSALegacyPublicMaterial.fromBytes( diff --git a/lib/src/packet/key/rsa_secret_material.dart b/lib/src/packet/key/rsa_secret_material.dart index b7369d3f..155c225e 100644 --- a/lib/src/packet/key/rsa_secret_material.dart +++ b/lib/src/packet/key/rsa_secret_material.dart @@ -120,7 +120,8 @@ class RSASecretMaterial implements SigningKeyMaterialInterface { final sizeOver3 = (publicMaterial.modulus.bitLength / 3).floor(); final r = Helper.randomBigInt(BigInt.two, BigInt.two << sizeOver3); final rde = r * exponent * publicMaterial.exponent; - return (rde % (primeP - BigInt.one)).compareTo(r) == 0 && (rde % (primeQ - BigInt.one)).compareTo(r) == 0; + return (rde % (primeP - BigInt.one)).compareTo(r) == 0 && + (rde % (primeQ - BigInt.one)).compareTo(r) == 0; } @override diff --git a/lib/src/packet/key/session_key_cryptor.dart b/lib/src/packet/key/session_key_cryptor.dart index 799aef5c..e06fee47 100644 --- a/lib/src/packet/key/session_key_cryptor.dart +++ b/lib/src/packet/key/session_key_cryptor.dart @@ -28,16 +28,15 @@ abstract class SessionKeyCryptor implements SessionKeyCryptorInterface { final AsymmetricBlockCipher engine, final Uint8List input, ) { - final numBlocks = - input.length ~/ engine.inputBlockSize + ((input.length % engine.inputBlockSize != 0) ? 1 : 0); + final numBlocks = input.length ~/ engine.inputBlockSize + + ((input.length % engine.inputBlockSize != 0) ? 1 : 0); final output = Uint8List(numBlocks * engine.outputBlockSize); var inpOff = 0; var outOff = 0; while (inpOff < input.length) { - final chunkSize = - (inpOff + engine.inputBlockSize <= input.length) + final chunkSize = (inpOff + engine.inputBlockSize <= input.length) ? engine.inputBlockSize : input.length - inpOff; diff --git a/lib/src/packet/packet_list.dart b/lib/src/packet/packet_list.dart index f8e24079..3ff0698b 100644 --- a/lib/src/packet/packet_list.dart +++ b/lib/src/packet/packet_list.dart @@ -13,7 +13,8 @@ import 'base_packet.dart'; /// This class represents a list of OpenPGP packets. /// Author Nguyen Van Nguyen -class PacketList extends ListBase implements PacketListInterface { +class PacketList extends ListBase + implements PacketListInterface { @override final List packets; @@ -30,11 +31,13 @@ class PacketList extends ListBase implements PacketListInterfac final reader = PacketReader.read(bytes, offset); offset = reader.offset; final packet = switch (reader.type) { - PacketType.publicKeyEncryptedSessionKey => PublicKeyEncryptedSessionKeyPacket.fromBytes( + PacketType.publicKeyEncryptedSessionKey => + PublicKeyEncryptedSessionKeyPacket.fromBytes( reader.data, ), PacketType.signature => SignaturePacket.fromBytes(reader.data), - PacketType.symEncryptedSessionKey => SymEncryptedSessionKeyPacket.fromBytes( + PacketType.symEncryptedSessionKey => + SymEncryptedSessionKeyPacket.fromBytes( reader.data, ), PacketType.onePassSignature => OnePassSignaturePacket.fromBytes( diff --git a/lib/src/packet/packet_reader.dart b/lib/src/packet/packet_reader.dart index 3b3b9d35..381a6d5e 100644 --- a/lib/src/packet/packet_reader.dart +++ b/lib/src/packet/packet_reader.dart @@ -24,7 +24,9 @@ final class PacketReader { final Uint8List bytes, [ final int offset = 0, ]) { - if (bytes.length <= offset || bytes.sublist(offset).length < 2 || (bytes[offset] & 0x80) == 0) { + if (bytes.length <= offset || + bytes.sublist(offset).length < 2 || + (bytes[offset] & 0x80) == 0) { throw ArgumentError( 'Error during parsing.' 'This data probably does not conform to a valid OpenPGP format.', @@ -78,7 +80,8 @@ final class PacketReader { partialPos += partialLen; break; } else if (partialLen < 224) { - partialLen = ((partialLen - 192) << 8) + (bytes[partialPos++]) + 192; + partialLen = + ((partialLen - 192) << 8) + (bytes[partialPos++]) + 192; partialData.add( bytes.sublist(partialPos, partialPos + partialLen), ); diff --git a/lib/src/packet/public_key.dart b/lib/src/packet/public_key.dart index a52ddb9f..bafee2a7 100644 --- a/lib/src/packet/public_key.dart +++ b/lib/src/packet/public_key.dart @@ -136,7 +136,8 @@ class PublicKeyPacket extends BasePacket implements KeyPacketInterface { ]); void _assertKey() { - if (keyVersion != KeyVersion.v4.value && keyVersion != KeyVersion.v6.value) { + if (keyVersion != KeyVersion.v4.value && + keyVersion != KeyVersion.v6.value) { throw UnsupportedError( 'Version $keyVersion of the key packet is unsupported.', ); @@ -151,7 +152,8 @@ class PublicKeyPacket extends BasePacket implements KeyPacketInterface { ); } } - if (keyAlgorithm == KeyAlgorithm.dsa || keyAlgorithm == KeyAlgorithm.elgamal) { + if (keyAlgorithm == KeyAlgorithm.dsa || + keyAlgorithm == KeyAlgorithm.elgamal) { throw ArgumentError( 'Key algorithm ${keyAlgorithm.name} ' 'cannot be used with v$keyVersion key packet.', diff --git a/lib/src/packet/public_key_encrypted_session_key.dart b/lib/src/packet/public_key_encrypted_session_key.dart index 5c8eb3af..31f216b4 100644 --- a/lib/src/packet/public_key_encrypted_session_key.dart +++ b/lib/src/packet/public_key_encrypted_session_key.dart @@ -83,7 +83,9 @@ class PublicKeyEncryptedSessionKeyPacket extends BasePacket { pos++; final sessionKeyCryptor = switch (keyAlgorithm) { - KeyAlgorithm.rsaEncryptSign || KeyAlgorithm.rsaEncrypt => RSASessionKeyCryptor.fromBytes( + KeyAlgorithm.rsaEncryptSign || + KeyAlgorithm.rsaEncrypt => + RSASessionKeyCryptor.fromBytes( bytes.sublist(pos), ), KeyAlgorithm.elgamal => ElGamalSessionKeyCryptor.fromBytes( @@ -135,7 +137,9 @@ class PublicKeyEncryptedSessionKeyPacket extends BasePacket { }; final cryptor = switch (keyPacket.keyAlgorithm) { - KeyAlgorithm.rsaEncryptSign || KeyAlgorithm.rsaEncrypt => RSASessionKeyCryptor.encryptSessionKey( + KeyAlgorithm.rsaEncryptSign || + KeyAlgorithm.rsaEncrypt => + RSASessionKeyCryptor.encryptSessionKey( keyData, keyPacket.keyMaterial as RSAPublicMaterial, ), @@ -144,7 +148,9 @@ class PublicKeyEncryptedSessionKeyPacket extends BasePacket { keyPacket.keyMaterial as ECDHPublicMaterial, keyPacket.fingerprint, ), - KeyAlgorithm.x25519 || KeyAlgorithm.x448 => MontgomerySessionKeyCryptor.encryptSessionKey( + KeyAlgorithm.x25519 || + KeyAlgorithm.x448 => + MontgomerySessionKeyCryptor.encryptSessionKey( keyData, keyPacket.keyMaterial as MontgomeryPublicMaterial, ), diff --git a/lib/src/packet/public_subkey.dart b/lib/src/packet/public_subkey.dart index 45e46792..1f6e0e08 100644 --- a/lib/src/packet/public_subkey.dart +++ b/lib/src/packet/public_subkey.dart @@ -12,7 +12,8 @@ import 'public_key.dart'; /// Implementation of the Public Subkey (PUBSUBKEY) Packet - Type 14 /// Author Nguyen Van Nguyen -class PublicSubkeyPacket extends PublicKeyPacket implements SubkeyPacketInterface { +class PublicSubkeyPacket extends PublicKeyPacket + implements SubkeyPacketInterface { @override get type => PacketType.publicSubkey; diff --git a/lib/src/packet/secret_key.dart b/lib/src/packet/secret_key.dart index 7c456483..d9eda0ab 100644 --- a/lib/src/packet/secret_key.dart +++ b/lib/src/packet/secret_key.dart @@ -181,7 +181,8 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { /// Only for a version 6 packet, and if string-to-key usage /// octet was 253 or 254, an one-octet count of the following field. - if (isV6 && (s2kUsage == S2kUsage.aeadProtect || s2kUsage == S2kUsage.cfb)) { + if (isV6 && + (s2kUsage == S2kUsage.aeadProtect || s2kUsage == S2kUsage.cfb)) { pos++; } @@ -206,7 +207,8 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { if (aead != null) { iv = bytes.sublist(pos, pos + aead.ivLength); pos += aead.ivLength; - } else if (!(s2k != null && s2k.type == S2kType.gnu) && s2kUsage != S2kUsage.none) { + } else if (!(s2k != null && s2k.type == S2kType.gnu) && + s2kUsage != S2kUsage.none) { iv = bytes.sublist(pos, pos + symmetric.blockSize); pos += symmetric.blockSize; } @@ -454,7 +456,7 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { @override get isSubkey => this is SubkeyPacketInterface; - + @override bool get isV6Key => publicKey.isV6Key; @@ -524,7 +526,10 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { final PublicKeyPacket publicKey, ) { final keyMaterial = switch (publicKey.keyAlgorithm) { - KeyAlgorithm.rsaEncryptSign || KeyAlgorithm.rsaSign || KeyAlgorithm.rsaEncrypt => RSASecretMaterial.fromBytes( + KeyAlgorithm.rsaEncryptSign || + KeyAlgorithm.rsaSign || + KeyAlgorithm.rsaEncrypt => + RSASecretMaterial.fromBytes( keyData, publicKey.keyMaterial as RSAPublicMaterial, ), @@ -548,11 +553,15 @@ class SecretKeyPacket extends BasePacket implements SecretKeyPacketInterface { keyData, publicKey.keyMaterial as EdDSALegacyPublicMaterial, ), - KeyAlgorithm.x25519 || KeyAlgorithm.x448 => MontgomerySecretMaterial.fromBytes( + KeyAlgorithm.x25519 || + KeyAlgorithm.x448 => + MontgomerySecretMaterial.fromBytes( keyData, publicKey.keyMaterial as MontgomeryPublicMaterial, ), - KeyAlgorithm.ed25519 || KeyAlgorithm.ed448 => EdDSASecretMaterial.fromBytes( + KeyAlgorithm.ed25519 || + KeyAlgorithm.ed448 => + EdDSASecretMaterial.fromBytes( keyData, publicKey.keyMaterial as EdDSAPublicMaterial, ), diff --git a/lib/src/packet/secret_subkey.dart b/lib/src/packet/secret_subkey.dart index 7af9f9aa..74834aa7 100644 --- a/lib/src/packet/secret_subkey.dart +++ b/lib/src/packet/secret_subkey.dart @@ -19,7 +19,8 @@ import 'secret_key.dart'; /// Implementation of the Secret Subkey (SECSUBKEY) Packet - Type 7 /// Author Nguyen Van Nguyen -class SecretSubkeyPacket extends SecretKeyPacket implements SubkeyPacketInterface { +class SecretSubkeyPacket extends SecretKeyPacket + implements SubkeyPacketInterface { @override get type => PacketType.secretSubkey; diff --git a/lib/src/packet/signature.dart b/lib/src/packet/signature.dart index 3fcbf77f..81215dc5 100644 --- a/lib/src/packet/signature.dart +++ b/lib/src/packet/signature.dart @@ -374,7 +374,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { ]); @override - get creationTime => getSubpacket()?.creationTime ?? DateTime.fromMillisecondsSinceEpoch(0); + get creationTime => + getSubpacket()?.creationTime ?? + DateTime.fromMillisecondsSinceEpoch(0); @override get expirationTime => getSubpacket()?.expirationTime; @@ -411,7 +413,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { get isSubkeyRevocation => signatureType == SignatureType.subkeyRevocation; @override - get issuerFingerprint => getSubpacket()?.fingerprint ?? Uint8List(version == 6 ? 32 : 20); + get issuerFingerprint => + getSubpacket()?.fingerprint ?? + Uint8List(version == 6 ? 32 : 20); @override get issuerKeyID { @@ -427,14 +431,17 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { @override getSubpacket() { - return hashedSubpackets.whereType().elementAtOrNull(0) ?? unhashedSubpackets.whereType().elementAtOrNull(0); + return hashedSubpackets.whereType().elementAtOrNull(0) ?? + unhashedSubpackets.whereType().elementAtOrNull(0); } @override isExpired([final DateTime? time]) { - final timestamp = time?.millisecondsSinceEpoch ?? DateTime.now().millisecondsSinceEpoch; + final timestamp = + time?.millisecondsSinceEpoch ?? DateTime.now().millisecondsSinceEpoch; final creation = creationTime.millisecondsSinceEpoch; - final expiration = expirationTime?.millisecondsSinceEpoch ?? DateTime.now().millisecondsSinceEpoch; + final expiration = expirationTime?.millisecondsSinceEpoch ?? + DateTime.now().millisecondsSinceEpoch; return !(creation <= timestamp && timestamp <= expiration); } @@ -513,7 +520,9 @@ class SignaturePacket extends BasePacket implements SignaturePacketInterface { CompressionAlgorithm.zlib.value, ])), Features.fromFeatures( - SupportFeature.seipdV1.value | SupportFeature.aead.value | SupportFeature.seipdV2.value, + SupportFeature.seipdV1.value | + SupportFeature.aead.value | + SupportFeature.seipdV2.value, ), ]; if (version == KeyVersion.v6.value) { diff --git a/lib/src/packet/signature/features.dart b/lib/src/packet/signature/features.dart index be62729b..f5c15baa 100644 --- a/lib/src/packet/signature/features.dart +++ b/lib/src/packet/signature/features.dart @@ -26,11 +26,16 @@ class Features extends SignatureSubpacket { }) => Features(Uint8List.fromList([features]), critical: critical); - bool get seipdV1Supported => (data[0] & SupportFeature.seipdV1.value) == SupportFeature.seipdV1.value; + bool get seipdV1Supported => + (data[0] & SupportFeature.seipdV1.value) == SupportFeature.seipdV1.value; - bool get aeadSupported => (data[0] & SupportFeature.aead.value) == SupportFeature.aead.value; + bool get aeadSupported => + (data[0] & SupportFeature.aead.value) == SupportFeature.aead.value; - bool get publicKeyV5Supported => (data[0] & SupportFeature.publicKeyV5.value) == SupportFeature.publicKeyV5.value; + bool get publicKeyV5Supported => + (data[0] & SupportFeature.publicKeyV5.value) == + SupportFeature.publicKeyV5.value; - bool get seidpV2Supported => (data[0] & SupportFeature.seipdV2.value) == SupportFeature.seipdV2.value; + bool get seidpV2Supported => + (data[0] & SupportFeature.seipdV2.value) == SupportFeature.seipdV2.value; } diff --git a/lib/src/packet/signature/key_flags.dart b/lib/src/packet/signature/key_flags.dart index 62dd2d7c..9f45f755 100644 --- a/lib/src/packet/signature/key_flags.dart +++ b/lib/src/packet/signature/key_flags.dart @@ -35,13 +35,18 @@ class KeyFlags extends SignatureSubpacket { return value; } - bool get isCertifyKeys => flags & KeyFlag.certifyKeys.value == KeyFlag.certifyKeys.value; + bool get isCertifyKeys => + flags & KeyFlag.certifyKeys.value == KeyFlag.certifyKeys.value; - bool get isSignData => flags & KeyFlag.signData.value == KeyFlag.signData.value; + bool get isSignData => + flags & KeyFlag.signData.value == KeyFlag.signData.value; - bool get isEncryptCommunication => flags & KeyFlag.encryptCommunication.value == KeyFlag.encryptCommunication.value; + bool get isEncryptCommunication => + flags & KeyFlag.encryptCommunication.value == + KeyFlag.encryptCommunication.value; - bool get isEncryptStorage => flags & KeyFlag.encryptStorage.value == KeyFlag.encryptStorage.value; + bool get isEncryptStorage => + flags & KeyFlag.encryptStorage.value == KeyFlag.encryptStorage.value; static Uint8List _flagsToBytes(final int flags) { final bytes = Uint8List(4); diff --git a/lib/src/packet/signature/notation_data.dart b/lib/src/packet/signature/notation_data.dart index 4ea1a6a2..72043448 100644 --- a/lib/src/packet/signature/notation_data.dart +++ b/lib/src/packet/signature/notation_data.dart @@ -71,16 +71,20 @@ class NotationData extends SignatureSubpacket implements NotationDataInterface { bool get humanReadable => data[0] == 0x80; Uint8List get nameData { - final nameLength = (((data[headerFlagLength] & 0xff) << 8) + (data[headerFlagLength + 1] & 0xff)); + final nameLength = (((data[headerFlagLength] & 0xff) << 8) + + (data[headerFlagLength + 1] & 0xff)); final nameOffset = headerFlagLength + headerNameLength + headerValueLength; return data.sublist(nameOffset, nameOffset + nameLength); } Uint8List get valueData { - final nameLength = (((data[headerFlagLength] & 0xff) << 8) + (data[headerFlagLength + 1] & 0xff)); - final valueLength = (((data[headerFlagLength + headerNameLength] & 0xff) << 8) + - (data[headerFlagLength + headerNameLength + 1] & 0xff)); - final valueOffset = headerFlagLength + headerNameLength + headerValueLength + nameLength; + final nameLength = (((data[headerFlagLength] & 0xff) << 8) + + (data[headerFlagLength + 1] & 0xff)); + final valueLength = + (((data[headerFlagLength + headerNameLength] & 0xff) << 8) + + (data[headerFlagLength + headerNameLength + 1] & 0xff)); + final valueOffset = + headerFlagLength + headerNameLength + headerValueLength + nameLength; return data.sublist(valueOffset, valueOffset + valueLength); } diff --git a/lib/src/packet/signature/preferred_aead_algorithms.dart b/lib/src/packet/signature/preferred_aead_algorithms.dart index 642cc8f6..ff1c99e1 100644 --- a/lib/src/packet/signature/preferred_aead_algorithms.dart +++ b/lib/src/packet/signature/preferred_aead_algorithms.dart @@ -22,8 +22,7 @@ class PreferredAeadAlgorithms extends SignatureSubpacket { data, ); - List get preferences => - data + List get preferences => data .map( (pref) => AeadAlgorithm.values.firstWhere( (alg) => alg.value == pref, diff --git a/lib/src/packet/signature/preferred_hash_algorithms.dart b/lib/src/packet/signature/preferred_hash_algorithms.dart index 0a292192..1f5be56f 100644 --- a/lib/src/packet/signature/preferred_hash_algorithms.dart +++ b/lib/src/packet/signature/preferred_hash_algorithms.dart @@ -20,8 +20,7 @@ class PreferredHashAlgorithms extends SignatureSubpacket { super.isLong, }) : super(SignatureSubpacketType.preferredHashAlgorithms, data); - List get preferences => - data + List get preferences => data .map( (pref) => HashAlgorithm.values.firstWhere( (alg) => alg.value == pref, diff --git a/lib/src/packet/signature/preferred_symmetric_algorithms.dart b/lib/src/packet/signature/preferred_symmetric_algorithms.dart index d2caff93..f31427e0 100644 --- a/lib/src/packet/signature/preferred_symmetric_algorithms.dart +++ b/lib/src/packet/signature/preferred_symmetric_algorithms.dart @@ -20,8 +20,7 @@ class PreferredSymmetricAlgorithms extends SignatureSubpacket { super.isLong, }) : super(SignatureSubpacketType.preferredSymmetricAlgorithms, data); - List get preferences => - data + List get preferences => data .map( (pref) => SymmetricAlgorithm.values.firstWhere( (alg) => alg.value == pref, diff --git a/lib/src/packet/signature/primary_user_id.dart b/lib/src/packet/signature/primary_user_id.dart index a1625889..aeac5c62 100644 --- a/lib/src/packet/signature/primary_user_id.dart +++ b/lib/src/packet/signature/primary_user_id.dart @@ -20,7 +20,8 @@ class PrimaryUserID extends SignatureSubpacket { final bool isPrimary, { final bool critical = false, }) => - PrimaryUserID(Uint8List.fromList([isPrimary ? 1 : 0]), critical: critical); + PrimaryUserID(Uint8List.fromList([isPrimary ? 1 : 0]), + critical: critical); bool get isPrimary => data[0] != 0; } diff --git a/lib/src/packet/signature/signer_user_id.dart b/lib/src/packet/signature/signer_user_id.dart index 6e9e2b15..54e6159a 100644 --- a/lib/src/packet/signature/signer_user_id.dart +++ b/lib/src/packet/signature/signer_user_id.dart @@ -14,7 +14,8 @@ import '../signature_subpacket.dart'; /// responsible for the signing. /// Author Nguyen Van Nguyen class SignerUserID extends SignatureSubpacket { - SignerUserID(final Uint8List data, {super.critical, super.isLong}) : super(SignatureSubpacketType.signerUserID, data); + SignerUserID(final Uint8List data, {super.critical, super.isLong}) + : super(SignatureSubpacketType.signerUserID, data); factory SignerUserID.fromUserID( final String userID, { diff --git a/lib/src/packet/sym_encrypted_data.dart b/lib/src/packet/sym_encrypted_data.dart index b4526d22..5537f4c6 100644 --- a/lib/src/packet/sym_encrypted_data.dart +++ b/lib/src/packet/sym_encrypted_data.dart @@ -18,7 +18,8 @@ import 'base_packet.dart'; /// Implementation of the Symmetrically Encrypted Data (SED) Packet - Type 9 /// The encrypted contents will consist of more OpenPGP packets. /// Author Nguyen Van Nguyen -class SymEncryptedDataPacket extends BasePacket implements EncryptedDataPacketInterface { +class SymEncryptedDataPacket extends BasePacket + implements EncryptedDataPacketInterface { @override final Uint8List encrypted; diff --git a/lib/src/packet/sym_encrypted_integrity_protected_data.dart b/lib/src/packet/sym_encrypted_integrity_protected_data.dart index 79fe6f15..0ccb4517 100644 --- a/lib/src/packet/sym_encrypted_integrity_protected_data.dart +++ b/lib/src/packet/sym_encrypted_integrity_protected_data.dart @@ -19,7 +19,8 @@ import 'base_packet.dart'; /// Symmetric Encrypted Integrity Protected Data (SEIPD) Packet - Type 18 /// Author Nguyen Van Nguyen -class SymEncryptedIntegrityProtectedDataPacket extends BasePacket implements EncryptedDataPacketInterface { +class SymEncryptedIntegrityProtectedDataPacket extends BasePacket + implements EncryptedDataPacketInterface { static const saltSize = 32; static const mdcSuffix = [0xd3, 0x14]; diff --git a/lib/src/type/encrypted_message.dart b/lib/src/type/encrypted_message.dart index e57dab07..9280bcd4 100644 --- a/lib/src/type/encrypted_message.dart +++ b/lib/src/type/encrypted_message.dart @@ -13,7 +13,8 @@ import 'session_key.dart'; /// Encrypted message interface /// Author Nguyen Van Nguyen -abstract interface class EncryptedMessageInterface implements ArmorableInterface, PacketContainerInterface { +abstract interface class EncryptedMessageInterface + implements ArmorableInterface, PacketContainerInterface { /// Return encrypted packet. EncryptedDataPacketInterface get encryptedPacket; diff --git a/lib/src/type/key.dart b/lib/src/type/key.dart index 5a54a83f..c7baa56b 100644 --- a/lib/src/type/key.dart +++ b/lib/src/type/key.dart @@ -23,7 +23,8 @@ export 'user.dart'; /// Transferable key interface /// That represents a key packet, the relevant signatures, users and subkeys. /// Author Nguyen Van Nguyen -abstract interface class KeyInterface implements ArmorableInterface, PacketContainerInterface { +abstract interface class KeyInterface + implements ArmorableInterface, PacketContainerInterface { /// Return key packet KeyPacketInterface get keyPacket; diff --git a/lib/src/type/literal_message.dart b/lib/src/type/literal_message.dart index ed94d3d2..75af3dd9 100644 --- a/lib/src/type/literal_message.dart +++ b/lib/src/type/literal_message.dart @@ -23,7 +23,8 @@ export 'verification.dart'; /// Literal message interface /// Author Nguyen Van Nguyen -abstract interface class LiteralMessageInterface implements ArmorableInterface, PacketContainerInterface { +abstract interface class LiteralMessageInterface + implements ArmorableInterface, PacketContainerInterface { /// Get literal data LiteralDataInterface get literalData; diff --git a/lib/src/type/packet_list.dart b/lib/src/type/packet_list.dart index 1f7d852a..d7338451 100644 --- a/lib/src/type/packet_list.dart +++ b/lib/src/type/packet_list.dart @@ -10,7 +10,8 @@ import 'packet.dart'; /// Packet list interface /// Author Nguyen Van Nguyen -abstract interface class PacketListInterface implements List { +abstract interface class PacketListInterface + implements List { /// Get packets List get packets; diff --git a/lib/src/type/secret_key_material.dart b/lib/src/type/secret_key_material.dart index f1dc9c20..99c6ed4c 100644 --- a/lib/src/type/secret_key_material.dart +++ b/lib/src/type/secret_key_material.dart @@ -8,7 +8,8 @@ import 'key_material.dart'; /// Secret key material interface /// Author Nguyen Van Nguyen -abstract interface class SecretKeyMaterialInterface implements KeyMaterialInterface { +abstract interface class SecretKeyMaterialInterface + implements KeyMaterialInterface { /// Get public key material KeyMaterialInterface get publicMaterial; diff --git a/lib/src/type/secret_key_packet.dart b/lib/src/type/secret_key_packet.dart index 436592c0..d23fafce 100644 --- a/lib/src/type/secret_key_packet.dart +++ b/lib/src/type/secret_key_packet.dart @@ -11,7 +11,8 @@ import 'key_packet.dart'; /// Secret key packet interface /// Author Nguyen Van Nguyen -abstract interface class SecretKeyPacketInterface implements KeyPacketInterface { +abstract interface class SecretKeyPacketInterface + implements KeyPacketInterface { /// Get public key packet KeyPacketInterface get publicKey; diff --git a/lib/src/type/signature.dart b/lib/src/type/signature.dart index 320675fa..2a7b8c8d 100644 --- a/lib/src/type/signature.dart +++ b/lib/src/type/signature.dart @@ -17,7 +17,8 @@ import 'verification.dart'; /// Signature interface /// Author Nguyen Van Nguyen -abstract interface class SignatureInterface implements ArmorableInterface, PacketContainerInterface { +abstract interface class SignatureInterface + implements ArmorableInterface, PacketContainerInterface { /// Get hash algorithms Iterable get hashAlgorithms; diff --git a/lib/src/type/signed_cleartext_message.dart b/lib/src/type/signed_cleartext_message.dart index 52585270..6d9474c9 100644 --- a/lib/src/type/signed_cleartext_message.dart +++ b/lib/src/type/signed_cleartext_message.dart @@ -9,4 +9,5 @@ import 'signed_message.dart'; /// Signed cleartext message interface /// Author Nguyen Van Nguyen -abstract interface class SignedCleartextMessageInterface implements CleartextMessageInterface, SignedMessageInterface {} +abstract interface class SignedCleartextMessageInterface + implements CleartextMessageInterface, SignedMessageInterface {} diff --git a/lib/src/type/signing_key_material.dart b/lib/src/type/signing_key_material.dart index dca479c4..8c3ad870 100644 --- a/lib/src/type/signing_key_material.dart +++ b/lib/src/type/signing_key_material.dart @@ -11,8 +11,9 @@ import '../enum/hash_algorithm.dart'; /// Signing key material interface /// Author Nguyen Van Nguyen -abstract interface class SigningKeyMaterialInterface implements SecretKeyMaterialInterface { - /// Sign a message and return signature +abstract interface class SigningKeyMaterialInterface + implements SecretKeyMaterialInterface { + /// Sign a message and return signature Uint8List sign( final Uint8List message, final HashAlgorithm hash, diff --git a/lib/src/type/verification_key_material.dart b/lib/src/type/verification_key_material.dart index e9074c05..4404819f 100644 --- a/lib/src/type/verification_key_material.dart +++ b/lib/src/type/verification_key_material.dart @@ -11,7 +11,8 @@ import 'key_material.dart'; /// Verification key material interface /// Author Nguyen Van Nguyen -abstract interface class VerificationKeyMaterial implements KeyMaterialInterface { +abstract interface class VerificationKeyMaterial + implements KeyMaterialInterface { /// Verify a signature with message bool verify( final Uint8List message, diff --git a/test/common/s2k_test.dart b/test/common/s2k_test.dart index b7faa5db..c250f201 100644 --- a/test/common/s2k_test.dart +++ b/test/common/s2k_test.dart @@ -303,7 +303,8 @@ void main() { test('4 iterations 10mb 32 keylength', () { const salt = "KtPeAgudgN7xrgUK"; - const hash = "66b3d1c15f544eae5810c29381ad477167d5a1d5360c9b97340bd5b8b06c589b"; + const hash = + "66b3d1c15f544eae5810c29381ad477167d5a1d5360c9b97340bd5b8b06c589b"; final s2k = Argon2S2k(salt.toBytes(), 4, 1, 10); final key = s2k.produceKey(passphrase, 32); @@ -315,7 +316,8 @@ void main() { test('4 iterations 64 mb 32 key length', () { const salt = "D85Euo8RwvlkUxb5"; - const hash = "cb1f8f04ec5ecb681e4ffb2665af6e4ad6aed540b5e62f625f48c834e8b88fa6"; + const hash = + "cb1f8f04ec5ecb681e4ffb2665af6e4ad6aed540b5e62f625f48c834e8b88fa6"; final s2k = Argon2S2k(salt.toBytes(), 4, 1, 16); final key = s2k.produceKey(passphrase, 32); diff --git a/test/crypto/aead_test.dart b/test/crypto/aead_test.dart index 296236c6..1bf07473 100644 --- a/test/crypto/aead_test.dart +++ b/test/crypto/aead_test.dart @@ -64,7 +64,8 @@ void main() { 'key': '7c77d6e813bed5ac98baa417477a2e7d', 'nonce': '1a8c98dcd73d38393b2bf1569deefc19', 'header': '65d2017990d62528', - 'cipher': '02083e3979da014812f59f11d52630da30137327d10649b0aa6e1c181db617d7f2', + 'cipher': + '02083e3979da014812f59f11d52630da30137327d10649b0aa6e1c181db617d7f2', }, { 'name': 'Test Case 8', @@ -72,7 +73,8 @@ void main() { 'key': '5fff20cafab119ca2fc73549e20f5b0d', 'nonce': 'dde59b97d722156d4d9aff2bc7559826', 'header': '54b9f04e6a09189a', - 'cipher': '2ec47b2c4954a489afc7ba4897edcdae8cc33b60450599bd02c96382902aef7f832a', + 'cipher': + '2ec47b2c4954a489afc7ba4897edcdae8cc33b60450599bd02c96382902aef7f832a', }, { 'name': 'Test Case 9', @@ -80,7 +82,8 @@ void main() { 'key': 'a4a4782bcffd3ec5e7ef6d8c34a56123', 'nonce': 'b781fcf2f75fa5a8de97a9ca48e522ec', 'header': '899a175897561d7e', - 'cipher': '0de18fd0fdd91e7af19f1d8ee8733938b1e8e7f6d2231618102fdb7fe55ff1991700', + 'cipher': + '0de18fd0fdd91e7af19f1d8ee8733938b1e8e7f6d2231618102fdb7fe55ff1991700', }, { 'name': 'Test Case 10', @@ -88,7 +91,8 @@ void main() { 'key': '8395fcf1e95bebd697bd010bc766aac3', 'nonce': '22e7add93cfc6393c57ec0b3c17d6b44', 'header': '126735fcc320d25a', - 'cipher': 'cb8920f87a6c75cff39627b56e3ed197c552d295a7cfc46afc253b4652b1af3795b124ab6e', + 'cipher': + 'cb8920f87a6c75cff39627b56e3ed197c552d295a7cfc46afc253b4652b1af3795b124ab6e', }, ]; for (var map in testVectors) { @@ -103,21 +107,27 @@ void main() { /// encryption test var ct = eax.encrypt(msg, nonce, header); - expect(ct, equals(cipher), reason: 'encryption test $map["name"] did not match output'); + expect(ct, equals(cipher), + reason: 'encryption test $map["name"] did not match output'); /// decryption test with verification var pt = eax.decrypt(cipher, nonce, header); - expect(pt, equals(msg), reason: 'decryption test $map["name"] did not match output'); + expect(pt, equals(msg), + reason: 'decryption test $map["name"] did not match output'); /// testing without additional data ct = eax.encrypt(msg, nonce, Uint8List(0)); pt = eax.decrypt(ct, nonce, Uint8List(0)); - expect(pt, equals(msg), reason: 'test $map["name"] did not match output'); + expect(pt, equals(msg), + reason: 'test $map["name"] did not match output'); /// testing with multiple additional data - ct = eax.encrypt(msg, nonce, Uint8List.fromList([...header, ...header, ...header])); - pt = eax.decrypt(ct, nonce, Uint8List.fromList([...header, ...header, ...header])); - expect(pt, equals(msg), reason: 'test $map["name"] did not match output'); + ct = eax.encrypt( + msg, nonce, Uint8List.fromList([...header, ...header, ...header])); + pt = eax.decrypt( + ct, nonce, Uint8List.fromList([...header, ...header, ...header])); + expect(pt, equals(msg), + reason: 'test $map["name"] did not match output'); }); } }); @@ -179,7 +189,8 @@ void main() { 'N': 'bbaa99887766554433221107', 'A': '000102030405060708090a0b0c0d0e0f1011121314151617', 'P': '000102030405060708090a0b0c0d0e0f1011121314151617', - 'C': '1ca2207308c87c010756104d8840ce1952f09673a448a122c92c62241051f57356d7f3c90bb0e07f', + 'C': + '1ca2207308c87c010756104d8840ce1952f09673a448a122c92c62241051f57356d7f3c90bb0e07f', }, { 'name': 'Test Case 9', @@ -193,14 +204,16 @@ void main() { 'N': 'bbaa99887766554433221109', 'A': '', 'P': '000102030405060708090a0b0c0d0e0f1011121314151617', - 'C': '221bd0de7fa6fe993eccd769460a0af2d6cded0c395b1c3ce725f32494b9f914d85c0b1eb38357ff', + 'C': + '221bd0de7fa6fe993eccd769460a0af2d6cded0c395b1c3ce725f32494b9f914d85c0b1eb38357ff', }, { 'name': 'Test Case 11', 'N': 'bbaa9988776655443322110a', 'A': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'P': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', - 'C': 'bd6f6c496201c69296c11efd138a467abd3c707924b964deaffc40319af5a48540fbba186c5553c68ad9f592a79a4240', + 'C': + 'bd6f6c496201c69296c11efd138a467abd3c707924b964deaffc40319af5a48540fbba186c5553c68ad9f592a79a4240', }, { 'name': 'Test Case 12', @@ -214,20 +227,24 @@ void main() { 'N': 'bbaa9988776655443322110c', 'A': '', 'P': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', - 'C': '2942bfc773bda23cabc6acfd9bfd5835bd300f0973792ef46040c53f1432bcdfb5e1dde3bc18a5f840b52e653444d5df', + 'C': + '2942bfc773bda23cabc6acfd9bfd5835bd300f0973792ef46040c53f1432bcdfb5e1dde3bc18a5f840b52e653444d5df', }, { 'name': 'Test Case 14', 'N': 'bbaa9988776655443322110d', - 'A': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', - 'P': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', + 'A': + '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', + 'P': + '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', 'C': 'd5ca91748410c1751ff8a2f618255b68a0a12e093ff454606e59f9c1d0ddc54b65e8628e568bad7aed07ba06a4a69483a7035490c5769e60', }, { 'name': 'Test Case 15', 'N': 'bbaa9988776655443322110e', - 'A': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', + 'A': + '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', 'P': '', 'C': 'c5cd9d1850c141e358649994ee701b68', }, @@ -235,7 +252,8 @@ void main() { 'name': 'Test Case 16', 'N': 'bbaa9988776655443322110f', 'A': '', - 'P': '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', + 'P': + '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627', 'C': '4412923493c57d5de0d700f753cce0d1d2d95060122e9f15a5ddbfc5787e50b5cc55ee507bcb084e479ad363ac366b95a98ca5f3000b1479', }, @@ -251,21 +269,27 @@ void main() { /// encryption test var ct = ocb.encrypt(msg, nonce, header); - expect(ct, equals(cipher), reason: 'encryption test $map["name"] did not match output'); + expect(ct, equals(cipher), + reason: 'encryption test $map["name"] did not match output'); /// decryption test with verification var pt = ocb.decrypt(cipher, nonce, header); - expect(pt, equals(msg), reason: 'decryption test $map["name"] did not match output'); + expect(pt, equals(msg), + reason: 'decryption test $map["name"] did not match output'); /// testing without additional data ct = ocb.encrypt(msg, nonce, Uint8List(0)); pt = ocb.decrypt(ct, nonce, Uint8List(0)); - expect(pt, equals(msg), reason: 'test $map["name"] did not match output'); + expect(pt, equals(msg), + reason: 'test $map["name"] did not match output'); /// testing with multiple additional data - ct = ocb.encrypt(msg, nonce, Uint8List.fromList([...header, ...header, ...header])); - pt = ocb.decrypt(ct, nonce, Uint8List.fromList([...header, ...header, ...header])); - expect(pt, equals(msg), reason: 'test $map["name"] did not match output'); + ct = ocb.encrypt( + msg, nonce, Uint8List.fromList([...header, ...header, ...header])); + pt = ocb.decrypt( + ct, nonce, Uint8List.fromList([...header, ...header, ...header])); + expect(pt, equals(msg), + reason: 'test $map["name"] did not match output'); }); } }); @@ -400,7 +424,8 @@ void main() { }, { 'name': 'Test Case 13', - 'key': '0000000000000000000000000000000000000000000000000000000000000000', + 'key': + '0000000000000000000000000000000000000000000000000000000000000000', 'iv': '000000000000000000000000', 'aad': '', 'input': '', @@ -409,7 +434,8 @@ void main() { }, { 'name': 'Test Case 14', - 'key': '0000000000000000000000000000000000000000000000000000000000000000', + 'key': + '0000000000000000000000000000000000000000000000000000000000000000', 'iv': '000000000000000000000000', 'aad': '', 'input': '00000000000000000000000000000000', @@ -418,7 +444,8 @@ void main() { }, { 'name': 'Test Case 15', - 'key': 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', + 'key': + 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'iv': 'cafebabefacedbaddecaf888', 'aad': '', 'input': @@ -429,7 +456,8 @@ void main() { }, { 'name': 'Test Case 16', - 'key': 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', + 'key': + 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'iv': 'cafebabefacedbaddecaf888', 'aad': 'feedfacedeadbeeffeedfacedeadbeefabaddad2', 'input': @@ -440,7 +468,8 @@ void main() { }, { 'name': 'Test Case 17', - 'key': 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', + 'key': + 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'iv': 'cafebabefacedbad', 'aad': 'feedfacedeadbeeffeedfacedeadbeefabaddad2', 'input': @@ -451,7 +480,8 @@ void main() { }, { 'name': 'Test Case 18', - 'key': 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', + 'key': + 'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'iv': '9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b', 'aad': 'feedfacedeadbeeffeedfacedeadbeefabaddad2', @@ -484,17 +514,21 @@ void main() { /// decryption test with verification var pt = gcm.decrypt(Uint8List.fromList([...output, ...mac]), iv, aad); - expect(pt, equals(input), reason: 'decryption test $map["name"] did not match output'); + expect(pt, equals(input), + reason: 'decryption test $map["name"] did not match output'); /// testing without additional data ct = gcm.encrypt(input, iv, Uint8List(0)); pt = gcm.decrypt(ct, iv, Uint8List(0)); - expect(pt, equals(input), reason: 'test $map["name"] did not match output'); + expect(pt, equals(input), + reason: 'test $map["name"] did not match output'); /// testing with multiple additional data - ct = gcm.encrypt(input, iv, Uint8List.fromList([...aad, ...aad, ...aad])); + ct = gcm.encrypt( + input, iv, Uint8List.fromList([...aad, ...aad, ...aad])); pt = gcm.decrypt(ct, iv, Uint8List.fromList([...aad, ...aad, ...aad])); - expect(pt, equals(input), reason: 'test $map["name"] did not match output'); + expect(pt, equals(input), + reason: 'test $map["name"] did not match output'); }); } }); diff --git a/test/crypto/asymmetric_test.dart b/test/crypto/asymmetric_test.dart index 16ecc685..a8309f6e 100644 --- a/test/crypto/asymmetric_test.dart +++ b/test/crypto/asymmetric_test.dart @@ -10,17 +10,21 @@ void main() { group('DSA', () { final prime = BigInt.parse( '18162137922021319783039084688936650943756676913936359487644230524033744038416716640315362119531957065117691808427264479820376952164824666951768158261158011465383622961646140102588814345836301228952436368478471605675244965240663395560393520043446488959085100446039711212792538929022066114201273802300832755863321968834472697137828335693635804943342266260626637109532050720555091308772127451653755872557451491248990382251482443887099369600464777831608990878007068814783464418617901906104198108074206903909793174142273612557335586051547777907089455850194383049226681257881252609518716935491786310874981455522347755965263'); - final order = BigInt.parse('66237724685660121164013399122464209600863963990328366006106224772467420697001'); + final order = BigInt.parse( + '66237724685660121164013399122464209600863963990328366006106224772467420697001'); final generator = BigInt.parse( '693117913754860276426473281664845283847827874078831837566781765224888221249721170562868171267423414589469577529462100295651372077651432728133000631159241493543615314643538727517688679127996156948227084734117835362992668110067565260029784027890436946325120986252996031434727021897912364504906315612769347582107563243931645185214720978427405505592726492013000567393825423372958968113840944031967516897982342279432489751673785605929305317306465162868047750314617256208362522435739505165126345703258213171855603629264914838294962758085762547804458344916991647240641414079945072645196179749686064721950595476461703347596'); final publicExponent = BigInt.parse( '4782172781034192998693423575547001875121450860285384286800905429000791264609187331114128879953098324124068264308502771574321383159125468535909140265000623111180145376619101796653939164726433685123758969904269839090078039075889777192894408978360938352224532502867949812284119229251938382586523438070582120724642233025483830096315195183698731083960541920397786806884931581765685611516570402002856528710913800628319231592500299988215432415250617341963426900030521545457294059283280813544106638008667172693314074865970063708048659226032286932981816054377197606962836326219108126026753202594298484748732919893514434857817'); - final secretExponent = BigInt.parse('4058353653331808916569051257818485824406724876273357155551230247524105887159'); + final secretExponent = BigInt.parse( + '4058353653331808916569051257818485824406724876273357155551230247524105887159'); final privateKey = DSAPrivateKey(secretExponent, prime, order, generator); final publicKey = DSAPublicKey(publicExponent, prime, order, generator); - final message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit ........".toBytes(); + final message = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit ........" + .toBytes(); test('With sha1 test', (() { final signer = DSASigner(Digest('SHA-1')); @@ -56,9 +60,12 @@ void main() { final engine = ElGamalEngine(); engine.init(true, PublicKeyParameter(publicKey)); - expect(engine.outputBlockSize, 2048 ~/ 4, reason: "2048 outputBlockSize on encryption failed."); + expect(engine.outputBlockSize, 2048 ~/ 4, + reason: "2048 outputBlockSize on encryption failed."); - final message = "En un lugar de La Mancha, de cuyo nombre no quiero acordarme ...".toBytes(); + final message = + "En un lugar de La Mancha, de cuyo nombre no quiero acordarme ..." + .toBytes(); final plainText = message; final cipherText = Uint8List(engine.outputBlockSize); engine.processBlock(plainText, 0, plainText.length, cipherText, 0); @@ -66,7 +73,8 @@ void main() { engine.init(false, PrivateKeyParameter(privateKey)); engine.processBlock(cipherText, 0, cipherText.length, plainText, 0); - expect(engine.outputBlockSize, (2048 ~/ 8) - 1, reason: "2048 outputBlockSize on decryption failed."); + expect(engine.outputBlockSize, (2048 ~/ 8) - 1, + reason: "2048 outputBlockSize on decryption failed."); expect(message, equals(plainText), reason: '2048 bit test failed'); }); }); diff --git a/test/crypto/symmetric_test.dart b/test/crypto/symmetric_test.dart index b5d7315b..f165f588 100644 --- a/test/crypto/symmetric_test.dart +++ b/test/crypto/symmetric_test.dart @@ -132,8 +132,12 @@ void main() { '9acc237dff16d76c20ef7c919e3a7509', ); - _blockCipherTest(7, CamelliaEngine(), _kp('4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a'), - '057764fe3a500edbd988c5c3b56cba9a', '4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a'); + _blockCipherTest( + 7, + CamelliaEngine(), + _kp('4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a'), + '057764fe3a500edbd988c5c3b56cba9a', + '4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a'); _blockCipherTest( 8, diff --git a/test/crypto/x448_test.dart b/test/crypto/x448_test.dart index 6db90396..747879ea 100644 --- a/test/crypto/x448_test.dart +++ b/test/crypto/x448_test.dart @@ -304,15 +304,18 @@ void checkX448Vector(String sk, String su, String se, String text) { }); } -void checkECDHVector(String sA, String sAPub, String sB, String sBPub, String sK, String text) { +void checkECDHVector( + String sA, String sAPub, String sB, String sBPub, String sK, String text) { test(text, () { final a = sA.hexToBytes(); final aPub = X448.scalarMultBase(a); - expect(aPub, equals(sAPub.hexToBytes()), reason: 'Public key did not match'); + expect(aPub, equals(sAPub.hexToBytes()), + reason: 'Public key did not match'); final b = sB.hexToBytes(); final bPub = X448.scalarMultBase(b); - expect(bPub, equals(sBPub.hexToBytes()), reason: 'Public key did not match'); + expect(bPub, equals(sBPub.hexToBytes()), + reason: 'Public key did not match'); final aK = X448.scalarMult(a, bPub); expect(aK, equals(sK.hexToBytes()), reason: 'Shared secret did not match'); diff --git a/test/message/literal_data_test.dart b/test/message/literal_data_test.dart index 0cb80084..eaed0dda 100644 --- a/test/message/literal_data_test.dart +++ b/test/message/literal_data_test.dart @@ -175,7 +175,8 @@ void main() { passwords: [password], ); - final encryptedPacket = encryptedMessage.encryptedPacket as SymEncryptedIntegrityProtectedDataPacket; + final encryptedPacket = encryptedMessage.encryptedPacket + as SymEncryptedIntegrityProtectedDataPacket; expect(encryptedPacket.aead, Config.preferredAead); final literalMessage = OpenPGP.decrypt( diff --git a/test/packet/compression_test.dart b/test/packet/compression_test.dart index 4419cc2c..8f839b77 100644 --- a/test/packet/compression_test.dart +++ b/test/packet/compression_test.dart @@ -7,7 +7,8 @@ import 'package:test/test.dart'; void main() { group('Compression', () { - final literalData = LiteralDataPacket.fromText(faker.randomGenerator.string(10000)); + final literalData = + LiteralDataPacket.fromText(faker.randomGenerator.string(10000)); test('zip test', () { final compressedPacket = CompressedDataPacket.fromPacketList( diff --git a/test/packet/encryption_test.dart b/test/packet/encryption_test.dart index e22741f2..78b3681d 100644 --- a/test/packet/encryption_test.dart +++ b/test/packet/encryption_test.dart @@ -27,8 +27,10 @@ void main() { expect(aepd.chunkSize, 14); expect(aepd.iv.toHexadecimal(), 'b732379f73c4928de25facfe6517ec10'); - final decryptAepd = aepd.decrypt('86f1efb86952329f24acd3bfd0e5346d'.hexToBytes()); - final literalData = decryptAepd.packets!.whereType().first; + final decryptAepd = + aepd.decrypt('86f1efb86952329f24acd3bfd0e5346d'.hexToBytes()); + final literalData = + decryptAepd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -43,8 +45,10 @@ void main() { expect(aepd.chunkSize, 14); expect(aepd.iv.toHexadecimal(), '5ed2bc1e470abe8f1d644c7a6c8a56'); - final decryptAepd = aepd.decrypt('d1f01ba30e130aa7d2582c16e050ae44'.hexToBytes()); - final literalData = decryptAepd.packets!.whereType().first; + final decryptAepd = + aepd.decrypt('d1f01ba30e130aa7d2582c16e050ae44'.hexToBytes()); + final literalData = + decryptAepd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); }); @@ -66,13 +70,15 @@ void main() { '3881bafe985412459b86c36f98cb9a5e'.hexToBytes(), ); - final seipd = SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( + final seipd = + SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( 'AgcBBp/5DjsyGWTzpCkTyNzGYZMlAVIn77fq6qSfBMLmdBddSj0ibtavy5yprBIsFHDhHGPUwKskHGqTitSL+ZpambkLuoMl3mEEdUAlireVmpWtBR3alusVQx3+9fXiJVyngmFUbjOa', )).decrypt(sessionKey.encryptionKey); expect(seipd.symmetric, SymmetricAlgorithm.aes128); expect(seipd.aead, AeadAlgorithm.eax); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -89,13 +95,15 @@ void main() { '28e79ab82397d3c63de24ac217d7b791'.hexToBytes(), ); - final seipd = SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( + final seipd = + SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( 'AgcCBiCmYfcx/JowMrViMyYCfjpdjbV0jr7/CwxZENCezdZB/5/ThWJ1gDW8SXVM4b8//6fa0KO4EE9RM89CpBAKg+70yhtIAaiEa/QrzafIzp1l4hLzAcvNmP3K3mlKh3rUJHMj9uhX', )).decrypt(sessionKey.encryptionKey); expect(seipd.symmetric, SymmetricAlgorithm.aes128); expect(seipd.aead, AeadAlgorithm.ocb); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -112,13 +120,15 @@ void main() { '1936fc8568980274bb900d8319360c77'.hexToBytes(), ); - final seipd = SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( + final seipd = + SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( 'AgcDBvy5RJC8uYu9ydEGxgkCZpQPcuie3CG1WWsVdrEB7Q+f/G/G1lu/0k3NB5CWbm0ehaMAU3hMsdi2oGme8SFVp7KtYlhTG1dlH9d3eRL6leNdm0Ahb2mkwkjbKP9DMfFjKQc5nm/5', )).decrypt(sessionKey.encryptionKey); expect(seipd.symmetric, SymmetricAlgorithm.aes128); expect(seipd.aead, AeadAlgorithm.gcm); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -136,10 +146,12 @@ void main() { ); expect(sessionKey.symmetric, SymmetricAlgorithm.aes128); - final seipd = SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( + final seipd = + SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( 'AZgYpj5gnPi7oX4MOUME6vk1FBe38okh/ibiY6UrIL+6otumcslkydOrejv0bEFN0h07OEdd8DempXiZPMU=', )).decrypt(sessionKey.encryptionKey, sessionKey.symmetric); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -157,10 +169,12 @@ void main() { ); expect(sessionKey.symmetric, SymmetricAlgorithm.aes192); - final seipd = SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( + final seipd = + SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( 'AdJ1Sw56PRYiKZjCvHg+2bnq02s33AJJoyBexBI4QKATFRkyez2gldJldRysLVg77Mwwfgl2n/d572WciAM=', )).decrypt(sessionKey.encryptionKey, sessionKey.symmetric); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -174,14 +188,17 @@ void main() { final sessionKey = skesk.sessionKey!; expect( sessionKey.encryptionKey, - 'bbeda55b9aae63dac45d4f49d89dacf4af37fefc13bab2f1f8e18fb74580d8b0'.hexToBytes(), + 'bbeda55b9aae63dac45d4f49d89dacf4af37fefc13bab2f1f8e18fb74580d8b0' + .hexToBytes(), ); expect(sessionKey.symmetric, SymmetricAlgorithm.aes256); - final seipd = SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( + final seipd = + SymEncryptedIntegrityProtectedDataPacket.fromBytes(base64.decode( 'AfirtbIE3SaPO19Vq7qe5dMCcqWZbNtVMHeu5vZKBetHnnx/yveQ9brJYlzhJvGskCUJma43+iur/T1sKjE=', )).decrypt(sessionKey.encryptionKey, sessionKey.symmetric); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); }); @@ -271,12 +288,19 @@ void main() { expect(sessionKey.symmetric, skesk.symmetric); final packets = PacketList.decode(PacketList([skesk, seipd]).encode()); - final decryptSkesk = packets.whereType().first.decrypt(password); - final decryptSeipd = packets.whereType().first.decrypt( + final decryptSkesk = packets + .whereType() + .first + .decrypt(password); + final decryptSeipd = packets + .whereType() + .first + .decrypt( decryptSkesk.sessionKey!.encryptionKey, decryptSkesk.sessionKey!.symmetric, ); - final literalData = decryptSeipd.packets!.whereType().first; + final literalData = + decryptSeipd.packets!.whereType().first; expect(literalData.text, literalText); }); @@ -295,12 +319,19 @@ void main() { expect(skesk.symmetric, SymmetricAlgorithm.aes256); final packets = PacketList.decode(PacketList([skesk, seipd]).encode()); - final decryptSkesk = packets.whereType().first.decrypt(password); - final decryptSeipd = packets.whereType().first.decrypt( + final decryptSkesk = packets + .whereType() + .first + .decrypt(password); + final decryptSeipd = packets + .whereType() + .first + .decrypt( decryptSkesk.sessionKey!.encryptionKey, decryptSkesk.sessionKey!.symmetric, ); - final literalData = decryptSeipd.packets!.whereType().first; + final literalData = + decryptSeipd.packets!.whereType().first; expect( decryptSkesk.symmetric, SymmetricAlgorithm.aes256, @@ -330,12 +361,19 @@ void main() { expect(seipd.aead, Config.preferredAead); final packets = PacketList.decode(PacketList([skesk, seipd]).encode()); - final decryptSkesk = packets.whereType().first.decrypt(password); - final decryptSeipd = packets.whereType().first.decrypt( + final decryptSkesk = packets + .whereType() + .first + .decrypt(password); + final decryptSeipd = packets + .whereType() + .first + .decrypt( decryptSkesk.sessionKey!.encryptionKey, decryptSkesk.sessionKey!.symmetric, ); - final literalData = decryptSeipd.packets!.whereType().first; + final literalData = + decryptSeipd.packets!.whereType().first; expect(literalData.text, literalText); }); }); @@ -401,13 +439,20 @@ WUlZSqHRuD/11Hh9WQgbyikT0/HWN6MKUYaC5ozOr4w0KIsCOk2vdOU6ZCbwcZlm+ZJFfE8T1PGu ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -472,14 +517,21 @@ heUWSSwsi+sdLtKcnQQfj/RDqmhO9tmfk8sRTu3Myp9tYJLnjngOxsNEMoRRgo7eBSLVjUQlQu8= ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); final comPacket = seipd.packets!.whereType().first; - final literalData = comPacket.packets.whereType().first; + final literalData = + comPacket.packets.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -514,13 +566,20 @@ PXVtziQ8IyqoGshWNSwpWcPZl9KW2mUBGVIpOtCg0j8BYZTkYDl0D/a62/c1QUyqjpXqgGhzXvuS ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -555,13 +614,20 @@ dJb40maS ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -594,13 +660,20 @@ SdJraH1GfEeeMdV9t8623Gu3xkQ4hXf+figKNUWdq+kwHGqbQQNoeai1TYYNCuY= ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -634,13 +707,20 @@ UQi6XlKOsfRPH6ozJjwLn7nPdfz5pHPtR0QljShJqeM= ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, literalText.toBytes()); }); @@ -681,13 +761,20 @@ ExAnXHXIb8I= ), ), ); - final pkesk = packetList.whereType().first.decrypt(subkey); + final pkesk = packetList + .whereType() + .first + .decrypt(subkey); final sessionKey = pkesk.sessionKey!; - final seipd = packetList.whereType().first.decrypt( + final seipd = packetList + .whereType() + .first + .decrypt( sessionKey.encryptionKey, sessionKey.symmetric, ); - final literalData = seipd.packets!.whereType().first; + final literalData = + seipd.packets!.whereType().first; expect(literalData.binary, 'Hello there'.toBytes()); }); @@ -747,14 +834,16 @@ EWbTE/ndfIE+i/dP8vgD2SGqAKyz4XmyABqt/Ry5idusd89FgIK6QNZDbI1xF5KImRjyyiBqHt4a expect(publicSubkey.keyAlgorithm, KeyAlgorithm.rsaEncryptSign); expect(publicSubkey.fingerprint, secretSubkey.fingerprint); - final encryptedPkesk = PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( + final encryptedPkesk = + PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( publicSubkey, sessionKey, ); final decryptedPkesk = PublicKeyEncryptedSessionKeyPacket.fromBytes( encryptedPkesk.data, ).decrypt(secretSubkey); - expect(decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); + expect( + decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); }); test('Encrypt session key with ECDH NIST P-384 subkey', () { @@ -788,14 +877,16 @@ CQABf19UJNkpedSjrDT3bwSSzOlI8/uyJzKkqF5z26O2i+UbQ/VYIK78pSWB5/YNCfpTHRn5 expect(publicSubkey.keyAlgorithm, KeyAlgorithm.ecdh); expect(publicSubkey.fingerprint, secretSubkey.fingerprint); - final encryptedPkesk = PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( + final encryptedPkesk = + PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( publicSubkey, sessionKey, ); final decryptedPkesk = PublicKeyEncryptedSessionKeyPacket.fromBytes( encryptedPkesk.data, ).decrypt(secretSubkey); - expect(decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); + expect( + decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); }); test('Encrypt session key with ECDH Brainpool P-256 subkey', () { @@ -828,14 +919,16 @@ JezusZoe4R0RBg== expect(publicSubkey.keyAlgorithm, KeyAlgorithm.ecdh); expect(publicSubkey.fingerprint, secretSubkey.fingerprint); - final encryptedPkesk = PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( + final encryptedPkesk = + PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( publicSubkey, sessionKey, ); final decryptedPkesk = PublicKeyEncryptedSessionKeyPacket.fromBytes( encryptedPkesk.data, ).decrypt(secretSubkey); - expect(decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); + expect( + decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); }); test('Encrypt session key with ECDH x25519 subkey', () { @@ -866,14 +959,16 @@ AP9/8RTxulNe64U7qvtO4JhL2hWCn8UQerIAGIlukzE6UBCu expect(publicSubkey.keyAlgorithm, KeyAlgorithm.ecdh); expect(publicSubkey.fingerprint, secretSubkey.fingerprint); - final encryptedPkesk = PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( + final encryptedPkesk = + PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( publicSubkey, sessionKey, ); final decryptedPkesk = PublicKeyEncryptedSessionKeyPacket.fromBytes( encryptedPkesk.data, ).decrypt(secretSubkey); - expect(decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); + expect( + decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); }); test('Encrypt session key with x25519 rfc9580 subkey', () { @@ -904,14 +999,16 @@ BmOHf+MZAAAAIIaTJINn+eUBXbki+PSAld2nhJh/LVmFsS+60WyvXkQ1AE1gCk95TUR3XFeibg/u expect(publicSubkey.keyAlgorithm, KeyAlgorithm.x25519); expect(publicSubkey.fingerprint, secretSubkey.fingerprint); - final encryptedPkesk = PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( + final encryptedPkesk = + PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( publicSubkey, sessionKey, ); final decryptedPkesk = PublicKeyEncryptedSessionKeyPacket.fromBytes( encryptedPkesk.data, ).decrypt(secretSubkey); - expect(decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); + expect( + decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); }); test('Encrypt session key with x448 rfc9580 subkey', () { @@ -944,14 +1041,16 @@ BsL8GXscLICI expect(publicSubkey.keyAlgorithm, KeyAlgorithm.x448); expect(publicSubkey.fingerprint, secretSubkey.fingerprint); - final encryptedPkesk = PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( + final encryptedPkesk = + PublicKeyEncryptedSessionKeyPacket.encryptSessionKey( publicSubkey, sessionKey, ); final decryptedPkesk = PublicKeyEncryptedSessionKeyPacket.fromBytes( encryptedPkesk.data, ).decrypt(secretSubkey); - expect(decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); + expect( + decryptedPkesk.sessionKey!.encryptionKey, sessionKey.encryptionKey); }); }); } diff --git a/test/packet/key_packet_test.dart b/test/packet/key_packet_test.dart index 3baa4528..a52e9677 100644 --- a/test/packet/key_packet_test.dart +++ b/test/packet/key_packet_test.dart @@ -220,7 +220,8 @@ BGc/+dASCSskAwMCCAEBBwIDBGuDRKYwfAtThNOAM51Is4J1BYPN6qZCTN0c9ldSQzGSVO0lI/BV }); test('Curve 25519 legacy keys', () { - const keyPacket = 'BGc/+gYWCSsGAQQB2kcPAQEHQGUAHTxwcB6TD72goFQpLf3jAqdbm1cZwv1N2mjBffEg'; + const keyPacket = + 'BGc/+gYWCSsGAQQB2kcPAQEHQGUAHTxwcB6TD72goFQpLf3jAqdbm1cZwv1N2mjBffEg'; final publicKey = PublicKeyPacket.fromBytes( base64.decode(keyPacket), ); @@ -234,7 +235,8 @@ BGc/+dASCSskAwMCCAEBBwIDBGuDRKYwfAtThNOAM51Is4J1BYPN6qZCTN0c9ldSQzGSVO0lI/BV expect(publicKey.keyStrength, 255); expect(keyMaterial.curve, Ecc.ed25519); - const subkeyPacket = 'BGc/+gYSCisGAQQBl1UBBQEBB0AJwaWfEiJqlOIk/O9i2PMaDBmbRUOBHGQdFRPKbifpfwMBCAc='; + const subkeyPacket = + 'BGc/+gYSCisGAQQBl1UBBQEBB0AJwaWfEiJqlOIk/O9i2PMaDBmbRUOBHGQdFRPKbifpfwMBCAc='; final publicSubkey = PublicSubkeyPacket.fromBytes( base64.decode(subkeyPacket), ); @@ -251,7 +253,8 @@ BGc/+dASCSskAwMCCAEBBwIDBGuDRKYwfAtThNOAM51Is4J1BYPN6qZCTN0c9ldSQzGSVO0lI/BV }); test('Curve 25519 rfc9580 keys', () { - const keyPacket = 'BmOHf+MbAAAAIPlNp7tI1gph5WdwamWH0DMZmbudiRoIJC6thFQ9+JWj'; + const keyPacket = + 'BmOHf+MbAAAAIPlNp7tI1gph5WdwamWH0DMZmbudiRoIJC6thFQ9+JWj'; final publicKey = PublicKeyPacket.fromBytes( base64.decode(keyPacket), ); @@ -263,7 +266,8 @@ BGc/+dASCSskAwMCCAEBBwIDBGuDRKYwfAtThNOAM51Is4J1BYPN6qZCTN0c9ldSQzGSVO0lI/BV expect(publicKey.keyVersion, 6); expect(publicKey.keyStrength, 255); - const subkeyPacket = 'BmOHf+MZAAAAIIaTJINn+eUBXbki+PSAld2nhJh/LVmFsS+60WyvXkQ1'; + const subkeyPacket = + 'BmOHf+MZAAAAIIaTJINn+eUBXbki+PSAld2nhJh/LVmFsS+60WyvXkQ1'; final publicSubkey = PublicSubkeyPacket.fromBytes( base64.decode(subkeyPacket), ); @@ -278,7 +282,8 @@ BGc/+dASCSskAwMCCAEBBwIDBGuDRKYwfAtThNOAM51Is4J1BYPN6qZCTN0c9ldSQzGSVO0lI/BV }); test('Curve 448 rfc9580 keys', () { - const keyPacket = 'BmbzbxMcAAAAOclr6WO01hRcPLq6+/O0G+HA8hfV+fWyej4w7y9j6Im19Y5lOhbn99B0mZ0i6ggJLxcf/wPqwG3hAA=='; + const keyPacket = + 'BmbzbxMcAAAAOclr6WO01hRcPLq6+/O0G+HA8hfV+fWyej4w7y9j6Im19Y5lOhbn99B0mZ0i6ggJLxcf/wPqwG3hAA=='; final publicKey = PublicKeyPacket.fromBytes( base64.decode(keyPacket), ); @@ -290,7 +295,8 @@ BGc/+dASCSskAwMCCAEBBwIDBGuDRKYwfAtThNOAM51Is4J1BYPN6qZCTN0c9ldSQzGSVO0lI/BV expect(publicKey.keyVersion, 6); expect(publicKey.keyStrength, 448); - const subkeyPacket = 'BmbzbxMaAAAAOJa5nnjGcHsLaqmdVTiX+7/V12+ROn+wufLdRd1egnJCCGBhvN7XDPd50Em1ZtAbYgbCsR+C8zgZ'; + const subkeyPacket = + 'BmbzbxMaAAAAOJa5nnjGcHsLaqmdVTiX+7/V12+ROn+wufLdRd1egnJCCGBhvN7XDPd50Em1ZtAbYgbCsR+C8zgZ'; final publicSubkey = PublicSubkeyPacket.fromBytes( base64.decode(subkeyPacket), ); diff --git a/test/packet/user_packet_test.dart b/test/packet/user_packet_test.dart index e5c55161..9ad760de 100644 --- a/test/packet/user_packet_test.dart +++ b/test/packet/user_packet_test.dart @@ -27,9 +27,11 @@ void main() { })); test('user attribute test', (() { - final imageData = Uint8List.fromList(faker.randomGenerator.numbers(255, 100)); + final imageData = + Uint8List.fromList(faker.randomGenerator.numbers(255, 100)); final subpacketType = faker.randomGenerator.integer(100); - final subpacketData = utf8.encoder.convert(faker.lorem.words(100).join(' ')); + final subpacketData = + utf8.encoder.convert(faker.lorem.words(100).join(' ')); final userAttr = UserAttributePacket.fromBytes(UserAttributePacket([ ImageUserAttribute.fromBytes(imageData),