Miracle密码算法开源库(九)分析 :mrebrick.c

本文详细介绍了Miracle密码算法开源库中的mrebrick.c文件,重点解析了ebrick_init()、ebrick_end()和mul_brick()函数。ebrick_init()用于初始化GF(p)椭圆曲线乘法,mul_brick()实现GF(p)椭圆曲线的预计算乘法,而ebrick_end()则负责释放内存。文章深入探讨了这些函数的工作原理,涉及蒙哥马利算法、Comb方法及椭圆曲线运算。
摘要由CSDN通过智能技术生成

2021SC@SDUSC 山东大学软件学院软件工程应用与实践

1、mrebrick.c结构


mrebrick.c的总体结构如下,,主要实现了ebrick_init()、 ebrick_end()、mul_brick()几个在miracl开源库中比较重要的函数,这一次的博客就是读一下这函数的功能。

  2、源代码 


BOOL ebrick_init(_MIPD_ ebrick *B,big x,big y,big a,big b,big n,int window,int nb)
{ /* Uses Montgomery arithmetic internally              *
   * (x,y) is the fixed base                            *
   * a,b and n are parameters and modulus of the curve  *
   * window is the window size in bits and              *
   * nb is the maximum number of bits in the multiplier */
    int i,j,k,t,bp,len,bptr,is;
    epoint **table;
    epoint *w;

#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(115)

#ifndef MR_ALWAYS_BINARY
    if (mr_mip->base != mr_mip->base2)
    {
        mr_berror(_MIPP_ MR_ERR_NOT_SUPPORTED);
        MR_OUT
        return FALSE;
    }
#endif

    B->window=window;
    B->max=nb;
    table=(epoint **)mr_alloc(_MIPP_ (1<<window),sizeof(epoint *));
    if (table==NULL)
    {
        mr_berror(_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值