Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Dec 29, 2024
1 parent be7b8a1 commit d2dbb35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/bn/relic_bn_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,10 @@ void bn_rec_rtnaf(int8_t *tnaf, size_t *len, const bn_t k, int8_t u, size_t m,
}

void bn_rec_reg(int8_t *naf, size_t *len, const bn_t k, size_t n, size_t w) {
int i, l = RLC_CEIL(n, w - 1), d = RLC_CEIL(n, RLC_DIG);
/* Leave some room in case n and w do not align perfectly. */
size_t l = RLC_CEIL(n, w - 1), d = RLC_CEIL(n, RLC_DIG) + 1;
dig_t mask, *t = RLC_ALLOCA(dig_t, d);
int8_t u_i;
int8_t i, u_i;

mask = RLC_MASK(w);

Expand Down
18 changes: 14 additions & 4 deletions src/ep/relic_ep_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
* Domain separation string.
*/
#define MAP_STRING (const uint8_t *)"RELIC"
#define MAPDST "RELIC"

#ifdef EP_CTMAP

Expand Down Expand Up @@ -444,8 +444,13 @@ void ep_map_basic(ep_t p, const uint8_t *msg, size_t len) {
const size_t elm = (FP_PRIME + ep_param_level() + 7) / 8;
uint8_t *r = RLC_ALLOCA(uint8_t, elm);

if (r == NULL) {
RLC_THROW(ERR_NO_BUFFER);
return;
}

RLC_TRY {
md_xmd(r, elm, msg, len, MAP_STRING, sizeof(MAP_STRING));
md_xmd(r, elm, msg, len, (const uint8_t *)MAPDST, strlen(MAPDST));
ep_map_basic_impl(p, r, elm);
}
RLC_CATCH_ANY {
Expand All @@ -465,12 +470,17 @@ void ep_map_sswum(ep_t p, const uint8_t *msg, size_t len) {
const size_t elm = (FP_PRIME + ep_param_level() + 7) / 8;
uint8_t *r = RLC_ALLOCA(uint8_t, 2 * elm);

if (r == NULL) {
RLC_THROW(ERR_NO_BUFFER);
return;
}

RLC_TRY {
/* for hash_to_field, need to hash to a pseudorandom string */
/* XXX(rsw) the below assumes that we want to use MD_MAP for hashing.
* Consider making the hash function a per-curve option!
*/
md_xmd(r, 2 * elm, msg, len, MAP_STRING, sizeof(MAP_STRING));
md_xmd(r, 2 * elm, msg, len, (const uint8_t *)MAPDST, sizeof(MAPDST));
/* figure out which hash function to use */
const int abNeq0 = (ep_curve_opt_a() != RLC_ZERO) &&
(ep_curve_opt_b() != RLC_ZERO);
Expand Down Expand Up @@ -510,7 +520,7 @@ void ep_map_swift(ep_t p, const uint8_t *msg, size_t len) {
}

RLC_TRY {
md_xmd(r, 2 * elm + 1, msg, len, MAP_STRING, sizeof(MAP_STRING));
md_xmd(r, 2*elm + 1, msg, len, (const uint8_t *)MAPDST, sizeof(MAPDST));

ep_map_swift_impl(p, r, 2 * elm + 1);
}
Expand Down

0 comments on commit d2dbb35

Please sign in to comment.