- nist_set_256(t_d2,buf, 0, 15, 14, 13, 12, 0, 0, 0);
- carry = bn_add_words(t_d, t_d, t_d2, BN_NIST_256_TOP);
- /* left shift */
- {
- register BN_ULONG *ap,t,c;
- ap = t_d;
- c=0;
- for (i = BN_NIST_256_TOP; i != 0; --i)
- {
- t= *ap;
- *(ap++)=((t<<1)|c)&BN_MASK2;
- c=(t & BN_TBIT)?1:0;
- }
- carry <<= 1;
- carry |= c;
- }
+ nist_set_256(c_d,buf, 0, 15, 14, 13, 12, 0, 0, 0);
+ carry = bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP);
+ mask = 0-(size_t)bn_sub_words(c_d,t_d,_nist_p_256,BN_NIST_256_TOP);
+ mask = ~mask | (0-(size_t)carry);
+ res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)t_d&~mask));
+
+ carry = bn_add_words(t_d, res, res, BN_NIST_256_TOP);
+ mask = 0-(size_t)bn_sub_words(c_d,t_d,_nist_p_256,BN_NIST_256_TOP);
+ mask = ~mask | (0-(size_t)carry);
+ res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)t_d&~mask));
+
+ carry = bn_add_words(r_d, r_d, res, BN_NIST_256_TOP);
+ mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_256,BN_NIST_256_TOP);
+ mask = ~mask | (0-(size_t)carry);
+ res = (BN_ULONG *)(((size_t)c_d&mask) | ((size_t)r_d&~mask));