I can't understand this Code line

Thread Starter

maraim

Joined Feb 2, 2016
4
Hi, am working on a security protocol SH256 however i can't understand this line even though there is a comment

// DBL_INT_ADD treats two unsigned ints a and b as one 64-bit integer and adds c to it
#define DBL_INT_ADD(a,b,c) if (a > 0xffffffff - (c)) ++b; a += c;

he compared "a" with (0xffffffff - (c)) then as the comment says he concatenated "a" and "b" then adds "c" to "a" ? is that it ?
but if a ,b and c are all integer (4 bytes) than "a "will never be greater than (0xffffffff - (c)) !!?
 

AlbertHall

Joined Jun 4, 2014
12,343
a is taken as the least significant byte and b as the most significant.
So if (a > 0xffffffff - (c)) is asking the question whether a+c will overflow and if it does then increment b
Finally add a+c.
 
Top