Skip to content

Commit

Permalink
fix: add IV params in EnrollParams and enroll verb builder
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris committed Dec 5, 2024
1 parent fb56a92 commit 0578bf1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
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
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

0 comments on commit 0578bf1

Please sign in to comment.