python 实现AES-CMAC算法验证_aescmac算法验证


一、AES-CMAC算法原理及用途

什么是基于AES的CMAC算法?

采用AES加密算法,使用密钥K,对明文P进行加密,得到的密文C,作为明文P的认证码,和明文P一起传输给接收方。接收方收到后,再使用自己的密钥,对明文再做一次AES加密,生成新的认证码,与接收到的发送方的认证码进行对比验证。如果相等,说明明文没有被篡改,接收方就可以接收明文并处理;如果不相等,说明明文被篡改,数据不安全,则丢弃!

这就是基于AES的CMAC算法,多用于消息数据的正确性认证,生成的认证码,叫作message authentication code,消息认证码,简称MAC。

二、python CMAC生成验证算法实现

from Crypto.Cipher import AES
from Crypto.Hash import CMAC
from binascii import hexlify, unhexlify
import binascii
import os

key = unhexlify(‘2b7e151628aed2a6abf7158809cf4f3c’)
#print(“key:”, key.decode())

message = unhexlify(‘6bc1bee22e409f96e93d7e117393172a’)
#print(“message:”, message.decode())

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂&#x

  • 7
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值