2021SC@SDUSC 山东大学软件学院软件工程应用与实践
1、mrbrick.c结构
mrbrick.c的总体结构如下,,主要实现了brick_init()、 brick_end()、pow_brick()几个在miracl开源库中比较重要的函数,这一次的博客就是读一下这函数的功能。
2、源代码
BOOL brick_init(_MIPD_ brick *b,big g,big n,int window,int nb)
{ /* Uses Montgomery arithmetic internally *
* g is the fixed base for exponentiation *
* n is the fixed modulus *
* nb is the maximum number of bits in the exponent */
int i,j,k,t,bp,len,bptr,is;
big *table;
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (nb<2 || window<1 || window>nb || mr_mip->ERNUM) return FALSE;
t=MR_ROUNDUP(nb,window);
if (t<2) return FALSE;
MR_IN(109)
#ifndef MR_ALWAYS_BINARY
if (mr_mip->base != mr_mip->base2)