标签: cbc-mac

C#中的ISO 9797-1算法1 [CBC-MAC]

似乎CBC-MAC算法有6种变化.我一直在努力匹配PINPad 1000SE上的MAC算法[每本手册都是ISO 9797-1算法1].

我从这里开始了一个很好的开始.

我将算法编码如下:

public static byte[] CalculateMAC(this IPinPad pinpad, byte[] message, byte[] key)
{
    //Divide the key with Key1[ first 64 bits] and key2 [last 64 bits]
    var key1 = new byte[8];
    Array.Copy(key, 0, key1, 0, 8);

    var key2 = new byte[8];
    Array.Copy(key, 8, key2, 0, 8); //64 bits

    //divide the message into 8 bytes blocks
    //pad the last block with "80" and "00","00","00" until it reaches 8 bytes
    //if the message already can be divided …
Run Code Online (Sandbox Code Playgroud)

algorithm cbc-mac

10
推荐指数
1
解决办法
8489
查看次数

使用一个密钥进行加密和HMAC

我想知道我是否可以使用在两个客户端之间建立的共享密钥作为HMAC密钥.

我看到当它被用作CBC-MAC时存在问题,但我没有发现任何证据表明HMAC是不好的做法.

谢谢,弗拉基米尔

cryptography key cbc-mac hmac

5
推荐指数
1
解决办法
2717
查看次数

使用AES-256和C语言中的openssl计算CBC-MAC

我想用openssl计算给定明文的CBC-MAC.我有以下明文(hexdump):

hexdump -C example.txt
00000000  4d 41 43 73 20 61 72 65  20 76 65 72 79 20 75 73  |MACs are very us|
00000010  65 66 75 6c 20 69 6e 20  63 72 79 70 74 6f 67 72  |eful in cryptogr|
00000020  61 70 68 79 21 20 20 20  20 20 20 20 20 20 20 20  |aphy!           |
Run Code Online (Sandbox Code Playgroud)

如果我使用openssl的命令行函数,我得到以下解决方案:

openssl aes-256-cbc -in example.txt -K 8000000000000000000000000000000000000000000000000000000000000001 -e -iv 00 | hexdump -C
00000000  e8 e9 …
Run Code Online (Sandbox Code Playgroud)

c openssl cryptography aes cbc-mac

3
推荐指数
1
解决办法
1641
查看次数

标签 统计

cbc-mac ×3

cryptography ×2

aes ×1

algorithm ×1

c ×1

hmac ×1

key ×1

openssl ×1