Lines Matching refs:header
18 //! \post Stream head points to just after the image header.
19 //! \exception read_error Thrown if the image header is invalid.
22 // seek to beginning of the stream/file and read the plaintext header
26 throw read_error("failed to read image header");
48 // check header signature 1
54 // check header signature 2 for version 1.1 and greater
62 //! \pre The image header must have already been read with a call to readImageHeader().
73 //! \pre The image header must have already been read.
100 //! \pre The image header must have already been read with a call to readImageHeader().
103 //! \exception read_error Thrown if the image header is invalid.
126 //! \pre Image header must have been read before this method is called.
136 EncoreBootImage::section_header_t header;
137 if (m_stream.read((char *)&header, sizeof(header)).bad())
139 throw read_error("failed to read section header");
142 // swizzle section header
143 header.m_tag = ENDIAN_LITTLE_TO_HOST_U32(header.m_tag);
144 header.m_offset = ENDIAN_LITTLE_TO_HOST_U32(header.m_offset);
145 header.m_length = ENDIAN_LITTLE_TO_HOST_U32(header.m_length);
146 header.m_flags = ENDIAN_LITTLE_TO_HOST_U32(header.m_flags);
148 m_sections.push_back(header);
158 //! \pre The image header and section table must have been read already.
174 // first compute a CBC-MAC over the image header with our KEK
229 //! \pre Image header must have been read.
243 EncoreBootImage::boot_command_t header;
245 if (m_stream.read((char *)&header, sizeof(header)).bad())
250 // swizzle to command header
251 header.m_flags = ENDIAN_LITTLE_TO_HOST_U16(header.m_flags);
252 header.m_address = ENDIAN_LITTLE_TO_HOST_U32(header.m_address);
253 header.m_count = ENDIAN_LITTLE_TO_HOST_U32(header.m_count);
254 header.m_data = ENDIAN_LITTLE_TO_HOST_U32(header.m_data);
261 cipher.blockDecrypt((uint8_t *)&header, sizeof(header) * 8, (uint8_t *)&header);
265 if (header.m_tag != EncoreBootImage::ROM_TAG_CMD)
270 uint8_t checksum = calculateCommandChecksum(header);
271 if (checksum != header.m_checksum)
277 m_bootTags.push_back(header);
280 bootTagOffset += header.m_count + 1; // include this boot tag in offset
281 if (header.m_flags & EncoreBootImage::ROM_LAST_TAG || bootTagOffset >= m_header.m_imageBlocks - 2)
288 uint8_t EncoreBootImageReader::calculateCommandChecksum(EncoreBootImage::boot_command_t & header)
290 uint8_t * bytes = reinterpret_cast<uint8_t *>(&header);
295 for (i = 1; i < sizeof(header); ++i)
305 //! \pre Both the image header and section table must have been read already before
311 // look up section header
313 EncoreBootImage::section_header_t & header = m_sections[index];
316 m_stream.seekg(sizeOfCipherBlocks(header.m_offset), std::ios_base::beg);
322 unsigned contentLength = sizeOfCipherBlocks(header.m_length);
331 if (isEncrypted() && (header.m_flags & EncoreBootImage::ROM_SECTION_CLEARTEXT) == 0)
340 if (header.m_flags & EncoreBootImage::ROM_SECTION_BOOTABLE)
343 EncoreBootImage::BootSection * bootSection = new EncoreBootImage::BootSection(header.m_tag);
345 bootSection->fillFromData((cipher_block_t *)contents, header.m_length);
352 EncoreBootImage::DataSection * dataSection = new EncoreBootImage::DataSection(header.m_tag);