summaryrefslogtreecommitdiff
path: root/controller/fw/src/rslib.c
blob: aa0db2c3fa7268454b0bc0af9fb0bd86d8df3f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdint.h>
#include <string.h>

#include "rscode-config.h"
#include <ecc.h>

#include "rslib.h"

static struct rscode_driver driver;

void rslib_encode(int nbits, size_t msglen, char msg[static msglen], char out[msglen + NPAR]) {
    rscode_init(&driver, nbits);
    rscode_encode(&driver, (unsigned char *)msg, msglen, (unsigned char *)out);
}

int rslib_decode(int nbits, size_t msglen, char msg_inout[static msglen]) {
    rscode_init(&driver, nbits);
    return rscode_decode(&driver, (unsigned char *)msg_inout, msglen);
}

int rslib_gexp(int z, int nbits) {
    rscode_init(&driver, nbits);
    return gexp(&driver, z);
}

size_t rslib_npar() {
    return NPAR;
}