c++ - HMAC_GOST341194 value mismatch -


i'm not sure place right choise kind of issues(it's rather crypto related), there no other hope spot error, unfortunately.

so, here code use compute hmac_gost341194:

hmac hmac; string step1, step2, step3;  ipad.assign(blocksize, 0x36); opad.assign(blocksize, 0x5c);  (size_t = 0ul, e = length; < e; ++i)  {     ipad.replace(i, 1, 1, secret[i] ^ 0x36);     opad.replace(i, 1, 1, secret[i] ^ 0x5c); }  step1 = ipad + text;  hmac.hash(step1, step1.length(), step2);  step3 = opad + step2;  hmac.hash(step3, step3.length(), mac); 

hash function double checked - there no errors , test values equal other sources.

my block size 256.

i use following s-boxes(cryptopro param set):

const unsigned char s[8][16] = {     { 10,   4,  5,  6,  8,  1,  3,  7,  13, 12, 14, 0,  9,  2,  11, 15  },     { 5,    15, 4,  0,  2,  13, 11, 9,  1,  7,  6,  3,  12, 14, 10, 8   },     { 7,    15, 12, 14, 9,  4,  1,  0,  3,  11, 5,  2,  6,  10, 8,  13  },     { 4,    10, 7,  12, 0,  15, 2,  8,  14, 1,  6,  5,  13, 11, 9,  3   },     { 7,    6,  4,  11, 9,  12, 2,  10, 1,  8,  0,  14, 15, 13, 3,  5   },     { 7,    6,  2,  4,  13, 9,  15, 0,  10, 1,  5,  11, 8,  14, 12, 3   },     { 13,   14, 4,  1,  7,  0,  5,  10, 3,  12, 8,  15, 6,  2,  9,  11  },     { 1,    3,  10, 9,  5,  11, 4,  15, 8,  6,  7,  14, 13, 0,  2,  12  }, };  

here have example(the sample found):

k(ascii) = "s=, ehesttgiyga bnss esi2leh3 mt" k(in hex) = 733d2c20 65686573 74746769 79676120 626e7373 20657369 326c6568 33206d54 (32 bytes)  text (ascii) = "this message, length=32 bytes" text (in hex) = 54686973 20697320 6d657373 6167652c 206c656e 6774683d 33322062 79746573  hmac_gostr3411 = 4ff66c94 bddaae61 13360514 2b582b9c 0f38bbdf f3d7f0ee 6a9c935d 92bfa107 

however, value is: c0f2fe71c3ca016356722646308b69453bb4cd1e232231e04beb03db6976f128

any of providing more test data or either reject/verify existing appreciated.

i've found answer question: example incorrect, there bug in code either.

so, assuming

k(ascii) = "s=, ehesttgiyga bnss esi2leh3 mt"  text (ascii) = "this message, length=32 bytes" 
  1. ipad || text hash is: e9d755a47f72a558ae5e75f5b141f5b174e7b1fed281436f3fe835d78d0d9f05
  2. opad || hash(ipad || text) hash is: 8ff55ddaab167a22de98286f10458a1619bc45c88f6eac9ce947ed3ffb348822

second value hmac_gost341194 itself.

all hashes computed using code , verified using cpverify params cpverify.exe -mk -alg gr3411 "%your_path_to_file%\hash.txt" pause

hope save couple hours of time not research why example hmac computed incorrectly here.

poc available here.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -