/* $Id$ */ /* * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. * * This work contains proprietary information of RSA Security. * Distribution is limited to authorized licensees of RSA * Security. Any unauthorized reproduction, distribution or * modification of this work is strictly prohibited. * */ #include "bn_lcl.h" #ifndef OPT_BN_ASM #ifndef BN_DIV_WORDS #define BN_DIV_WORDS #endif #endif #ifdef BN_DIV_WORDS #if defined(BN_LLONG) BN_ULONG bn_div_words(h,l,d) BN_ULONG h,l,d; { return((BN_ULONG)(((((BN_ULLONG)h)< ((BN_ULONG)1)<= d) h-=d; if (i) { d=(d<>(BN_BITS2-i)))&BN_MASK2; l=(l<>BN_BITS4)&BN_MASK2lh; dl=(d&BN_MASK2l); for (;;) { if ((h>>BN_BITS4) == dh) q=BN_MASK2l; else q=h/dh; for (;;) { t=(h-q*dh)&BN_MASK2; if ((t&BN_MASK2h) || (((dl*q)&BN_MASK2) <= (( (t<>BN_BITS4)&BN_MASK2lh))&BN_MASK2))) break; q--; } th=(q*dh)&BN_MASK2; tl=(q*dl)&BN_MASK2; t=(tl>>BN_BITS4); tl=(tl&BN_MASK2lh)<>BN_BITS4))&BN_MASK2; l=(l&BN_MASK2l)<