Files
libaaruformat/docs/html/ps3__encryption__map_8c.html

412 lines
21 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.16.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libaaruformat: src/ps3/ps3_encryption_map.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libaaruformat<span id="projectnumber">&#160;1.0</span>
</div>
<div id="projectbrief">Aaru Data Preservation Suite - Format Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.16.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('ps3__encryption__map_8c.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">ps3_encryption_map.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &quot;<a class="el" href="ps3__encryption__map_8h_source.html">ps3_encryption_map.h</a>&quot;</code><br />
</div>
<p><a href="ps3__encryption__map_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a3a376cf8ba481c4b09b25273af5953fe" id="r_a3a376cf8ba481c4b09b25273af5953fe"><td class="memItemLeft">static uint32_t&#160;</td><td class="memItemRight"><a class="el" href="#a3a376cf8ba481c4b09b25273af5953fe">read_be32</a> (const uint8_t *p)</td></tr>
<tr class="memitem:a2e85418928614df336b5df9f3c28cbc7" id="r_a2e85418928614df336b5df9f3c28cbc7"><td class="memItemLeft">static uint32_t&#160;</td><td class="memItemRight"><a class="el" href="#a2e85418928614df336b5df9f3c28cbc7">read_le32</a> (const uint8_t *p)</td></tr>
<tr class="memitem:a4ed80664538efb908d3c161aec613612" id="r_a4ed80664538efb908d3c161aec613612"><td class="memItemLeft">static void&#160;</td><td class="memItemRight"><a class="el" href="#a4ed80664538efb908d3c161aec613612">write_le32</a> (uint8_t *p, uint32_t v)</td></tr>
<tr class="memitem:ab646921aa4c83e38af36f38b8b3d068a" id="r_ab646921aa4c83e38af36f38b8b3d068a"><td class="memItemLeft">int32_t&#160;</td><td class="memItemRight"><a class="el" href="#ab646921aa4c83e38af36f38b8b3d068a">ps3_parse_encryption_map</a> (const uint8_t *sector0, uint32_t length, <a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> **regions, uint32_t *count)</td></tr>
<tr class="memdesc:ab646921aa4c83e38af36f38b8b3d068a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse the encryption map from PS3 disc sector 0 (big-endian on disc). <br /></td></tr>
<tr class="memitem:aebc9066937e11649d0a81351ddd83582" id="r_aebc9066937e11649d0a81351ddd83582"><td class="memItemLeft">int32_t&#160;</td><td class="memItemRight"><a class="el" href="#aebc9066937e11649d0a81351ddd83582">ps3_serialize_encryption_map</a> (const <a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> *regions, uint32_t count, uint8_t **out_data, uint32_t *out_length)</td></tr>
<tr class="memdesc:aebc9066937e11649d0a81351ddd83582"><td class="mdescLeft">&#160;</td><td class="mdescRight">Serialize plaintext regions to little-endian binary for storage as a media tag. <br /></td></tr>
<tr class="memitem:a49a5e6c2b524988714513c446e2d200d" id="r_a49a5e6c2b524988714513c446e2d200d"><td class="memItemLeft">int32_t&#160;</td><td class="memItemRight"><a class="el" href="#a49a5e6c2b524988714513c446e2d200d">ps3_deserialize_encryption_map</a> (const uint8_t *data, uint32_t length, <a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> **regions, uint32_t *count)</td></tr>
<tr class="memdesc:a49a5e6c2b524988714513c446e2d200d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deserialize plaintext regions from little-endian binary (media tag format). <br /></td></tr>
<tr class="memitem:a058b5191df4b4a83a6bc55052fad503f" id="r_a058b5191df4b4a83a6bc55052fad503f"><td class="memItemLeft">bool&#160;</td><td class="memItemRight"><a class="el" href="#a058b5191df4b4a83a6bc55052fad503f">ps3_is_sector_encrypted</a> (const <a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> *plaintext_regions, uint32_t region_count, uint64_t sector_address)</td></tr>
<tr class="memdesc:a058b5191df4b4a83a6bc55052fad503f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check whether a sector is encrypted (i.e., not in any plaintext region). <br /></td></tr>
</table>
<a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
<a id="a49a5e6c2b524988714513c446e2d200d" name="a49a5e6c2b524988714513c446e2d200d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a49a5e6c2b524988714513c446e2d200d">&#9670;&#160;</a></span>ps3_deserialize_encryption_map()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ps3_deserialize_encryption_map </td>
<td>(</td>
<td class="paramtype">const uint8_t *</td> <td class="paramname"><span class="paramname"><em>data</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>length</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> **</td> <td class="paramname"><span class="paramname"><em>regions</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t *</td> <td class="paramname"><span class="paramname"><em>count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Deserialize plaintext regions from little-endian binary (media tag format). </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Serialized data buffer. </td></tr>
<tr><td class="paramname">length</td><td>Length of data buffer. </td></tr>
<tr><td class="paramname">regions</td><td>Output: allocated array of plaintext regions. Caller must free(). </td></tr>
<tr><td class="paramname">count</td><td>Output: number of regions. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, negative error code on failure. </dd></dl>
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00117">117</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">References <a class="el" href="ps3__encryption__map_8h_source.html#l00036">Ps3PlaintextRegion::end_sector</a>, <a class="el" href="ps3__encryption__map_8h_source.html#l00039">PS3_MAX_PLAINTEXT_REGIONS</a>, <a class="el" href="ps3__encryption__map_8c_source.html#l00034">read_le32()</a>, and <a class="el" href="ps3__encryption__map_8h_source.html#l00035">Ps3PlaintextRegion::start_sector</a>.</p>
<p class="reference">Referenced by <a class="el" href="ps3__crypto_8c_source.html#l00070">ps3_lazy_init()</a>.</p>
</div>
</div>
<a id="a058b5191df4b4a83a6bc55052fad503f" name="a058b5191df4b4a83a6bc55052fad503f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a058b5191df4b4a83a6bc55052fad503f">&#9670;&#160;</a></span>ps3_is_sector_encrypted()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool ps3_is_sector_encrypted </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> *</td> <td class="paramname"><span class="paramname"><em>plaintext_regions</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>region_count</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint64_t</td> <td class="paramname"><span class="paramname"><em>sector_address</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Check whether a sector is encrypted (i.e., not in any plaintext region). </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">plaintext_regions</td><td>Array of plaintext regions. </td></tr>
<tr><td class="paramname">region_count</td><td>Number of regions. </td></tr>
<tr><td class="paramname">sector_address</td><td>Sector number to check. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the sector is encrypted (not in any plaintext region). </dd></dl>
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00151">151</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">Referenced by <a class="el" href="read_8c_source.html#l00352">aaruf_read_sector()</a>, and <a class="el" href="write_8c_source.html#l00102">aaruf_write_sector()</a>.</p>
</div>
</div>
<a id="ab646921aa4c83e38af36f38b8b3d068a" name="ab646921aa4c83e38af36f38b8b3d068a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab646921aa4c83e38af36f38b8b3d068a">&#9670;&#160;</a></span>ps3_parse_encryption_map()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ps3_parse_encryption_map </td>
<td>(</td>
<td class="paramtype">const uint8_t *</td> <td class="paramname"><span class="paramname"><em>sector0</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>length</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> **</td> <td class="paramname"><span class="paramname"><em>regions</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t *</td> <td class="paramname"><span class="paramname"><em>count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Parse the encryption map from PS3 disc sector 0 (big-endian on disc). </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">sector0</td><td>Pointer to the 2048-byte sector 0 data. </td></tr>
<tr><td class="paramname">length</td><td>Length of sector0 data (must be &gt;= 264). </td></tr>
<tr><td class="paramname">regions</td><td>Output: allocated array of plaintext regions. Caller must free(). </td></tr>
<tr><td class="paramname">count</td><td>Output: number of regions. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, negative error code on failure. </dd></dl>
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00048">48</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">References <a class="el" href="ps3__encryption__map_8h_source.html#l00036">Ps3PlaintextRegion::end_sector</a>, <a class="el" href="ps3__encryption__map_8h_source.html#l00039">PS3_MAX_PLAINTEXT_REGIONS</a>, <a class="el" href="ps3__encryption__map_8c_source.html#l00028">read_be32()</a>, and <a class="el" href="ps3__encryption__map_8h_source.html#l00035">Ps3PlaintextRegion::start_sector</a>.</p>
</div>
</div>
<a id="aebc9066937e11649d0a81351ddd83582" name="aebc9066937e11649d0a81351ddd83582"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aebc9066937e11649d0a81351ddd83582">&#9670;&#160;</a></span>ps3_serialize_encryption_map()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ps3_serialize_encryption_map </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structPs3PlaintextRegion.html">Ps3PlaintextRegion</a> *</td> <td class="paramname"><span class="paramname"><em>regions</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>count</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t **</td> <td class="paramname"><span class="paramname"><em>out_data</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t *</td> <td class="paramname"><span class="paramname"><em>out_length</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Serialize plaintext regions to little-endian binary for storage as a media tag. </p>
<p>Format: [4B region_count LE] + region_count × [4B start LE, 4B end LE]</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">regions</td><td>Array of plaintext regions. </td></tr>
<tr><td class="paramname">count</td><td>Number of regions. </td></tr>
<tr><td class="paramname">out_data</td><td>Output: allocated buffer. Caller must free(). </td></tr>
<tr><td class="paramname">out_length</td><td>Output: size of the buffer in bytes. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, negative error code on failure. </dd></dl>
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00094">94</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">References <a class="el" href="ps3__encryption__map_8h_source.html#l00039">PS3_MAX_PLAINTEXT_REGIONS</a>, and <a class="el" href="ps3__encryption__map_8c_source.html#l00040">write_le32()</a>.</p>
</div>
</div>
<a id="a3a376cf8ba481c4b09b25273af5953fe" name="a3a376cf8ba481c4b09b25273af5953fe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3a376cf8ba481c4b09b25273af5953fe">&#9670;&#160;</a></span>read_be32()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">uint32_t read_be32 </td>
<td>(</td>
<td class="paramtype">const uint8_t *</td> <td class="paramname"><span class="paramname"><em>p</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00028">28</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">Referenced by <a class="el" href="ps3__encryption__map_8c_source.html#l00048">ps3_parse_encryption_map()</a>.</p>
</div>
</div>
<a id="a2e85418928614df336b5df9f3c28cbc7" name="a2e85418928614df336b5df9f3c28cbc7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2e85418928614df336b5df9f3c28cbc7">&#9670;&#160;</a></span>read_le32()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">uint32_t read_le32 </td>
<td>(</td>
<td class="paramtype">const uint8_t *</td> <td class="paramname"><span class="paramname"><em>p</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00034">34</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">Referenced by <a class="el" href="ps3__encryption__map_8c_source.html#l00117">ps3_deserialize_encryption_map()</a>.</p>
</div>
</div>
<a id="a4ed80664538efb908d3c161aec613612" name="a4ed80664538efb908d3c161aec613612"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4ed80664538efb908d3c161aec613612">&#9670;&#160;</a></span>write_le32()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void write_le32 </td>
<td>(</td>
<td class="paramtype">uint8_t *</td> <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>v</em></span>&#160;)</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="ps3__encryption__map_8c_source.html#l00040">40</a> of file <a class="el" href="ps3__encryption__map_8c_source.html">ps3_encryption_map.c</a>.</p>
<p class="reference">Referenced by <a class="el" href="ps3__encryption__map_8c_source.html#l00094">ps3_serialize_encryption_map()</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a href="dir_334a95085ca661c6475619df5f6eaf52.html">ps3</a></li><li class="navelem"><a href="ps3__encryption__map_8c.html">ps3_encryption_map.c</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1 </li>
</ul>
</div>
</body>
</html>