mp_misc.cpp

来自「含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种Chec」· C++ 代码 · 共 55 行

CPP
55
字号
/************************************************** Misc MP Functions Source File                  ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/mp_core.h>extern "C" {/************************************************** Division Core                                  **************************************************/bool bigint_divcore(word q, word y_1, word y_2,                    word x_1, word x_2, word x_3)   {   dword product = (dword)q * y_2;   y_2 = MP_LOW_WORD(product);   product = (dword)q * y_1 + MP_HIGH_WORD(product);   y_1 = MP_LOW_WORD(product);   word y_0 = MP_HIGH_WORD(product);   if(y_0 > x_1) return true;   if(y_0 < x_1) return false;   if(y_1 > x_2)  return true;   if(y_1 < x_2)  return false;   if(y_2 > x_3)  return true;   if(y_2 < x_3)  return false;   return false;   }/************************************************** Compare                                        **************************************************/s32bit bigint_cmp(const word* x, u32bit x_size,                  const word* y, u32bit y_size)   {   if(x_size < y_size) { return (-bigint_cmp(y, y_size, x, x_size)); }   while(x_size > y_size)      {      if(x[x_size-1])         return 1;      x_size--;      }   for(u32bit j = x_size; j > 0; j--)      {      if(x[j-1] > y[j-1]) return 1;      if(x[j-1] < y[j-1]) return -1;      }   return 0;   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?