--- /dev/null
+îîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî\16\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\16
\ No newline at end of file
md_gost12_512(M5)= 363b449ec81ae40b3a407b125c3b1c2b768b50496bcb5f690b89e9007b06e4084182ed45d4072a67fec9d3421dab013da2aabc1d6528e8e775aec7b3457ac675
md_gost12_512(M6)= 8781dfc81d2db6a41d1857f3230b3ffe2bda574273ea1947189aaa5468470df1c4b374b1a2b56e59d11d213fea57e3514543b0ced9b20e553ae66425ec909cfd
md_gost12_512(M7)= 03e12ae816c7f794929b7550781d22efc7bc724fd70e295f3123d157c4d577fdc325943ef2b999cc43205dc323fa930bddc60d44663d76844b779fd36aa89de3
+md_gost12_512(carry)= 8b06f41e59907d9636e892caf5942fcdfb71fa31169a5e70f0edb873664df41c2cce6e06dc6755d15a61cdeb92bd607cc4aaca6732bf3568a23a210dd520fd41
md_gost12_256(M1)= 9d151eefd8590b89daa6ba6cb74af9275dd051026bb149a452fd84e5e57b5500
md_gost12_256(M2)= 9dd2fe4e90409e5da87f53976d7405b0c0cac628fc669a741d50063c557e8f50
md_gost12_256(M3)= 3f539a213e97c802cc229d474c6aa32a825a360b2a933a949fd925208d9ce1bb
md_gost12_256(M5)= f0a557f6a04a90ab1811c1b6e9b078e4163b74037c6cf59f52444a37f48e11d8
md_gost12_256(M6)= 2f4f651fe88fea46ec6f2223728d8dff3968893558ef00a310c23e7d1923ba0c
md_gost12_256(M7)= 633b567983d60243837715e56cc52443ffff9824170ad60b613b2dd6fabf2f40
+md_gost12_256(carry)= 81bb632fa31fcc38b4c379a662dbc58b9bed83f50d3a1b2ce7271ab02d25babb
{
#ifndef __GOST3411_BIG_ENDIAN__
unsigned int CF, OF;
+ unsigned long long tmp;
unsigned int i;
CF = 0;
- for (i = 0; i < 8; i++) {
- r->QWORD[i] = x->QWORD[i] + y->QWORD[i];
- if (r->QWORD[i] < y->QWORD[i] || r->QWORD[i] < x->QWORD[i])
+ for (i = 0; i < 8; i++)
+ {
+ /* Detecting integer overflow condition for three numbers
+ * in a portable way is tricky a little. */
+
+ /* Step 1: numbers cause overflow */
+ tmp = x->QWORD[i] + y->QWORD[i];
+
+ /* Compare with any of two summands, no need to check both */
+ if (tmp < x->QWORD[i])
OF = 1;
else
OF = 0;
- r->QWORD[i] += CF;
+ /* Step 2: carry bit causes overflow */
+ tmp += CF;
+
+ if (CF > 0 && tmp == 0)
+ OF = 1;
+
CF = OF;
+
+ r->QWORD[i] = tmp;
}
#else
const unsigned char *xp, *yp;