Files
6CAR/doc/Doxygen/html/pke__prime_8h_source.html
2026-04-18 09:16:58 +08:00

143 lines
16 KiB
HTML
Raw Blame History

<!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">
<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.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SemiDrive SSDK Appication Program Interface: Z:/01-Code/06-SSDK-DEV-Firewall/ssdk/drivers/include/crypto/cacc/ral/pke_prime.h Source File</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>
<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">SemiDrive SSDK Appication Program Interface<span id="projectnumber">&#160;PTG3.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- 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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_14bc92f4b96c8519b376567118ac28b3.html">drivers</a></li><li class="navelem"><a class="el" href="dir_ee023d43c33bfccc31aa50a48a76892b.html">include</a></li><li class="navelem"><a class="el" href="dir_e08589e132e001d864753e5516cdc279.html">crypto</a></li><li class="navelem"><a class="el" href="dir_610f8d7993e1efb130988b94d1ce0406.html">cacc</a></li><li class="navelem"><a class="el" href="dir_5c2f64ee58b16a19072d9378e4b18c4c.html">ral</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">pke_prime.h</div></div>
</div><!--header-->
<div class="contents">
<a href="pke__prime_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="preprocessor">#ifndef PKE_PRIME_H</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="preprocessor">#define PKE_PRIME_H</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> </div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="preprocessor">#include &quot;stdint.h&quot;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span><span class="comment">/* 1:use hardware; 2:use software */</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#ace6b915dcd7b7357f3e64572dda14b2c"> 19</a></span><span class="preprocessor">#define BIGINT_DIV_CHOICE (2)</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> </div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#if (BIGINT_DIV_CHOICE == 1)</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> uint32_t low;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> uint32_t high;</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span>} <a class="code hl_typedef" href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217">double_uint32_t</a>;</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span><span class="preprocessor">#elif (BIGINT_DIV_CHOICE == 2)</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217"> 27</a></span><span class="keyword">typedef</span> uint32_t <a class="code hl_typedef" href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217">double_uint32_t</a>;</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> </div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="comment">/* 1:use Fermat primality test; 2:use Miller<65>CRabin primality test */</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a55b38c62198f0283205ec6d0da58b1f6"> 31</a></span><span class="preprocessor">#define PRIMALITY_TEST_CHOICE (1)</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="preprocessor">#if (PRIMALITY_TEST_CHOICE == 1)</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a16dde891955073f287d3f940ed2a61ed"> 34</a></span><span class="preprocessor">#define FERMAT_ROUND (3)</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor">#elif (PRIMALITY_TEST_CHOICE == 2)</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="preprocessor">#define MILLER_RABIN_ROUND (3)</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> </div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span><span class="comment">/* prime table level(total number of small prime numbers) */</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a17794ed33d7dfd92068c98dc4df93b7b"> 40</a></span><span class="preprocessor">#define PTL_MAX (400) </span><span class="comment">/* the max PTL value */</span><span class="preprocessor"></span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a0921b0f21acb2fd73826eed26f80c482"> 41</a></span><span class="preprocessor">#define PTL_512 \</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="preprocessor"> (400) </span><span class="comment">/* the best PTL value for prime bit length 512 (RSA1024) */</span><span class="preprocessor"></span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a5f1c8768ec72d9cfe52ab4a8e72c4a3d"> 43</a></span><span class="preprocessor">#define PTL_1024 \</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span><span class="preprocessor"> (400) </span><span class="comment">/* the best PTL value for prime bit length 1024 (RSA2048) */</span><span class="preprocessor"></span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#ab3bd23948d596fcc38da458c2cf88bb3"> 46</a></span><span class="preprocessor">#define NOT_PRIME (0xFFFFFFFF)</span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#acab86ab73437f580d0e5d965eb77e2ed"> 47</a></span><span class="preprocessor">#define MAYBE_PRIME (0)</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> </div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span><span class="keyword">extern</span> <span class="keyword">const</span> uint16_t <a class="code hl_variable" href="pke__prime_8h.html#a13c4ba42df8f0219b6def84781f549a0">primetable</a>[<a class="code hl_define" href="pke__prime_8h.html#a17794ed33d7dfd92068c98dc4df93b7b">PTL_MAX</a>];</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span><span class="keyword">extern</span> <span class="keyword">const</span> <a class="code hl_typedef" href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217">double_uint32_t</a> <a class="code hl_variable" href="pke__prime_8h.html#a6a6b41bd0f453d0bab4c77b5098a154e">primetable_s</a>[<a class="code hl_define" href="pke__prime_8h.html#a17794ed33d7dfd92068c98dc4df93b7b">PTL_MAX</a>];</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span><span class="keyword">extern</span> <span class="keyword">const</span> uint16_t <a class="code hl_variable" href="pke__prime_8h.html#a0d0bba5446a11d74d74ad5e3d2945c2a">primetable_r</a>[<a class="code hl_define" href="pke__prime_8h.html#a17794ed33d7dfd92068c98dc4df93b7b">PTL_MAX</a>];</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> </div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a283dc5c059cbf3ed81ab1ec20dd2f9ee"> 53</a></span>uint32_t <a class="code hl_function" href="pke__prime_8h.html#a283dc5c059cbf3ed81ab1ec20dd2f9ee">get_prime</a>(uint32_t p[], uint32_t pbitlen);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a61d77653ccfd24de4d37f3f8e9cb30b7"> 54</a></span>uint32_t <a class="code hl_function" href="pke__prime_8h.html#a61d77653ccfd24de4d37f3f8e9cb30b7">bigint_div_table_high</a>(uint32_t *a, uint32_t awordlen, uint16_t *r,</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_typedef" href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217">double_uint32_t</a> *s, uint16_t *high_result,</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> uint32_t PTL);</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"><a class="line" href="pke__prime_8h.html#a798e569dcdbb4bc7e1d632d3fab2502a"> 57</a></span>uint32_t <a class="code hl_function" href="pke__prime_8h.html#a798e569dcdbb4bc7e1d632d3fab2502a">bigint_div_table_low</a>(uint32_t *a, uint16_t *r, <a class="code hl_typedef" href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217">double_uint32_t</a> *s,</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> uint16_t *high_result, uint32_t PTL);</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span>}</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="apke__prime_8h_html_a0d0bba5446a11d74d74ad5e3d2945c2a"><div class="ttname"><a href="pke__prime_8h.html#a0d0bba5446a11d74d74ad5e3d2945c2a">primetable_r</a></div><div class="ttdeci">const uint16_t primetable_r[PTL_MAX]</div></div>
<div class="ttc" id="apke__prime_8h_html_a13c4ba42df8f0219b6def84781f549a0"><div class="ttname"><a href="pke__prime_8h.html#a13c4ba42df8f0219b6def84781f549a0">primetable</a></div><div class="ttdeci">const uint16_t primetable[PTL_MAX]</div></div>
<div class="ttc" id="apke__prime_8h_html_a17794ed33d7dfd92068c98dc4df93b7b"><div class="ttname"><a href="pke__prime_8h.html#a17794ed33d7dfd92068c98dc4df93b7b">PTL_MAX</a></div><div class="ttdeci">#define PTL_MAX</div><div class="ttdef"><b>Definition:</b> pke_prime.h:40</div></div>
<div class="ttc" id="apke__prime_8h_html_a283dc5c059cbf3ed81ab1ec20dd2f9ee"><div class="ttname"><a href="pke__prime_8h.html#a283dc5c059cbf3ed81ab1ec20dd2f9ee">get_prime</a></div><div class="ttdeci">uint32_t get_prime(uint32_t p[], uint32_t pbitlen)</div></div>
<div class="ttc" id="apke__prime_8h_html_a61d77653ccfd24de4d37f3f8e9cb30b7"><div class="ttname"><a href="pke__prime_8h.html#a61d77653ccfd24de4d37f3f8e9cb30b7">bigint_div_table_high</a></div><div class="ttdeci">uint32_t bigint_div_table_high(uint32_t *a, uint32_t awordlen, uint16_t *r, double_uint32_t *s, uint16_t *high_result, uint32_t PTL)</div></div>
<div class="ttc" id="apke__prime_8h_html_a6a6b41bd0f453d0bab4c77b5098a154e"><div class="ttname"><a href="pke__prime_8h.html#a6a6b41bd0f453d0bab4c77b5098a154e">primetable_s</a></div><div class="ttdeci">const double_uint32_t primetable_s[PTL_MAX]</div></div>
<div class="ttc" id="apke__prime_8h_html_a798e569dcdbb4bc7e1d632d3fab2502a"><div class="ttname"><a href="pke__prime_8h.html#a798e569dcdbb4bc7e1d632d3fab2502a">bigint_div_table_low</a></div><div class="ttdeci">uint32_t bigint_div_table_low(uint32_t *a, uint16_t *r, double_uint32_t *s, uint16_t *high_result, uint32_t PTL)</div></div>
<div class="ttc" id="apke__prime_8h_html_a9b2f9ed7adebd6277b0aac0fef9d5217"><div class="ttname"><a href="pke__prime_8h.html#a9b2f9ed7adebd6277b0aac0fef9d5217">double_uint32_t</a></div><div class="ttdeci">uint32_t double_uint32_t</div><div class="ttdef"><b>Definition:</b> pke_prime.h:27</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>