relic-toolkit / relic

Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bn_mod_pmers hangs if modulus is 0

guidovranken opened this issue · comments

#include <relic_conf.h>
#include <relic.h>

int main(void)
{
    if ( core_init() != RLC_OK ) abort();

    bn_t A, B, tmp, R;

    bn_null(A); bn_new(A);
    bn_null(B); bn_new(B);
    bn_null(tmp); bn_new(tmp);
    bn_null(R); bn_new(R);

    const char* s1 = "1";
    const char* s2 = "0";

    bn_read_str(A, s1, strlen(s2), 10);
    bn_read_str(B, s2, strlen(s2), 10);

    bn_mod_pre_pmers(tmp, B);
    bn_mod_pmers(R, A, B, tmp);

    bn_free(A);
    bn_free(B);
    bn_free(tmp);
    bn_free(R);
    return 0;
}

Maybe it should set the result to 0 like the other mod functions?

Confirmed fixed.