Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add IV params in EnrollParams and enroll verb builder #727

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 5.1.1
- fix: Introduce IV params for apkam enrollment flow
## 5.1.0
- feat: Introduce skipDeletesUntil for sync:from verb
## 5.0.2
Expand Down
2 changes: 2 additions & 0 deletions packages/at_commons/lib/src/at_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class AtConstants {
'encryptedDefaultEncPrivateKey';
static const String apkamEncryptedDefaultSelfEncryptionKey =
'encryptedDefaultSelfEncryptionKey';
static const String apkamEncryptionPrivateKeyIV = 'encPrivateKeyIV';
static const String apkamEncryptedSymmetricKey = 'encryptedApkamSymmetricKey';
static const String apkamSelfEncryptionKeyIV = 'selfEncKeyIV';
static const String apkamPublicKey = 'apkamPublicKey';
static const String apkamNamespaces = 'namespaces';
static const String defaultEncryptionPrivateKey = 'default_enc_private_key';
Expand Down
2 changes: 2 additions & 0 deletions packages/at_commons/lib/src/verb/enroll_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class EnrollParams {
Map<String, String>? namespaces;
String? otp;
String? encryptedDefaultEncryptionPrivateKey;
String? encPrivateKeyIV;
String? encryptedDefaultSelfEncryptionKey;
String? selfEncKeyIV;
String? encryptedAPKAMSymmetricKey;
String? apkamPublicKey;
List<EnrollmentStatus>? enrollmentStatusFilter;
Expand Down
6 changes: 6 additions & 0 deletions packages/at_commons/lib/src/verb/enroll_params.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/at_commons/lib/src/verb/enroll_verb_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
String? encryptedDefaultEncryptedPrivateKey;

String? encryptedDefaultEncryptionPrivateKey;

/// Initialisation vector used during symmetric encryption of the default encryption key.
String? encPrivateKeyIV;

String? encryptedDefaultSelfEncryptionKey;

/// Initialisation vector used during symmetric encryption of the default self encryption key.
String? selfEncKeyIV;

String? encryptedAPKAMSymmetricKey;

/// Used to force revoke the enrollment request.
Expand Down Expand Up @@ -64,7 +72,9 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
..namespaces = namespaces
..encryptedDefaultEncryptionPrivateKey =
encryptedDefaultEncryptionPrivateKey
..encPrivateKeyIV = encPrivateKeyIV
..encryptedDefaultSelfEncryptionKey = encryptedDefaultSelfEncryptionKey
..selfEncKeyIV = selfEncKeyIV
..encryptedAPKAMSymmetricKey = encryptedAPKAMSymmetricKey
..enrollmentStatusFilter = enrollmentStatusFilter
..apkamKeysExpiryDuration = apkamKeysExpiryDuration;
Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_commons
description: A library of Dart and Flutter utility classes that are used across other components of the atPlatform.
version: 5.1.0
version: 5.1.1
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
6 changes: 4 additions & 2 deletions packages/at_commons/test/enroll_params_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() {
group('A group of tests related to enroll verb', () {
test('A test to verify enroll request params', () {
String command =
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key", "encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
expect(RegExp(VerbSyntax.enroll).hasMatch(command), true);
command = command.replaceAll('enroll:request:', '');
var enrollParams = jsonDecode(command);
Expand All @@ -28,7 +28,7 @@ void main() {

test('A test to verify enroll approve params', () {
String command =
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encPrivateKeyIV":"MHz0FJD63Dm3y5/w2fc+qw==","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","selfEncKeyIV":"G7GXk44cpIFACy31MSaUkA==","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
expect(RegExp(VerbSyntax.enroll).hasMatch(command), true);
command = command.replaceAll('enroll:approve:', '');
var enrollParams = jsonDecode(command);
Expand All @@ -38,8 +38,10 @@ void main() {
expect(enrollParams['namespaces']['wavi'], 'rw');
expect(enrollParams['encryptedDefaultEncryptionPrivateKey'],
'dummy_encrypted_private_key');
expect(enrollParams['encPrivateKeyIV'], 'MHz0FJD63Dm3y5/w2fc+qw==');
expect(enrollParams['encryptedDefaultSelfEncryptionKey'],
'dummy_self_encryption_key');
expect(enrollParams['selfEncKeyIV'], 'G7GXk44cpIFACy31MSaUkA==');
expect(enrollParams['encryptedAPKAMSymmetricKey'], 'dummy_pkam_sym_key');
expect(enrollParams['apkamPublicKey'], 'abcd1234');
});
Expand Down
6 changes: 4 additions & 2 deletions packages/at_commons/test/enroll_verb_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ void main() {
..apkamPublicKey = 'abcd1234'
..encryptedAPKAMSymmetricKey = 'dummy_pkam_sym_key'
..encryptedDefaultEncryptionPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key';
..encPrivateKeyIV = 'dummy_iv_for_enc_private_key'
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key'
..selfEncKeyIV = 'dummy_iv_for_self_encryption_key';
var command = enrollVerbBuilder.buildCommand();
expect(command,
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encPrivateKeyIV":"dummy_iv_for_enc_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","selfEncKeyIV":"dummy_iv_for_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
});

test('A test to verify enroll deny operation', () {
Expand Down
Loading