63 #if defined( _WIN32_WCE ) && _WIN32_WCE < 400
68 #if defined( INC_ALL )
76 #if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
83 if (num <= 0)
return(c1);
95 mul_add(rp[0],ap[0],w,c1);
if (--num==0)
return c1;
96 mul_add(rp[1],ap[1],w,c1);
if (--num==0)
return c1;
97 mul_add(rp[2],ap[2],w,c1);
return c1;
108 if (num <= 0)
return(c1);
112 mul(rp[0],ap[0],w,c1);
113 mul(rp[1],ap[1],w,c1);
114 mul(rp[2],ap[2],w,c1);
115 mul(rp[3],ap[3],w,c1);
116 ap+=4; rp+=4; num-=4;
120 mul(rp[0],ap[0],w,c1);
if (--num == 0)
return c1;
121 mul(rp[1],ap[1],w,c1);
if (--num == 0)
return c1;
122 mul(rp[2],ap[2],w,c1);
141 sqr(r[0],r[1],a[0]);
if (--n == 0)
return;
142 sqr(r[2],r[3],a[1]);
if (--n == 0)
return;
163 if (--num == 0)
break;
165 if (--num == 0)
break;
167 if (--num == 0)
break;
169 if (--num == 0)
break;
189 mul(rp[0],ap[0],bl,bh,carry);
190 if (--num == 0)
break;
191 mul(rp[1],ap[1],bl,bh,carry);
192 if (--num == 0)
break;
193 mul(rp[2],ap[2],bl,bh,carry);
194 if (--num == 0)
break;
195 mul(rp[3],ap[3],bl,bh,carry);
196 if (--num == 0)
break;
209 sqr64(r[0],r[1],a[0]);
212 sqr64(r[2],r[3],a[1]);
215 sqr64(r[4],r[5],a[2]);
218 sqr64(r[6],r[7],a[3]);
228 #if defined(BN_LLONG) && defined(BN_DIV2W)
294 if (--count == 0)
break;
315 ll+=(BN_ULLONG)a[0]+b[0];
320 ll+=(BN_ULLONG)a[1]+b[1];
325 ll+=(BN_ULLONG)a[2]+b[2];
330 ll+=(BN_ULLONG)a[3]+b[3];
404 if (t1 != t2) c=(t1 < t2);
409 if (t1 != t2) c=(t1 < t2);
414 if (t1 != t2) c=(t1 < t2);
419 if (t1 != t2) c=(t1 < t2);
442 #define mul_add_c(a,b,c0,c1,c2) \
444 t1=(BN_ULONG)Lw(t); \
445 t2=(BN_ULONG)Hw(t); \
446 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
447 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
449 #define mul_add_c2(a,b,c0,c1,c2) \
453 t1=(BN_ULONG)Lw(tt); \
454 t2=(BN_ULONG)Hw(tt); \
455 c0=(c0+t1)&BN_MASK2; \
456 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
457 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
459 #define sqr_add_c(a,i,c0,c1,c2) \
460 t=(BN_ULLONG)a[i]*a[i]; \
461 t1=(BN_ULONG)Lw(t); \
462 t2=(BN_ULONG)Hw(t); \
463 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
464 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
466 #define sqr_add_c2(a,i,j,c0,c1,c2) \
467 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
469 #elif defined(BN_UMULT_HIGH)
471 #define mul_add_c(a,b,c0,c1,c2) { \
472 BN_ULONG ta=(a),tb=(b); \
474 t2 = BN_UMULT_HIGH(ta,tb); \
475 c0 += t1; t2 += (c0<t1)?1:0; \
476 c1 += t2; c2 += (c1<t2)?1:0; \
479 #define mul_add_c2(a,b,c0,c1,c2) { \
480 BN_ULONG ta=(a),tb=(b),t0; \
481 t1 = BN_UMULT_HIGH(ta,tb); \
483 t2 = t1+t1; c2 += (t2<t1)?1:0; \
484 t1 = t0+t0; t2 += (t1<t0)?1:0; \
485 c0 += t1; t2 += (c0<t1)?1:0; \
486 c1 += t2; c2 += (c1<t2)?1:0; \
489 #define sqr_add_c(a,i,c0,c1,c2) { \
490 BN_ULONG ta=(a)[i]; \
492 t2 = BN_UMULT_HIGH(ta,ta); \
493 c0 += t1; t2 += (c0<t1)?1:0; \
494 c1 += t2; c2 += (c1<t2)?1:0; \
497 #define sqr_add_c2(a,i,j,c0,c1,c2) \
498 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
501 #define mul_add_c(a,b,c0,c1,c2) \
502 t1=LBITS(a); t2=HBITS(a); \
503 bl=LBITS(b); bh=HBITS(b); \
504 mul64(t1,t2,bl,bh); \
505 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
506 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
508 #define mul_add_c2(a,b,c0,c1,c2) \
509 t1=LBITS(a); t2=HBITS(a); \
510 bl=LBITS(b); bh=HBITS(b); \
511 mul64(t1,t2,bl,bh); \
512 if (t2 & BN_TBIT) c2++; \
513 t2=(t2+t2)&BN_MASK2; \
514 if (t1 & BN_TBIT) t2++; \
515 t1=(t1+t1)&BN_MASK2; \
516 c0=(c0+t1)&BN_MASK2; \
517 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
518 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
520 #define sqr_add_c(a,i,c0,c1,c2) \
521 sqr64(t1,t2,(a)[i]); \
522 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
523 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
525 #define sqr_add_c2(a,i,j,c0,c1,c2) \
526 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
531 #if defined( BN_LLONG )
533 #elif !defined( BN_UMULT_HIGH )
640 #if defined( BN_LLONG )
642 #elif !defined( BN_UMULT_HIGH )
685 #if defined( BN_LLONG )
687 #elif !defined( BN_UMULT_HIGH )
766 #if defined( BN_LLONG )
768 #elif !defined( BN_UMULT_HIGH )