信息安全实战01_基于AES(CMAC)加密算法脚本开发

前言

在信息安全中有两个非常重要的应用:安全启动及安全刷新,所谓安全启动即是在用户程序启动前,先进行校验,防止恶意或被篡改的程序得到允许,安全刷新则是在对软件包刷新前,校验刷新包是不是被篡改过,两者目的都是保护程序的完整性与真实性。

在安全刷新及安全启动中普遍采用的技术是数字签名,可采用的加密方式有非对称加密及对称加密方式,两者的区别往大的说就是非对称加密安全性更高,但比较吃算力,对称加密的加解密只有一把秘钥安全性相对差一点但计算的速度比较快。

以上为背景,本文假设具体需求为:请通过python脚本对起始地址0x0000F300,数据长度为128K的数据,基于AES128算法进行CMAC认证,并将CMAC值patch到原hex中。

对需求进行拆分,需要我们做的主要是如下几点:

  1. 对hex文件解析,如何找到待计算的block;
  2. 如何在对称加密AES128算法计算对应Block的MAC值;
  3. 如何将计算的MAC填充到hex中。

本文大纲如下:
在这里插入图片描述

1. 基于AES128的CMAC认证脚本开发

1.1 hex文件解析

在进行AES CMAC认证前需要对hex文件进行解析,主要目的是获取待校验的数据,hex文件格式解析之前有篇文章详细介绍了:

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
详细介绍了AES-CMAC的算法的原理与实现,附有C语言写的样例程序。 以下是原文的introduction: The National Institute of Standards and Technology (NIST) has recently specified the Cipher-based Message Authentication Code(CMAC). CMAC [NIST-CMAC] is a keyed hash function that is based on a symmetric key block cipher, such as the Advanced Encryption Standard [NIST-AES]. CMAC is equivalent to the One-Key CBC MAC1 (OMAC1) submitted by Iwata and Kurosawa [OMAC1a, OMAC1b]. OMAC1 is an improvement of the eXtended Cipher Block Chaining mode (XCBC) submitted by Black and Rogaway [XCBCa, XCBCb], which itself is an improvement of the basic Cipher Block Chaining-Message Authentication Code (CBC-MAC). XCBC efficiently addresses the security deficiencies of CBC-MAC, and OMAC1 efficiently reduces the key size of XCBC. AES-CMAC provides stronger assurance of data integrity than a checksum or an error-detecting code. The verification of a checksum or an error-detecting code detects only accidental modifications of the data, while CMAC is designed to detect intentional, unauthorized modifications of the data, as well as accidental modifications. AES-CMAC achieves a security goal similar to that of HMAC [RFC-HMAC]. Since AES-CMAC is based on a symmetric key block cipher, AES, and HMAC is based on a hash function, such as SHA-1, AES-CMAC is appropriate for information systems in which AES is more readily available than a hash function. This memo specifies the authentication algorithm based on CMAC with AES-128. This new authentication algorithm is named AES-CMAC.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Autosar汽车电子进阶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值