Skip to content

Commit b8f6aeb

Browse files
authored
Remove comment about EC PKCS #8 not working on Firefox, and add tests (#117)
* Remove comment about EC PKCS #8 not working on Firefox, and add tests * Disable `flutter test --platform chrome`
1 parent e0c1734 commit b8f6aeb

File tree

5 files changed

+9
-30
lines changed

5 files changed

+9
-30
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
- run: flutter pub get
8282
- run: flutter pub run webcrypto:setup
8383
- run: flutter test
84-
- run: flutter test --platform chrome
84+
#- run: flutter test --platform chrome
8585
- run: flutter test integration_test/webcrypto_test.dart -d windows
8686
working-directory: ./example
8787
- uses: nanasess/setup-chromedriver@v2

lib/src/testing/webcrypto/ecdh.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,9 @@ final runner = TestRunner.asymmetric<EcdhPrivateKey, EcdhPublicKey>(
3131
algorithm: 'ECDH',
3232
importPrivateRawKey: null, // not supported
3333
exportPrivateRawKey: null,
34-
// HACK: PKCS8 is not support for ECDH / ECDSA on firefox:
35-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1133698
36-
//
37-
// So filter away PKCS8 test data and functions when running on gecko.
38-
importPrivatePkcs8Key: nullOnFirefox((keyData, keyImportParams) =>
39-
EcdhPrivateKey.importPkcs8Key(keyData, curveFromJson(keyImportParams))),
40-
exportPrivatePkcs8Key: nullOnFirefox((key) => key.exportPkcs8Key()),
34+
importPrivatePkcs8Key: (keyData, keyImportParams) =>
35+
EcdhPrivateKey.importPkcs8Key(keyData, curveFromJson(keyImportParams)),
36+
exportPrivatePkcs8Key: (key) => key.exportPkcs8Key(),
4137
importPrivateJsonWebKey: (jsonWebKeyData, keyImportParams) =>
4238
EcdhPrivateKey.importJsonWebKey(
4339
jsonWebKeyData, curveFromJson(keyImportParams)),
@@ -70,10 +66,7 @@ final runner = TestRunner.asymmetric<EcdhPrivateKey, EcdhPublicKey>(
7066
length,
7167
keys.publicKey,
7268
),
73-
testData: _testData.map((c) => {
74-
...c,
75-
'privatePkcs8KeyData': nullOnFirefox(c['privatePkcs8KeyData']),
76-
}),
69+
testData: _testData,
7770
);
7871

7972
void main() async {

lib/src/testing/webcrypto/ecdsa.dart

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@
1515
import 'package:webcrypto/webcrypto.dart';
1616
import '../utils/utils.dart';
1717
import '../utils/testrunner.dart';
18-
import '../utils/detected_runtime.dart';
1918

2019
final runner = TestRunner.asymmetric<EcdsaPrivateKey, EcdsaPublicKey>(
2120
algorithm: 'ECDSA',
2221
importPrivateRawKey: null, // not supported
2322
exportPrivateRawKey: null,
24-
// HACK: PKCS8 is not support for ECDH / ECDSA on firefox:
25-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1133698
26-
//
27-
// So filter away PKCS8 test data and functions when running on gecko.
28-
importPrivatePkcs8Key: nullOnFirefox((keyData, keyImportParams) =>
29-
EcdsaPrivateKey.importPkcs8Key(keyData, curveFromJson(keyImportParams))),
30-
exportPrivatePkcs8Key: nullOnFirefox((key) => key.exportPkcs8Key()),
23+
importPrivatePkcs8Key: (keyData, keyImportParams) =>
24+
EcdsaPrivateKey.importPkcs8Key(keyData, curveFromJson(keyImportParams)),
25+
exportPrivatePkcs8Key: (key) => key.exportPkcs8Key(),
3126
importPrivateJsonWebKey: (jsonWebKeyData, keyImportParams) =>
3227
EcdsaPrivateKey.importJsonWebKey(
3328
jsonWebKeyData, curveFromJson(keyImportParams)),
@@ -53,10 +48,7 @@ final runner = TestRunner.asymmetric<EcdsaPrivateKey, EcdsaPublicKey>(
5348
key.verifyBytes(signature, data, hashFromJson(verifyParams)),
5449
verifyStream: (key, signature, data, verifyParams) =>
5550
key.verifyStream(signature, data, hashFromJson(verifyParams)),
56-
testData: _testData.map((c) => {
57-
...c,
58-
'privatePkcs8KeyData': nullOnFirefox(c['privatePkcs8KeyData']),
59-
}),
51+
testData: _testData,
6052
);
6153

6254
void main() async {

lib/src/webcrypto/webcrypto.ecdh.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ part of 'webcrypto.dart';
1818
abstract class EcdhPrivateKey {
1919
EcdhPrivateKey._(); // keep the constructor private.
2020

21-
// Note. unsupported on Firefox, see EcdsaPrivateKey.importPkcs8Key
2221
static Future<EcdhPrivateKey> importPkcs8Key(
2322
List<int> keyData,
2423
EllipticCurve curve,
@@ -48,7 +47,6 @@ abstract class EcdhPrivateKey {
4847
// https://tools.ietf.org/html/rfc6090#appendix-B
4948
Future<Uint8List> deriveBits(int length, EcdhPublicKey publicKey);
5049

51-
// Note. unsupported on Firefox, see EcdsaPrivateKey.importPkcs8Key
5250
Future<Uint8List> exportPkcs8Key();
5351

5452
Future<Map<String, dynamic>> exportJsonWebKey();

lib/src/webcrypto/webcrypto.ecdsa.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ part of 'webcrypto.dart';
1818
abstract class EcdsaPrivateKey {
1919
EcdsaPrivateKey._(); // keep the constructor private.
2020

21-
// TODO: document or workaround pkcs8 being unsupported on Firefox:
22-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1133698
23-
// See: https://github.com/callstats-io/pem-to-jwk/blob/master/index.js#L126
2421
static Future<EcdsaPrivateKey> importPkcs8Key(
2522
List<int> keyData,
2623
EllipticCurve curve,
@@ -48,7 +45,6 @@ abstract class EcdsaPrivateKey {
4845
Future<Uint8List> signBytes(List<int> data, Hash hash);
4946
Future<Uint8List> signStream(Stream<List<int>> data, Hash hash);
5047

51-
// Note. unsupported on Firefox, see EcdsaPrivateKey.importPkcs8Key
5248
Future<Uint8List> exportPkcs8Key();
5349

5450
Future<Map<String, dynamic>> exportJsonWebKey();

0 commit comments

Comments
 (0)