string keyhashFilename = info.imagePath + ".keyhash";
secret.erase(secret.size()-2);
string keyHash = "echo -n " + secret + " | openssl dgst -sha256 | awk '{print $2}' > " + keyhashFilename;
- cout << keyHash << endl;
- system(keyHash.c_str());
+ int result = system(keyHash.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Hashing key failed");
+ }
string line;
ifstream myfile(keyhashFilename.c_str());
if (myfile.is_open()) {
getline(myfile, line);
- //cout << "line " << line << endl;
myfile.close();
}
string dec_command = "openssl enc " + cipher + " -d -nopad -nosalt -K " + secret
+ " -in " + info.imagePath + " -out " + info.imagePath
+ "_dec -iv 0000000000000000";
- //std::cout << dec_command << std::endl;
- system(dec_command.c_str());
+ result = system(dec_command.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Image decryption failed");
+ }
+
string removeEncImage = "rm -f " + info.imagePath;
- //std::cout << removeEncImage << std::endl;
- system(removeEncImage.c_str());
+ result = system(removeEncImage.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Post decryption operations failed");
+ }
+
string renameDecImage = "mv " + info.imagePath + "_dec " + info.imagePath;
- //std::cout << renameDecImage << std::endl;
- system(renameDecImage.c_str());
+ result = system(renameDecImage.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Post decryption operations failed");
+ }
+
string removeKeyHash = "rm -f " + keyhashFilename;
- //std::cout << removeEncImage << std::endl;
- system(removeKeyHash.c_str());
+ result = system(removeKeyHash.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Post decryption operations failed");
+ }
}
/**
decryptImage(info);
string s = "chmod +x " + info.imagePath;
- system(s.c_str());
+ int result = system(s.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Unpacking executable TA failed");
+ }
ret = true;
}
return -1;
}
string removeImage = "rm -f " + extract_dir_path + uuid + ".image";
- system(removeImage.c_str());
+ int result = system(removeImage.c_str());
+ if (result != 0) {
+ LOGE(SIM_DAEMON, "Failed to remove existing TA image");
+ }
+
ofstream image((extract_dir_path + uuid + ".image").c_str(),
ios::out | ios::binary);
ofstream manifest((extract_dir_path + uuid + ".manifest").c_str(),