<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[HA01   MCAL中使用TRNG模块获取随机数]]></title><description><![CDATA[<p dir="auto">TRNG获取随机数时想要尽量缩短请求的时间（只需要获取3字节的随机数）<br />
目前根据MCAL中的Crypto_demo例子<br />
(slow_bus_clk为24M，samp_size为0x200)<br />
在sample_size和slow_bus_clk都不变的前提下通过修改eny_dly缩短时间，eny_dly修改为0x80、0x100、0x200都可以获取到随机数<br />
eny_dly为0x80时（5ms获取一次）：<br />
复位后连续获取1w次，重复的随机数出现2次、4次、8次（共测了3轮共计3w次）<br />
复位后获取1000次再复位共计10轮1w次，重复的随机数出现3次、2次、5次（共测了3轮共计3w次）<br />
eny_dly为0x100时（10ms获取一次）：<br />
复位后连续获取1w次，重复的随机数出现5次、6次、2次（共测了3轮共计3w次）<br />
复位后获取1000次再复位共计10轮1w次，重复的随机数出现1次、3次、1次（共测了3轮共计3w次）<br />
eny_dly为0x200时（20ms获取一次）：<br />
复位后连续获取1w次，重复的随机数出现4次、6次、1次（共测了3轮共计3w次）<br />
复位后获取1000次再复位共计10轮1w次，重复的随机数出现3次、0次、4次（共测了3轮共计3w次）<br />
问题1：<br />
理论eny_dly设置越大重复率应该越低，为什么效果不太明显呢？（也有可能是测试的样本数量不够，YT这边是否有相应的测试数据？）<br />
问题2：<br />
我尝试保持eny_dly和slow_bus_clk不变修改sample_size为0x20、0x80、0x100时获取到的随机数都是相同的，是不是有哪个地方没有修改对？<br />
代码如下：<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/105/26a46b88-eb32-4663-852c-625f79bc4712.png" alt="438d4f3a-08fe-48bd-9988-8237f834e267-image.png" class=" img-fluid img-markdown" /><br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/105/61c5e05e-2f42-4524-89ac-919a9e79ab08.png" alt="93b1fa92-1c15-4a86-8845-c317b9957c47-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/topic/2230/ha01-mcal中使用trng模块获取随机数</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 06:09:43 GMT</lastBuildDate><atom:link href="https://forum.ytmicro.com/topic/2230.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Sep 2026 05:47:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:39:42 GMT]]></title><description><![CDATA[<p dir="auto">图中的修改samp size是不是不太对，其实是不能修改samp size的，我看其他用户修改samp size也是遇到类似的问题了</p>
]]></description><link>https://forum.ytmicro.com/post/9616</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9616</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:39:42 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:37:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/105">zhai</a> 如果实际要读取的长度&lt;32字节，还是要按照32字节去读取的，上层字节从32字节中取相应长度的数据就行，就是这个意思</p>
]]></description><link>https://forum.ytmicro.com/post/9615</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9615</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:37:03 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:37:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/1288">沈宇恒</a> 好的，32字节缓存是什么？我看其他帖子，如果实际要读取的长度&lt;32字节，还是要按照32字节去读取的，上层字节从32字节中取相应长度的数据就行，参考的是这个帖子<br />
<a href="https://forum.ytmicro.com/topic/257/trng-%E7%9C%9F%E9%9A%8F%E6%9C%BA%E6%95%B0%E4%BA%A7%E7%94%9F%E6%97%B6%E9%97%B4%E8%AE%A1%E7%AE%97/4?_=1766039682973">https://forum.ytmicro.com/topic/257/trng-真随机数产生时间计算/4?_=1766039682973</a><br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/105/bd00b5f8-0753-4c2d-99c1-c29891e6d64a.png" alt="ce4448b2-92f6-4c3e-99df-f0ae31fed27e-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/post/9614</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9614</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:37:16 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:31:50 GMT]]></title><description><![CDATA[<p dir="auto">嗯嗯，32 字节缓存那个来实现其实也缩短了</p>
]]></description><link>https://forum.ytmicro.com/post/9613</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9613</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:31:50 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:27:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/1288">沈宇恒</a> 好的，那如果要是想缩短单次获取的时间的话，就只能修改ent_dly或slow_bus_clk了对吧</p>
]]></description><link>https://forum.ytmicro.com/post/9612</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9612</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:27:30 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:25:44 GMT]]></title><description><![CDATA[<p dir="auto">原始采样总数0x200，256 个输出 bit 的熵不可能超过输入的原始采样数这是信息论下限，这个寄存器0x100已经是数学下限了，你改成0x20电路只能输出大量确定性内容，这个是TRNG 熵源的安全参数不能修改的哈，不要在这个上面挖时间，修改这个要重跑NIST SP800-22才能用</p>
]]></description><link>https://forum.ytmicro.com/post/9611</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9611</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:25:44 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 08:19:21 GMT]]></title><description><![CDATA[<p dir="auto">我使用的macl版本是2.0.3，我之前确实修改的是上图中的内部代码，要修改samp_size是修改Random_Generate_Length？Random_Generate_Length是单次获取的长度，samp_size是生成熵时所采集的样本总数，按照介绍获取随机数的最大时间根samp_size、ent_dly、slow_clk有关，如果我想尽量减少生成的时间，那不应该修改samp_size吗？<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/105/bba71640-9a2b-428d-8503-6229a8629ed7.png" alt="image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/post/9610</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9610</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 08:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 07:46:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/105">zhai</a> 你用的是哪个版本的？以前的老版本不能32字节丢数据；而且你是不是改了内部代码，这个值是不能动的哦，samp_size你获取的字节不是改这个，是改Random_Generate_Length<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/1288/f48f58cc-2780-4363-a239-18f514dd62e4.png" alt="c91b87a0-fe7c-4a3e-ba23-b4b19bec1a90-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/post/9609</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9609</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 07:46:25 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 07:39:13 GMT]]></title><description><![CDATA[<p dir="auto">我刚刚试了一下并没有哦<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/1288/70a11d71-c4e9-46c4-b91f-200dbc7c9038.jpg" alt="dc142309-a30f-4ad0-9390-d04c19607912-img_v3_02156_7a637570-c762-45a6-ab18-c54a2ffe6cbg.jpg" class=" img-fluid img-markdown" /><br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/1288/6d4028e0-7cc3-4f40-b648-cb5eba6baa11.jpg" alt="d38429a4-e901-4133-9c6b-2218316a4d8f-img_v3_02156_704680e5-c40b-4589-bd7b-6d4a9659544g.jpg" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/post/9608</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9608</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 07:39:13 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 07:28:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/1288">沈宇恒</a> 目前就是这样操作的，上面结构体中的配置参数还是按照demo中的什么都不修改，samp_szie设置为0x20，ent_dly设置为0x200，调用CryptoTest_Asyn_SingleCall_Random接口去获取也是按照32字节去获取的，但是获得的随机数还是相同的<br />
下图是连续两次获取的结果<br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/105/b957badd-9328-4cd0-bce8-624c1c441a1c.png" alt="73713a2a-5536-4879-a367-43cb8b60f470-image.png" class=" img-fluid img-markdown" /><br />
<img src="https://yt-static-main.oss-cn-shanghai.aliyuncs.com/nodebb/105/f07bacf7-1724-46c3-8335-8a5e1bb605ab.png" alt="826fabf6-52b8-48c0-8931-0bb63d2a27f3-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.ytmicro.com/post/9606</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9606</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 07:28:21 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 07:10:52 GMT]]></title><description><![CDATA[<p dir="auto">驱动校验要求长度是 4 的倍数，你如果要3字节的随机数生成出来自己扔掉就行，尽量缩短获取随机数的时间可以按 32 字节发一次作业存进池，每次请求从池里取 3 字节，池空了再触发下一次</p>
]]></description><link>https://forum.ytmicro.com/post/9605</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9605</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 07:10:52 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 07:01:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/1288">沈宇恒</a> 如果我想获得3字节的随机数并且想尽量缩短获取随机数的时间，samp_szie设置为0x20时，上面应该如何修改？我尝试修改为0x20后连续获取的随机数一直是一个值</p>
]]></description><link>https://forum.ytmicro.com/post/9604</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9604</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 07:01:35 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 06:58:59 GMT]]></title><description><![CDATA[<p dir="auto">有的，可以咨询 FAE</p>
]]></description><link>https://forum.ytmicro.com/post/9603</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9603</guid><dc:creator><![CDATA[Diga]]></dc:creator><pubDate>Thu, 03 Sep 2026 06:58:59 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 06:58:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.ytmicro.com/uid/23">Diga</a> YT针对随机数这块有相应的测试数据报告吗</p>
]]></description><link>https://forum.ytmicro.com/post/9601</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9601</guid><dc:creator><![CDATA[zhai]]></dc:creator><pubDate>Thu, 03 Sep 2026 06:58:25 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 06:57:05 GMT]]></title><description><![CDATA[<p dir="auto">问题2：Random_Generate_Length = 32 是软件输出缓冲长度，必须 ≤32、4 字节对齐，它决定的是你获取的随机数长度一次只能最多256bit，如果要生成更多那就得多生成几次；PrimitiveInfo 里的 32 是 Crypto 作业结构字段，跟 TRNG 采样无关，所以修改不修改都没有作用；</p>
]]></description><link>https://forum.ytmicro.com/post/9600</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9600</guid><dc:creator><![CDATA[沈宇恒]]></dc:creator><pubDate>Thu, 03 Sep 2026 06:57:05 GMT</pubDate></item><item><title><![CDATA[Reply to HA01   MCAL中使用TRNG模块获取随机数 on Thu, 03 Sep 2026 06:53:09 GMT]]></title><description><![CDATA[<p dir="auto">你同一种配置，在不同轮次的结果不也不一样嘛，这不是符合随机性嘛。HA01 一次会生成 256-bit 的真随机数，当样本数够大时，里面出现 0-bit 与 1-bit 的个数应该是一样的。如果想自己测随机性，可以参考 NIST SP 800-22 测试方法，这个对随机性的测试是比较科学严谨的</p>
]]></description><link>https://forum.ytmicro.com/post/9598</link><guid isPermaLink="true">https://forum.ytmicro.com/post/9598</guid><dc:creator><![CDATA[Diga]]></dc:creator><pubDate>Thu, 03 Sep 2026 06:53:09 GMT</pubDate></item></channel></rss>