Skip to content

Commit

Permalink
Make domain separation tag configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Jan 11, 2025
1 parent 0612d80 commit eef556a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions include/relic_conf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#ifndef RLC_CONF_H
#define RLC_CONF_H

/** Project name */
#define RLC_STRING "@CMAKE_PROJECT_NAME@"
/** Project version. */
#define RLC_VERSION "@VERSION@"

Expand Down
22 changes: 13 additions & 9 deletions src/ep/relic_ep_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
/*============================================================================*/

/**
* Domain separation string.
* Domain separation tag.
*/
#define MAPDST "RELIC"
#ifndef RLC_DSTAG
#define RLC_DSTAG RLC_STRING
#endif

#ifdef EP_CTMAP

Expand Down Expand Up @@ -450,7 +452,7 @@ void ep_map_basic(ep_t p, const uint8_t *msg, size_t len) {
}

RLC_TRY {
md_xmd(r, elm, msg, len, (const uint8_t *)MAPDST, strlen(MAPDST));
md_xmd(r, elm, msg, len, (const uint8_t *)RLC_DSTAG, strlen(RLC_DSTAG));
ep_map_basic_impl(p, r, elm);
}
RLC_CATCH_ANY {
Expand Down Expand Up @@ -480,7 +482,8 @@ void ep_map_sswum(ep_t p, const uint8_t *msg, size_t len) {
/* 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, (const uint8_t *)MAPDST, sizeof(MAPDST));
md_xmd(r, 2 * elm, msg, len, (const uint8_t *)RLC_DSTAG,
sizeof(RLC_DSTAG));
/* 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 @@ -520,7 +523,8 @@ void ep_map_swift(ep_t p, const uint8_t *msg, size_t len) {
}

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

ep_map_swift_impl(p, r, 2 * elm + 1);
}
Expand All @@ -535,17 +539,17 @@ void ep_map_swift(ep_t p, const uint8_t *msg, size_t len) {
#endif

void ep_map_rnd(ep_t p, const uint8_t *uniform_bytes, size_t len) {
#if EP_MAP == BASIC || !defined(STRIP)
#if EP_MAP == BASIC || !defined(STRIP)
ep_map_basic_impl(p, uniform_bytes, len);
#elif EP_MAP == SWIFT || !defined(STRIP)
#elif EP_MAP == SWIFT || !defined(STRIP)
/* figure out which hash function to use */
const int abNeq0 = (ep_curve_opt_a() != RLC_ZERO) &&
(ep_curve_opt_b() != RLC_ZERO);
void (*const map_fn)(ep_t, const fp_t) =
(ep_curve_is_ctmap() || abNeq0 ? ep_map_sswu : ep_map_svdw);

ep_map_sswum_impl(p, uniform_bytes, len, map_fn);
#elif EP_MAP == SSWUM || !defined(STRIP)
#elif EP_MAP == SSWUM || !defined(STRIP)
ep_map_swift_impl(p, uniform_bytes, len);
#endif
#endif
}

0 comments on commit eef556a

Please sign in to comment.