javacard mac相关

本文介绍了MAC(消息认证码)及其变种HMAC的概念与实现原理,详细解释了MAC填充方式的不同方法,并深入探讨了ALG_DES_MAC8_ISO9797_1_M2_ALG3这一特定算法的工作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MAC, (message authentication code), just a personal digest algorithm with a secret key.

HMAC, just a MAC with standard digest algorithm. Hashed twice. The secret key just do XOR operation.

mac填充方式:

    PKCS5: Pad with bytes all of the same value as the number of padding bytes. it’s also the same as PKCS5 and RFC 3852 Cryptographic Message Syntax (CMS)

    ISO 9797 method 1: Pad with zero (null) characters.

    ISO 9797 method 2:   Pad with 0x80 followed by zero bytes. if the last block is full

ALG_DES_MAC8_ISO9797_1_M2_ALG3 算法流程:

1. Pad the data to be signed with method 2: (pad方式见The Padding method)

2, Encrypt the padded data with K1 in DES CBC mode

3, Decrypt the last block with K2 in DES ECB mode

4, Encrypt the last block with K1 in DES ECB mode

Then the last block is our signature.

 

 

The Padding method:

Pad the message M according to ISO 7816-4 (which is equivalent to method 2 of ISO/IEC 9797), hence add a mandatory ‘80’ byte to the right of MSG, and then add the smallest number of ‘00’ bytes to the right such that the length of resulting message MSG := (MSG || ‘80’ || ‘00’ || ‘00’ || . . . || ‘00’) is a multiple of 8 bytes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值