Skip to content

Commit 084db0d

Browse files
authored
Merge branch 'master' into refactor-rsaoaep
2 parents 0a93df6 + cdf81ad commit 084db0d

File tree

12 files changed

+104
-25
lines changed

12 files changed

+104
-25
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ jobs:
5656
- run: flutter test --platform chrome
5757
- run: flutter test integration_test/webcrypto_test.dart -d macos
5858
working-directory: ./example
59-
- uses: nanasess/setup-chromedriver@v2
60-
- name: Run integration_test with chromedriver
61-
working-directory: ./example
62-
run: |
63-
../tool/with-chromedriver.sh flutter drive \
64-
--driver=test_driver/integration_test.dart \
65-
--target=integration_test/webcrypto_test.dart \
66-
-d chrome
59+
# TODO: Enable chromdriver testing on MacOS when it works reliably
60+
#- uses: nanasess/setup-chromedriver@v2
61+
#- name: Run integration_test with chromedriver
62+
# working-directory: ./example
63+
# run: |
64+
# ../tool/with-chromedriver.sh flutter drive \
65+
# --driver=test_driver/integration_test.dart \
66+
# --target=integration_test/webcrypto_test.dart \
67+
# -d chrome
6768
- run: flutter pub run test -p vm,chrome # TODO: Enable firefox if it works
6869
windows:
6970
name: webcrypto on Windows desktop / Chrome / Firefox

darwin/webcrypto.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Pod::Spec.new do |s|
2828
s.compiler_flags = [
2929
'-DOPENSSL_NO_ASM',
3030
'-DDOPENSSL_SMALL',
31-
'-GCC_WARN_INHIBIT_ALL_WARNINGS',
3231
'-w',
3332
]
3433

lib/src/impl_ffi/impl_ffi.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ final class _WebCryptoImpl implements WebCryptoImpl {
9292

9393
@override
9494
final rsaOaepPublicKey = const _StaticRsaOaepPublicKeyImpl();
95+
96+
@override
97+
final pbkdf2SecretKey = const _StaticPbkdf2SecretKeyImpl();
9598
}

lib/src/impl_ffi/impl_ffi.pbkdf2.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@
1616

1717
part of 'impl_ffi.dart';
1818

19-
Future<Pbkdf2SecretKey> pbkdf2SecretKey_importRawKey(List<int> keyData) async {
20-
return _Pbkdf2SecretKey(Uint8List.fromList(keyData));
19+
Future<Pbkdf2SecretKeyImpl> pbkdf2SecretKey_importRawKey(List<int> keyData) async {
20+
return _Pbkdf2SecretKeyImpl(Uint8List.fromList(keyData));
2121
}
2222

23-
class _Pbkdf2SecretKey implements Pbkdf2SecretKey {
23+
final class _StaticPbkdf2SecretKeyImpl implements StaticPbkdf2SecretKeyImpl {
24+
const _StaticPbkdf2SecretKeyImpl();
25+
26+
@override
27+
Future<Pbkdf2SecretKeyImpl> importRawKey(List<int> keyData) {
28+
return pbkdf2SecretKey_importRawKey(keyData);
29+
}
30+
}
31+
32+
final class _Pbkdf2SecretKeyImpl implements Pbkdf2SecretKeyImpl {
2433
final Uint8List _key;
2534

26-
_Pbkdf2SecretKey(this._key);
35+
_Pbkdf2SecretKeyImpl(this._key);
2736

2837
@override
2938
String toString() {

lib/src/impl_interface/impl_interface.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ part 'impl_interface.aescbc.dart';
2424
part 'impl_interface.aesctr.dart';
2525
part 'impl_interface.hmac.dart';
2626
part 'impl_interface.rsaoaep.dart';
27+
part 'impl_interface.pbkdf2.dart';
2728
part 'impl_interface.aesgcm.dart';
2829

2930
/// Interface to be provided by platform implementations.
@@ -49,4 +50,5 @@ abstract interface class WebCryptoImpl {
4950
StaticHmacSecretKeyImpl get hmacSecretKey;
5051
StaticRsaOaepPrivateKeyImpl get rsaOaepPrivateKey;
5152
StaticRsaOaepPublicKeyImpl get rsaOaepPublicKey;
53+
StaticPbkdf2SecretKeyImpl get pbkdf2SecretKey;
5254
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
part of 'impl_interface.dart';
16+
17+
abstract interface class StaticPbkdf2SecretKeyImpl {
18+
Future<Pbkdf2SecretKeyImpl> importRawKey(List<int> keyData);
19+
}
20+
21+
abstract interface class Pbkdf2SecretKeyImpl {
22+
Future<Uint8List> deriveBits(int length, Hash hash, List<int> salt, int iterations);
23+
}

lib/src/impl_js/impl_js.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@ final class _WebCryptoImpl implements WebCryptoImpl {
7878

7979
@override
8080
final rsaOaepPublicKey = const _StaticRsaOaepPublicKeyImpl();
81+
82+
@override
83+
final pbkdf2SecretKey = const _StaticPbkdf2SecretKeyImpl();
8184
}

lib/src/impl_js/impl_js.pbkdf2.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ part of 'impl_js.dart';
1818

1919
const _pbkdf2AlgorithmName = 'PBKDF2';
2020

21-
Future<Pbkdf2SecretKey> pbkdf2SecretKey_importRawKey(List<int> keyData) async {
22-
return _Pbkdf2SecretKey(await _importKey(
21+
Future<Pbkdf2SecretKeyImpl> pbkdf2SecretKey_importRawKey(List<int> keyData) async {
22+
return _Pbkdf2SecretKeyImpl(await _importKey(
2323
'raw',
2424
keyData,
2525
const subtle.Algorithm(name: _pbkdf2AlgorithmName),
@@ -31,9 +31,18 @@ Future<Pbkdf2SecretKey> pbkdf2SecretKey_importRawKey(List<int> keyData) async {
3131
));
3232
}
3333

34-
class _Pbkdf2SecretKey implements Pbkdf2SecretKey {
34+
final class _StaticPbkdf2SecretKeyImpl implements StaticPbkdf2SecretKeyImpl {
35+
const _StaticPbkdf2SecretKeyImpl();
36+
37+
@override
38+
Future<Pbkdf2SecretKeyImpl> importRawKey(List<int> keyData) {
39+
return pbkdf2SecretKey_importRawKey(keyData);
40+
}
41+
}
42+
43+
final class _Pbkdf2SecretKeyImpl implements Pbkdf2SecretKeyImpl {
3544
final subtle.JSCryptoKey _key;
36-
_Pbkdf2SecretKey(this._key);
45+
_Pbkdf2SecretKeyImpl(this._key);
3746

3847
@override
3948
String toString() {

lib/src/impl_stub.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,3 @@ Future<HkdfSecretKey> hkdfSecretKey_importRawKey(List<int> keyData) =>
202202

203203
//---------------------- PBKDF2
204204

205-
Future<Pbkdf2SecretKey> pbkdf2SecretKey_importRawKey(List<int> keyData) =>
206-
throw _notImplemented;

lib/src/impl_stub/impl_stub.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ part 'impl_stub.aesctr.dart';
2222
part 'impl_stub.aesgcm.dart';
2323
part 'impl_stub.hmac.dart';
2424
part 'impl_stub.rsaoaep.dart';
25+
part 'impl_stub.pbkdf2.dart';
2526

2627
const WebCryptoImpl webCryptImpl = _WebCryptoImpl();
2728

@@ -45,4 +46,7 @@ final class _WebCryptoImpl implements WebCryptoImpl {
4546

4647
@override
4748
final rsaOaepPublicKey = const _StaticRsaOaepPublicKeyImpl();
49+
50+
@override
51+
final pbkdf2SecretKey = const _StaticPbkdf2SecretKeyImpl();
4852
}

0 commit comments

Comments
 (0)