⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp_core2.cpp

📁 含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种CheckSum校验、多种MAC校验等几十种加密算法的程序
💻 CPP
字号:
/************************************************** Two Operand MP Algorithms Source File          ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/mp_core.h>extern "C" {/************************************************** Two Operand Addition Without Carry             **************************************************/word bigint_add2_nc(word* const x, u32bit x_size,                    const word* y, u32bit y_size)   {   word carry = 0;   for(u32bit j = 0; j != y_size; j++)      {      dword sum = ((dword)x[j] + y[j]) + carry;      x[j] = MP_LOW_WORD(sum);      carry = MP_HIGH_WORD(sum);      }   if(!carry)      return 0;   for(u32bit j = y_size; j != x_size; j++)      {      x[j]++;      if(x[j])         return 0;      }   return 1;   }/************************************************** Two Operand Addition                           **************************************************/void bigint_add2(word* const x, u32bit x_size,                 const word* y, u32bit y_size)   {   x[x_size] += bigint_add2_nc(x, x_size, y, y_size);   }/************************************************** Two Operand Subtraction                        **************************************************/void bigint_sub2(word* const x, u32bit x_size,                 const word* y, u32bit y_size)   {   word borrow = 0;   for(u32bit j = 0; j != y_size; j++)      {      dword temp = ((MP_RADIX + x[j]) - y[j]) - borrow;      borrow = ((temp < MP_RADIX) ? 1 : 0);      x[j] = (word)(temp - MP_RADIX);      }   for(u32bit j = y_size; j != x_size; j++)      {      if(borrow == 0)         break;      dword temp = (MP_RADIX + x[j]) - borrow;      borrow = ((temp < MP_RADIX) ? 1 : 0);      x[j] = (word)(temp - MP_RADIX);      }   }/************************************************** Two Operand Linear Multiply                    **************************************************/void bigint_linmul2(word* const x, u32bit x_size, word y)   {   word carry = 0;   for(u32bit j = 0; j != x_size; j++)      {      dword product = (dword)x[j] * y + carry;      x[j] = MP_LOW_WORD(product);      carry = MP_HIGH_WORD(product);      }   x[x_size] = carry;   }}

⌨️ 快捷键说明

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