Sha256: f7aca8c9b2f06109e8891e7aa328065525b7bbc50e54aa139f34a82439e76bfc

Contents?: true

Size: 760 Bytes

Versions: 13

Compression:

Stored size: 760 Bytes

Contents

#include "fe.h"
#include "x25519_ref10.h"

int x25519_ref10_scalarmult(uint8_t *q, const uint8_t *n, const uint8_t *p)
{
  uint8_t e[32];
  unsigned int i;
  fe x1;
  fe x2;
  fe z2;
  fe x3;
  fe z3;
  fe tmp0;
  fe tmp1;
  int pos;
  unsigned int swap;
  unsigned int b;

  for (i = 0;i < 32;++i) e[i] = n[i];
  e[0] &= 248;
  e[31] &= 127;
  e[31] |= 64;

  fe_frombytes(x1,p);
  fe_1(x2);
  fe_0(z2);
  fe_copy(x3,x1);
  fe_1(z3);

  swap = 0;
  for (pos = 254;pos >= 0;--pos) {
    b = e[pos / 8] >> (pos & 7);
    b &= 1;
    swap ^= b;
    fe_cswap(x2,x3,swap);
    fe_cswap(z2,z3,swap);
    swap = b;
#include "montgomery.h"
  }
  fe_cswap(x2,x3,swap);
  fe_cswap(z2,z3,swap);

  fe_invert(z2,z2);
  fe_mul(x2,x2,z2);
  fe_tobytes(q,x2);
  return 0;
}

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
x25519-1.0.10 ext/x25519_ref10/scalarmult.c
x25519-1.0.9 ext/x25519_ref10/scalarmult.c
x25519-termux-1.1.0 ext/x25519_ref10/scalarmult.c
x25519-1.0.8 ext/x25519_ref10/scalarmult.c
x25519-1.0.7 ext/x25519_ref10/scalarmult.c
x25519-1.0.6 ext/x25519_ref10/scalarmult.c
x25519-1.0.5 ext/x25519_ref10/scalarmult.c
x25519-1.0.4 ext/x25519_ref10/scalarmult.c
x25519-1.0.3 ext/x25519_ref10/scalarmult.c
x25519-1.0.2 ext/x25519_ref10/scalarmult.c
x25519-1.0.1 ext/x25519_ref10/scalarmult.c
x25519-1.0.0 ext/x25519_ref10/scalarmult.c
x25519-0.2.0 ext/x25519_ref10/scalarmult.c