Adapt UI to abstract from core functions
This commit is contained in:
förälder
3c802756aa
incheckning
dd1ae2a6aa
13
ui/open.c
13
ui/open.c
@ -1,15 +1,15 @@
|
||||
#include "../params.h"
|
||||
#include "../xmss_core.h"
|
||||
#include "../xmss.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define MLEN 32
|
||||
|
||||
#ifdef XMSSMT
|
||||
#define XMSS_PARSE_OID xmssmt_parse_oid
|
||||
#define XMSS_CORE_SIGN_OPEN xmssmt_core_sign_open
|
||||
#define XMSS_SIGN_OPEN xmssmt_sign_open
|
||||
#else
|
||||
#define XMSS_PARSE_OID xmss_parse_oid
|
||||
#define XMSS_CORE_SIGN_OPEN xmss_core_sign_open
|
||||
#define XMSS_SIGN_OPEN xmss_sign_open
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@ -34,15 +34,16 @@ int main(int argc, char **argv) {
|
||||
fread(&oid, 1, XMSS_OID_LEN, keypair);
|
||||
XMSS_PARSE_OID(¶ms, oid);
|
||||
|
||||
unsigned char pk[params.pk_bytes];
|
||||
unsigned char pk[XMSS_OID_LEN + params.pk_bytes];
|
||||
unsigned char sm[params.sig_bytes + MLEN];
|
||||
unsigned char m[params.sig_bytes + MLEN];
|
||||
unsigned long long mlen;
|
||||
|
||||
fread(pk, 1, params.pk_bytes, keypair);
|
||||
fseek(keypair, 0, SEEK_SET);
|
||||
fread(pk, 1, XMSS_OID_LEN + params.pk_bytes, keypair);
|
||||
fread(sm, 1, params.sig_bytes + MLEN, stdin);
|
||||
|
||||
ret = XMSS_CORE_SIGN_OPEN(¶ms, m, &mlen, sm, params.sig_bytes + MLEN, pk);
|
||||
ret = XMSS_SIGN_OPEN(m, &mlen, sm, params.sig_bytes + MLEN, pk);
|
||||
|
||||
if (ret) {
|
||||
printf("Verification failed!\n");
|
||||
|
17
ui/sign.c
17
ui/sign.c
@ -1,15 +1,15 @@
|
||||
#include "../params.h"
|
||||
#include "../xmss_core.h"
|
||||
#include "../xmss.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define MLEN 32
|
||||
|
||||
#ifdef XMSSMT
|
||||
#define XMSS_PARSE_OID xmssmt_parse_oid
|
||||
#define XMSS_CORE_SIGN xmssmt_core_sign
|
||||
#define XMSS_SIGN xmssmt_sign
|
||||
#else
|
||||
#define XMSS_PARSE_OID xmss_parse_oid
|
||||
#define XMSS_CORE_SIGN xmss_core_sign
|
||||
#define XMSS_SIGN xmss_sign
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@ -42,17 +42,20 @@ int main(int argc, char **argv) {
|
||||
fread(&oid_sk, 1, XMSS_OID_LEN, keypair);
|
||||
XMSS_PARSE_OID(¶ms, oid_sk);
|
||||
|
||||
unsigned char sk[params.sk_bytes];
|
||||
unsigned char sk[XMSS_OID_LEN + params.sk_bytes];
|
||||
unsigned char m[MLEN];
|
||||
unsigned char sm[params.sig_bytes + MLEN];
|
||||
unsigned long long smlen;
|
||||
|
||||
fread(sk, 1, params.sk_bytes, keypair);
|
||||
/* fseek back to start of sk. */
|
||||
fseek(keypair, -((long int)XMSS_OID_LEN), SEEK_CUR);
|
||||
fread(sk, 1, XMSS_OID_LEN + params.sk_bytes, keypair);
|
||||
fread(m, 1, MLEN, stdin);
|
||||
XMSS_CORE_SIGN(¶ms, sk, sm, &smlen, m, MLEN);
|
||||
|
||||
XMSS_SIGN(sk, sm, &smlen, m, MLEN);
|
||||
|
||||
fseek(keypair, -((long int)params.sk_bytes), SEEK_CUR);
|
||||
fwrite(sk, 1, params.sk_bytes, keypair);
|
||||
fwrite(sk + XMSS_OID_LEN, 1, params.sk_bytes, keypair);
|
||||
fwrite(sm, 1, params.sig_bytes + MLEN, stdout);
|
||||
|
||||
fclose(keypair);
|
||||
|
Laddar…
Referens i nytt ärende
Block a user