Skip to content

Commit

Permalink
Merge pull request #360 from atsign-foundation/ticket_359
Browse files Browse the repository at this point in the history
feat: added enrollmentID & apkamSymmetric key
  • Loading branch information
murali-shris authored Nov 14, 2023
2 parents 6b9cc8e + ac0c237 commit 9ca6a63
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/at_dump_atKeys/bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:archive/archive_io.dart';
import 'package:args/args.dart';
import 'package:at_dump_atKeys/commandline_parser.dart';
import 'package:crypton/crypton.dart';
Expand All @@ -14,30 +13,37 @@ Future<void> main(List<String> arguments) async {
try {
parser = CommandLineParser().getParser();
if (arguments.length == 1 &&
(arguments[0] == '-h' || arguments[0] == '--help') ||
arguments.length ==0) {
(arguments[0] == '-h' || arguments[0] == '--help') ||
arguments.isEmpty) {
print('Usage: \ndart run bin/main.dart \n${parser.usage}');
exit(0);
}
var args = CommandLineParser().getParserResults(arguments, parser);
var filePath = args['file_path'];
var keyMap = new Map();
var keyMap = {};
var isFileExists = await File(filePath).exists();
if (!isFileExists) {
throw Exception('File not found');
}
var fileContents = File(filePath).readAsStringSync();
var keysJSON = json.decode(fileContents);
var aesEncryptionKey = keysJSON['selfEncryptionKey'];
keyMap['pkamPublicKey'] =
RSAPublicKey.fromString(decryptValue(keysJSON['aesPkamPublicKey'], aesEncryptionKey));
keyMap['pkamPrivateKey'] =
RSAPrivateKey.fromString(decryptValue(keysJSON['aesPkamPrivateKey'], aesEncryptionKey));
keyMap['encryptionPublicKey'] =
RSAPublicKey.fromString(decryptValue(keysJSON['aesEncryptPublicKey'], aesEncryptionKey));
keyMap['encryptionPrivateKey'] =
RSAPrivateKey.fromString(decryptValue(keysJSON['aesEncryptPrivateKey'], aesEncryptionKey));
String? enrollmentId = keysJSON['enrollmentId'];
String? apkamSymmetrickey = keysJSON['apkamSymmetricKey'];
keyMap['pkamPublicKey'] = RSAPublicKey.fromString(
decryptValue(keysJSON['aesPkamPublicKey'], aesEncryptionKey));
keyMap['pkamPrivateKey'] = RSAPrivateKey.fromString(
decryptValue(keysJSON['aesPkamPrivateKey'], aesEncryptionKey));
keyMap['encryptionPublicKey'] = RSAPublicKey.fromString(
decryptValue(keysJSON['aesEncryptPublicKey'], aesEncryptionKey));
keyMap['encryptionPrivateKey'] = RSAPrivateKey.fromString(
decryptValue(keysJSON['aesEncryptPrivateKey'], aesEncryptionKey));
keyMap['selfEncryptionKey'] = aesEncryptionKey;
if ((enrollmentId != null && enrollmentId.isNotEmpty) &&
(apkamSymmetrickey != null && apkamSymmetrickey.isNotEmpty)) {
keyMap['enrollmentId'] = enrollmentId;
keyMap['apkamSymmetricKey'] = apkamSymmetrickey;
}
keyMap.forEach((k, v) => print("$k: $v\n"));
} on ArgParserException catch (e) {
print('$e');
Expand Down

0 comments on commit 9ca6a63

Please sign in to comment.