decryptAtKeysWithSelfEncKey method
- @Deprecated('legacy helpers for serialization, if we need to retain this turn it into a static helper')
Future<AtKeys>
decryptAtKeysWithSelfEncKey(
- Map<String, dynamic> jsonData,
- PkamAuthMode authMode
)
Implementation
@Deprecated(
'legacy helpers for serialization, if we need to retain this turn it into a static helper')
Future<AtKeys> decryptAtKeysWithSelfEncKey(
Map<String, dynamic> jsonData, PkamAuthMode authMode) async {
var securityKeys = AtKeys();
String decryptionKey = jsonData[auth_constants.defaultSelfEncryptionKey];
var atChops =
AtChopsImpl(AtChopsKeys()..selfEncryptionKey = AESKey(decryptionKey));
securityKeys.defaultSelfEncryptionKey = AtBytes.fromString(decryptionKey);
securityKeys.defaultEncryptionPublicKey = AtBytes.fromString(
(await atChops.decryptString(
jsonData[auth_constants.defaultEncryptionPublicKey],
EncryptionKeyType.aes256,
keyName: 'selfEncryptionKey',
iv: AtChopsUtil.generateIVLegacy()))
.result);
securityKeys.defaultEncryptionPrivateKey = AtBytes.fromString(
(await atChops.decryptString(
jsonData[auth_constants.defaultEncryptionPrivateKey],
EncryptionKeyType.aes256,
keyName: 'selfEncryptionKey',
iv: AtChopsUtil.generateIVLegacy()))
.result);
securityKeys
.apkamPublicKey = AtBytes.fromString((await atChops.decryptString(
jsonData[auth_constants.apkamPublicKey], EncryptionKeyType.aes256,
keyName: 'selfEncryptionKey', iv: AtChopsUtil.generateIVLegacy()))
.result);
// pkam private key will not be saved in keyfile if auth mode is sim/any other secure element.
// decrypt the private key only when auth mode is keysFile
if (authMode == PkamAuthMode.keysFile) {
securityKeys.apkamPrivateKey = AtBytes.fromString(
(await atChops.decryptString(jsonData[auth_constants.apkamPrivateKey],
EncryptionKeyType.aes256,
keyName: 'selfEncryptionKey',
iv: AtChopsUtil.generateIVLegacy()))
.result);
}
securityKeys.apkamSymmetricKey =
AtBytes.fromString(jsonData[auth_constants.apkamSymmetricKey] ?? '');
securityKeys.enrollmentId = jsonData[AtConstants.enrollmentId];
return securityKeys;
}