Skip to content

Commit

Permalink
Merge branch 'trunk' into sync_builder_remove_deprecated_params
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris authored Dec 12, 2024
2 parents 15d68c5 + 8252529 commit 8585b18
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/at_end2end_test/test/enrollment_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Future<String> getDefaultEncryptionPrivateKey(
var privateKeyCommand =
'keys:get:keyName:$enrollmentIdFromServer.${AtConstants.defaultEncryptionPrivateKey}.__manage$atSign';
String encryptionPrivateKeyFromServer;
String encryptionPrivateKeyIV;
try {
var getPrivateKeyResult =
await atLookUp.executeCommand('$privateKeyCommand\n', auth: true);
Expand All @@ -200,13 +201,15 @@ Future<String> getDefaultEncryptionPrivateKey(
getPrivateKeyResult = getPrivateKeyResult.replaceFirst('data:', '');
var privateKeyResultJson = jsonDecode(getPrivateKeyResult);
encryptionPrivateKeyFromServer = privateKeyResultJson['value'];
encryptionPrivateKeyIV = privateKeyResultJson['iv'];
} on Exception catch (e) {
throw AtEnrollmentException(
'Exception while getting encrypted private key/self key from server: $e');
}
AtEncryptionResult? atEncryptionResult = atLookUp.atChops?.decryptString(
encryptionPrivateKeyFromServer, EncryptionKeyType.aes256,
keyName: 'apkamSymmetricKey', iv: AtChopsUtil.generateIVLegacy());
keyName: 'apkamSymmetricKey',
iv: AtChopsUtil.generateIVFromBase64String(encryptionPrivateKeyIV));
return atEncryptionResult?.result;
}

Expand All @@ -218,6 +221,7 @@ Future<String> getDefaultSelfEncryptionKey(
var selfEncryptionKeyCommand =
'keys:get:keyName:$enrollmentIdFromServer.${AtConstants.defaultSelfEncryptionKey}.__manage$atSign';
String selfEncryptionKeyFromServer;
String selfEncryptionKeyIV;
try {
String? encryptedSelfEncryptionKey = await atLookUp
.executeCommand('$selfEncryptionKeyCommand\n', auth: true);
Expand All @@ -230,12 +234,14 @@ Future<String> getDefaultSelfEncryptionKey(
encryptedSelfEncryptionKey.replaceFirst('data:', '');
var selfEncryptionKeyResultJson = jsonDecode(encryptedSelfEncryptionKey);
selfEncryptionKeyFromServer = selfEncryptionKeyResultJson['value'];
selfEncryptionKeyIV = selfEncryptionKeyResultJson['iv'];
} on Exception catch (e) {
throw AtEnrollmentException(
'Exception while getting encrypted private key/self key from server: $e');
}
AtEncryptionResult? atEncryptionResult = atLookUp.atChops?.decryptString(
selfEncryptionKeyFromServer, EncryptionKeyType.aes256,
keyName: 'apkamSymmetricKey', iv: AtChopsUtil.generateIVLegacy());
keyName: 'apkamSymmetricKey',
iv: AtChopsUtil.generateIVFromBase64String(selfEncryptionKeyIV));
return atEncryptionResult?.result;
}

0 comments on commit 8585b18

Please sign in to comment.