Adapt UI to abstract from core functions

This commit is contained in:
Joost Rijneveld 2017-10-26 14:24:10 +02:00
父節點 3c802756aa
當前提交 dd1ae2a6aa
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: A4FE39CF49CBC553
共有 2 個檔案被更改,包括 17 行新增13 行删除

查看文件

@ -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(&params, 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(&params, 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");

查看文件

@ -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(&params, 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(&params, 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);