From a04c0ff1432aae73846e4db46001ae9340840aef Mon Sep 17 00:00:00 2001 From: AquibAquil Date: Thu, 16 Jul 2026 16:07:48 +0530 Subject: [PATCH 1/3] chore: mark unsupported code paths with coverage:ignore --- lib/src/boringssl/lookup/utils.dart | 2 ++ lib/src/impl_ffi/impl_ffi.aes_common.dart | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/src/boringssl/lookup/utils.dart b/lib/src/boringssl/lookup/utils.dart index 899929b79..873719258 100644 --- a/lib/src/boringssl/lookup/utils.dart +++ b/lib/src/boringssl/lookup/utils.dart @@ -29,10 +29,12 @@ String get libraryFileName { if (Platform.isMacOS) { return 'lib$libraryName.dylib'; } + // coverage:ignore-start throw UnsupportedError( 'Platform ${Platform.operatingSystem} is unsupported or embed ' 'the binary webcrypto library for package:webcrypto', ); + // coverage:ignore-end } /// Look for the webcrypto binary library in the `.dart_tool/webcrypto/` folder. diff --git a/lib/src/impl_ffi/impl_ffi.aes_common.dart b/lib/src/impl_ffi/impl_ffi.aes_common.dart index 219267f74..3d22f6008 100644 --- a/lib/src/impl_ffi/impl_ffi.aes_common.dart +++ b/lib/src/impl_ffi/impl_ffi.aes_common.dart @@ -18,7 +18,9 @@ Uint8List _aesImportRawKey(List keyData) { if (keyData.length == 24) { // 192-bit AES is intentionally unsupported, see https://crbug.com/533699 // If not supported in Chrome, there is not reason to support it in Dart. + // coverage:ignore-start throw UnsupportedError('192-bit AES keys are not supported'); + // coverage:ignore-end } if (keyData.length != 16 && keyData.length != 32) { throw const FormatException('keyData for AES must be 128 or 256 bits'); @@ -43,7 +45,9 @@ Uint8List _aesImportJwkKey( if (keyData.length == 24) { // 192-bit AES is intentionally unsupported, see https://crbug.com/533699 // If not supported in Chrome, there is not reason to support it in Dart. + // coverage:ignore-start throw UnsupportedError('192-bit AES keys are not supported'); + // coverage:ignore-end } checkJwk( keyData.length == 16 || keyData.length == 32, @@ -82,7 +86,9 @@ Uint8List _aesGenerateKey(int length) { if (length == 192) { // 192-bit AES is intentionally unsupported, see https://crbug.com/533699 // If not supported in Chrome, there is not reason to support it in Dart. + // coverage:ignore-start throw UnsupportedError('192-bit AES keys are not supported'); + // coverage:ignore-end } if (length != 128 && length != 256) { throw const FormatException('keyData for AES must be 128 or 256 bits'); From 3e0ba4f10eed06035c9c2f8aed2d757b08f3c345 Mon Sep 17 00:00:00 2001 From: AquibAquil Date: Thu, 16 Jul 2026 17:34:40 +0530 Subject: [PATCH 2/3] test: mark impl_stub as coverage:ignore-file --- lib/src/impl_stub/impl_stub.aescbc.dart | 1 + lib/src/impl_stub/impl_stub.aesctr.dart | 1 + lib/src/impl_stub/impl_stub.aesgcm.dart | 1 + lib/src/impl_stub/impl_stub.dart | 1 + lib/src/impl_stub/impl_stub.digest.dart | 1 + lib/src/impl_stub/impl_stub.ecdh.dart | 1 + lib/src/impl_stub/impl_stub.ecdsa.dart | 1 + lib/src/impl_stub/impl_stub.hkdf.dart | 1 + lib/src/impl_stub/impl_stub.hmac.dart | 1 + lib/src/impl_stub/impl_stub.pbkdf2.dart | 1 + lib/src/impl_stub/impl_stub.random.dart | 1 + lib/src/impl_stub/impl_stub.rsaoaep.dart | 1 + lib/src/impl_stub/impl_stub.rsapss.dart | 1 + lib/src/impl_stub/impl_stub.rsassapkcs1v15.dart | 1 + 14 files changed, 14 insertions(+) diff --git a/lib/src/impl_stub/impl_stub.aescbc.dart b/lib/src/impl_stub/impl_stub.aescbc.dart index a6bf3634a..d27b2755f 100644 --- a/lib/src/impl_stub/impl_stub.aescbc.dart +++ b/lib/src/impl_stub/impl_stub.aescbc.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticAesCbcSecretKeyImpl implements StaticAesCbcSecretKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.aesctr.dart b/lib/src/impl_stub/impl_stub.aesctr.dart index 1a7e9f42f..a4f0b2901 100644 --- a/lib/src/impl_stub/impl_stub.aesctr.dart +++ b/lib/src/impl_stub/impl_stub.aesctr.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticAesCtrSecretKeyImpl implements StaticAesCtrSecretKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.aesgcm.dart b/lib/src/impl_stub/impl_stub.aesgcm.dart index 58dee35f3..ab7f48b1b 100644 --- a/lib/src/impl_stub/impl_stub.aesgcm.dart +++ b/lib/src/impl_stub/impl_stub.aesgcm.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticAesGcmSecretKeyImpl implements StaticAesGcmSecretKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.dart b/lib/src/impl_stub/impl_stub.dart index c8411eef2..52680a082 100644 --- a/lib/src/impl_stub/impl_stub.dart +++ b/lib/src/impl_stub/impl_stub.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file library; import 'dart:typed_data'; diff --git a/lib/src/impl_stub/impl_stub.digest.dart b/lib/src/impl_stub/impl_stub.digest.dart index 6404d2278..a33b6a435 100644 --- a/lib/src/impl_stub/impl_stub.digest.dart +++ b/lib/src/impl_stub/impl_stub.digest.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _HashImpl implements HashImpl { diff --git a/lib/src/impl_stub/impl_stub.ecdh.dart b/lib/src/impl_stub/impl_stub.ecdh.dart index 4c79a082f..b94233888 100644 --- a/lib/src/impl_stub/impl_stub.ecdh.dart +++ b/lib/src/impl_stub/impl_stub.ecdh.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticEcdhPrivateKeyImpl implements StaticEcdhPrivateKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.ecdsa.dart b/lib/src/impl_stub/impl_stub.ecdsa.dart index 34f43a3db..5784badf7 100644 --- a/lib/src/impl_stub/impl_stub.ecdsa.dart +++ b/lib/src/impl_stub/impl_stub.ecdsa.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticEcdsaPrivateKeyImpl implements StaticEcdsaPrivateKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.hkdf.dart b/lib/src/impl_stub/impl_stub.hkdf.dart index 1e07cead7..20b863cd9 100644 --- a/lib/src/impl_stub/impl_stub.hkdf.dart +++ b/lib/src/impl_stub/impl_stub.hkdf.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticHkdfSecretKeyImpl implements StaticHkdfSecretKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.hmac.dart b/lib/src/impl_stub/impl_stub.hmac.dart index b39310a7c..e4eef5e2e 100644 --- a/lib/src/impl_stub/impl_stub.hmac.dart +++ b/lib/src/impl_stub/impl_stub.hmac.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticHmacSecretKeyImpl implements StaticHmacSecretKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.pbkdf2.dart b/lib/src/impl_stub/impl_stub.pbkdf2.dart index e1fc586fd..03ddcd998 100644 --- a/lib/src/impl_stub/impl_stub.pbkdf2.dart +++ b/lib/src/impl_stub/impl_stub.pbkdf2.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticPbkdf2SecretKeyImpl implements StaticPbkdf2SecretKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.random.dart b/lib/src/impl_stub/impl_stub.random.dart index c7f13fa87..f094a2126 100644 --- a/lib/src/impl_stub/impl_stub.random.dart +++ b/lib/src/impl_stub/impl_stub.random.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _RandomImpl implements RandomImpl { diff --git a/lib/src/impl_stub/impl_stub.rsaoaep.dart b/lib/src/impl_stub/impl_stub.rsaoaep.dart index a3daef976..c37d8f42c 100644 --- a/lib/src/impl_stub/impl_stub.rsaoaep.dart +++ b/lib/src/impl_stub/impl_stub.rsaoaep.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticRsaOaepPrivateKeyImpl diff --git a/lib/src/impl_stub/impl_stub.rsapss.dart b/lib/src/impl_stub/impl_stub.rsapss.dart index ac8fbd435..78d30690d 100644 --- a/lib/src/impl_stub/impl_stub.rsapss.dart +++ b/lib/src/impl_stub/impl_stub.rsapss.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticRsaPssPrivateKeyImpl implements StaticRsaPssPrivateKeyImpl { diff --git a/lib/src/impl_stub/impl_stub.rsassapkcs1v15.dart b/lib/src/impl_stub/impl_stub.rsassapkcs1v15.dart index 558e51d91..02e660684 100644 --- a/lib/src/impl_stub/impl_stub.rsassapkcs1v15.dart +++ b/lib/src/impl_stub/impl_stub.rsassapkcs1v15.dart @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// coverage:ignore-file part of 'impl_stub.dart'; final class _StaticRsaSsaPkcs1V15PrivateKeyImpl From 1b0d8d4058f9c21fe8511d53899657e735bec217 Mon Sep 17 00:00:00 2001 From: AquibAquil Date: Thu, 16 Jul 2026 17:42:58 +0530 Subject: [PATCH 3/3] test: ignore unreachable curve fallbacks in EC helpers --- lib/src/impl_ffi/impl_ffi.ec_common.dart | 6 ++++++ lib/src/impl_ffi/impl_ffi.ecdsa.dart | 2 ++ lib/src/impl_js/impl_js.utils.dart | 2 ++ 3 files changed, 10 insertions(+) diff --git a/lib/src/impl_ffi/impl_ffi.ec_common.dart b/lib/src/impl_ffi/impl_ffi.ec_common.dart index 5e9652b4c..a71474b32 100644 --- a/lib/src/impl_ffi/impl_ffi.ec_common.dart +++ b/lib/src/impl_ffi/impl_ffi.ec_common.dart @@ -26,7 +26,9 @@ int _ecCurveToNID(EllipticCurve curve) { return NID_secp521r1; } // This should never happen! + // coverage:ignore-start throw UnsupportedError('curve "$curve" is not supported'); + // coverage:ignore-end } /// Get [EllipticCurve] from matching BoringSSL `ssl.NID_...`. @@ -41,7 +43,9 @@ EllipticCurve _ecCurveFromNID(int nid) { return EllipticCurve.p521; } // This should never happen! + // coverage:ignore-start throw operationError('internal error detecting curve'); + // coverage:ignore-end } String _ecCurveToJwkCrv(EllipticCurve curve) { @@ -55,7 +59,9 @@ String _ecCurveToJwkCrv(EllipticCurve curve) { return 'P-521'; } // This should never happen! + // coverage:ignore-start throw UnsupportedError('curve "$curve" is not supported'); + // coverage:ignore-end } /// Perform some post-import validation for EC keys. diff --git a/lib/src/impl_ffi/impl_ffi.ecdsa.dart b/lib/src/impl_ffi/impl_ffi.ecdsa.dart index ba399eb64..f3c560239 100644 --- a/lib/src/impl_ffi/impl_ffi.ecdsa.dart +++ b/lib/src/impl_ffi/impl_ffi.ecdsa.dart @@ -29,7 +29,9 @@ String _ecdsaCurveToJwkAlg(EllipticCurve curve) { return 'ES512'; } // This should never happen! + // coverage:ignore-start throw UnsupportedError('curve "$curve" is not supported'); + // coverage:ignore-end } Future ecdsaPrivateKey_importPkcs8Key( diff --git a/lib/src/impl_js/impl_js.utils.dart b/lib/src/impl_js/impl_js.utils.dart index 81e231d22..53ca306be 100644 --- a/lib/src/impl_js/impl_js.utils.dart +++ b/lib/src/impl_js/impl_js.utils.dart @@ -45,8 +45,10 @@ String _curveToName(EllipticCurve curve) { return 'P-521'; } // This should never happen. + // coverage:ignore-start // ignore: dead_code throw AssertionError('Unknown curve "$curve"'); + // coverage:ignore-end } Object _translateDomException(