/// <summary> /// AIS Section Load command generation /// </summary> /// <param name="cf">The COFFfile object that the section comes from.</param> /// <param name="secHeader">The Hashtable object of the section header to load.</param> /// <param name="devAISGen">The specific device AIS generator object.</param> /// <returns>retType enumerator indicating success or failure.</returns> private static retType AISSecureSectionLoad( AISGen devAISGen, ObjectFile file, ObjectSection section, Boolean encryptSection) { Byte[] secData = file.secRead(section); // Write Section_Load AIS command, load address, and size if (encryptSection) { Byte[] encData = null; // Encrypt data using CTS algorithm try { encData = AesManagedUtil.AesCTSEncrypt(secData,devAISGen.customerEncryptionKey,devAISGen.CEKInitialValue); } catch(Exception e) { Console.WriteLine("Exception during encryption operation: {0}",e.Message); return retType.FAIL; } if (encData != null) { devAISGen.InsertAISEncSectionLoad((UInt32) section.loadAddr, (UInt32) section.size, secData, encData); } else { Console.WriteLine("Section encryption failed."); return retType.FAIL; } } else { devAISGen.InsertAISSectionLoad((UInt32) section.loadAddr, (UInt32) section.size, secData); } // Add this section's memory range, checking for overlap AddMemoryRange(devAISGen, (UInt32) section.loadAddr, (UInt32) (section.loadAddr+section.size-1)); return retType.SUCCESS; }