写在前面
在《安全启动模式下的数据保存问题》中,小编介绍了在hab boot和xip encrypted boot下,读写外部nor flash数据的特点以及image的数据特征状态,比如使能xip encrypted boot后,nor flash内的bootable image是密文状态,那是否意味着只要在使能xip encrypted boot后,被加密的bootable image就可以随意下发给oem进行量产烧录,同时在量产后,客户可随意访问加密的bootable image而无需担心application image泄漏呢?
是否泄漏呢?
为了测试是否有泄漏的风险,在mimxrt1060-evk上进行如下步骤测试:
在mcuxpresso secure provisioning工具选择xip encrypted模式,生成并烧录blink led的bootable image;
图1
通过nxp-mcubootutility查看烧录后的image,对比右边框中的明文image会发现密文image显得很是杂乱,即使被查看也应该不会泄漏明文image;
图2
接着换另一种方式查看密文image,即通过pyocd命令读取,具体如下所示,打开9_21_readback.bin与右边框中的明文image比较,发现居然一致,换句话说,明文image被泄漏了;
图3 图4
通过上述测试结果表明,使用后一种方式读取查看密文image居然能得到明文image,直接让xip encrypted boot破防了,这是怎么回事呢?
原因解释
小编在《安全启动模式下的数据保存问题》中提到,存储在serial nor flash中的加密代码和数据在送到cpu执行之前,需要经过bee或者otfad解密,这是 encypted xip boot模式实现的基础,jlink在连接目标mcu时,会把对应的flash驱动算法加载在内部ram中运行,如果此时mcu已经正常启动运行application image的话,则表示bee或者otfad模块也已完成好配置了,那么flash驱动在读nor flash内的密文时,数据会被自动解密。
图 5
应对策略
既然我们已经了解泄漏的原因,就要阻断外部工具加载flashloader或者flash驱动算法到内部ram运行,所以除了禁止debug port外,我们还需要禁止serial download方式,预防不怀好意者利用serial downloader方式,使得rom code加载专门的flashloader到ram中运行,通过配置bee或otfad模块来读取image明文(如下代码所示)。
status = sln_auth_check_context(sln_crypto_ctx_1); configprintf((context check status %d, status)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a crash if (sln_auth_no_context == status) { configprintf((ensuring context...)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a crash // load crypto contexts and make sure they are valid (our own context should be good to get to this point!) status = bl_nor_encrypt_ensure_context(); if (kstatus_fail == status) { configprintf((failed to load crypto context...)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a crash // double check if encrypted xip is enabled if (!bl_nor_encrypt_is_enabled()) { configprintf((not running in encrypted xip mode, ignore error.)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a // crash // no encrypted xip enabled, we can ignore the bad status status = kstatus_success; } } else if (kstatus_readonly == status) // using this status from standard status to indicate that we need to split prdb { volatile uint32_t delay = 1000000; // set up context as needed for this application status = bl_nor_encrypt_split_prdb(); configprintf((restarting bootloader...)); while (delay--) ; // restart dbgconsole_deinit(); nvic_disableirq(lpuart6_irqn); nvic_systemreset(); } } else if (sln_auth_ok == status) { configprintf((ensuring context...)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a crash // we will check to see if we need to update the backup to the reduced scope prdb0 for bootloader space status = bl_nor_encrypt_ensure_context(); if (kstatus_fail == status) { configprintf((failed to load crypto context...)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a crash // double check if encrypted xip is enabled if (!bl_nor_encrypt_is_enabled()) { configprintf((not running in encrypted xip mode, ignore error.)); // no encrypted xip enabled, we can ignore the bad status status = kstatus_success; } } else if (kstatus_success == status) // we have good prdbs so we can update the backup { bool ismatch = false; bool isoriginal = false; configprintf((checking backup context...)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before a crash // check if we have identical kibs and initial ctr status = bl_nor_crypto_ctx_compare_backup(&ismatch, &isoriginal, sln_crypto_ctx_0); if (kstatus_success == status) { if (ismatch && isoriginal) { configprintf((updating backup context with valid address space...)); // debug_log_delay_ms(1000); // optional delay, enable for debugging to ensure log is printed before // a crash // update backup prdb0 status = sln_auth_backup_context(sln_crypto_ctx_0); } } } }
但相较于直接永久禁止debug port的简单粗暴, 小编更加推荐secure debug安全调试,因为产品的售后,维护往往不是一帆风顺的,产品在客户现场有时也是状况频出,所以secure debug[1]就像给debug port加了一把坚固的锁,只有能打开这把锁的人才能使用调试功能。
ARDUINO蜘蛛机器人DIY图解
RDMA RoCEv2、AWS SRD/EFA和阿里云HPCC
美媒放风对华芯片限制有松动,台积电三星可能得到“豁免”
DS1820单总线(1-wire)数字温度传感器
modbus转MQTT支持TCP以太网通讯接入阿里华为云
Encrypted Boot image泄漏讨论
人工智能13种趋势及将在未来几年产生巨大影响
大联大世平集团推出基于NXP产品的跳频无钥匙车辆门禁系统解决方案
很多工程师在选择波特率时非常头疼,一文读懂如何快速解决特殊波特率计算的问题
动力电池技术创新活跃,热安全解决途径走在世界前列
专业医疗器械工业设计的市场会较往年有更加巨大的市场份额
怎样使用SDN优化业务连续性?
照明行业相关输美产品税率变化
云杰通信推出全新企业SD-WAN智能网组
校企合作“芯”篇章丨芯盾时代入选北京工业大学创新创业实训基地
SpaceX 星际飞船原型 SN10 顺利完成首次发动机静态点火测试
人工智能全面布局:小小芯片圆了世界级创新的梦想
九种计算机存储的类型及工作原理
舜宇贝尔:潜伏牵引式物料转运 AGV让人眼前一亮!
AI+RPA端云一体,软通动力积极赋能金融行业数字化转型