Skip to content

Commit

Permalink
- adds META.yml files
Browse files Browse the repository at this point in the history
- adds new api: crypto_sign_signature and crypto_sign_verify
- adds namespacing
- convert CRLF to LF
  • Loading branch information
bhess committed Feb 21, 2024
1 parent 442f21e commit af6ddc7
Show file tree
Hide file tree
Showing 33 changed files with 1,309 additions and 907 deletions.
2 changes: 1 addition & 1 deletion .cmake/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (${MAYO_BUILD_TYPE} MATCHES "ref")
option(ENABLE_AESNI "Use AESni" OFF)
option(ENABLE_PARAMS_DYNAMIC "Use dynamic parameters" ON)
add_definitions(-DMAYO_BUILD_TYPE_REF)
elseif(${MAYO_BUILD_TYPE} MATCHES "ref")
elseif(${MAYO_BUILD_TYPE} MATCHES "opt")
add_definitions(-DMAYO_BUILD_TYPE_OPT)
option(ENABLE_PARAMS_DYNAMIC "Use dynamic parameters" OFF)
elseif(${MAYO_BUILD_TYPE} MATCHES "avx2")
Expand Down
37 changes: 37 additions & 0 deletions META/MAYO_1_META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: MAYO_1
type: signature
claimed-nist-level: 1
length-public-key: 1168
length-secret-key: 24
length-signature: 321
nistkat-sha256: ba2473dedd92cf3b8a1fc14fc22f2ffdde972c8b64cfcd8cddb4f803e48df017
principal-submitters:
- Ward Beullens
- Fabio Campos
- Sofía Celi
- Basil Hess
- Matthias J. Kannwischer
implementations:
- name: opt
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_1 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL
signature_keypair: pqmayo_MAYO_1_opt_crypto_sign_keypair
signature_signature: pqmayo_MAYO_1_opt_crypto_sign_signature
signature_verify: pqmayo_MAYO_1_opt_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_1/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_1/api.h ./src/simple_arithmetic.h ./src/generic/arithmetic_common.h ./src/generic/echelon_form.h ./src/generic/arithmetic_96.h ./src/generic/arithmetic_64.h ./src/generic/arithmetic_128.h ./src/arithmetic.h ./src/common/aes_ctr.h
- name: avx2
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_1 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL
signature_keypair: pqmayo_MAYO_1_avx2_crypto_sign_keypair
signature_signature: pqmayo_MAYO_1_avx2_crypto_sign_signature
signature_verify: pqmayo_MAYO_1_avx2_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_1/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_1/api.h ./src/simple_arithmetic.h ./src/arithmetic.h ./src/common/aes_ctr.h ./src/AVX2/arithmetic_128.h ./src/AVX2/arithmetic_96.h ./src/AVX2/echelon_form.h ./src/AVX2/shuffle_arithmetic_128.h ./src/AVX2/shuffle_arithmetic_96.h ./src/AVX2/arithmetic_64.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic_64.h
supported_platforms:
- architecture: x86_64
operating_systems:
- Darwin
- Linux
required_flags:
- avx2
37 changes: 37 additions & 0 deletions META/MAYO_2_META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: MAYO_2
type: signature
claimed-nist-level: 1
length-public-key: 5488
length-secret-key: 24
length-signature: 180
nistkat-sha256: 72cb237642b2c0c4e7f8c824d9c8601ac7189784649d28dbb2cccfb94732c9a3
principal-submitters:
- Ward Beullens
- Fabio Campos
- Sofía Celi
- Basil Hess
- Matthias J. Kannwischer
implementations:
- name: opt
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_2 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL
signature_keypair: pqmayo_MAYO_2_opt_crypto_sign_keypair
signature_signature: pqmayo_MAYO_2_opt_crypto_sign_signature
signature_verify: pqmayo_MAYO_2_opt_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_2/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_2/api.h ./src/simple_arithmetic.h ./src/generic/arithmetic_common.h ./src/generic/echelon_form.h ./src/generic/arithmetic_96.h ./src/generic/arithmetic_64.h ./src/generic/arithmetic_128.h ./src/arithmetic.h ./src/common/aes_ctr.h
- name: avx2
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_2 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL
signature_keypair: pqmayo_MAYO_2_avx2_crypto_sign_keypair
signature_signature: pqmayo_MAYO_2_avx2_crypto_sign_signature
signature_verify: pqmayo_MAYO_2_avx2_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_2/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_2/api.h ./src/simple_arithmetic.h ./src/arithmetic.h ./src/common/aes_ctr.h ./src/AVX2/arithmetic_128.h ./src/AVX2/arithmetic_96.h ./src/AVX2/echelon_form.h ./src/AVX2/shuffle_arithmetic_128.h ./src/AVX2/shuffle_arithmetic_96.h ./src/AVX2/arithmetic_64.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic_64.h
supported_platforms:
- architecture: x86_64
operating_systems:
- Darwin
- Linux
required_flags:
- avx2
37 changes: 37 additions & 0 deletions META/MAYO_3_META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: MAYO_3
type: signature
claimed-nist-level: 3
length-public-key: 2656
length-secret-key: 32
length-signature: 577
nistkat-sha256: dbc49f4fdfa0de69d416051215cb53c042c4a329d325452d079f3734b7467a6b
principal-submitters:
- Ward Beullens
- Fabio Campos
- Sofía Celi
- Basil Hess
- Matthias J. Kannwischer
implementations:
- name: opt
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_3 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
signature_keypair: pqmayo_MAYO_3_opt_crypto_sign_keypair
signature_signature: pqmayo_MAYO_3_opt_crypto_sign_signature
signature_verify: pqmayo_MAYO_3_opt_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_3/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_3/api.h ./src/simple_arithmetic.h ./src/generic/arithmetic_common.h ./src/generic/echelon_form.h ./src/generic/arithmetic_96.h ./src/generic/arithmetic_64.h ./src/generic/arithmetic_128.h ./src/arithmetic.h ./src/common/aes_ctr.h
- name: avx2
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_3 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
signature_keypair: pqmayo_MAYO_3_avx2_crypto_sign_keypair
signature_signature: pqmayo_MAYO_3_avx2_crypto_sign_signature
signature_verify: pqmayo_MAYO_3_avx2_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_3/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_3/api.h ./src/simple_arithmetic.h ./src/arithmetic.h ./src/common/aes_ctr.h ./src/AVX2/arithmetic_128.h ./src/AVX2/arithmetic_96.h ./src/AVX2/echelon_form.h ./src/AVX2/shuffle_arithmetic_128.h ./src/AVX2/shuffle_arithmetic_96.h ./src/AVX2/arithmetic_64.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic_64.h
supported_platforms:
- architecture: x86_64
operating_systems:
- Darwin
- Linux
required_flags:
- avx2
37 changes: 37 additions & 0 deletions META/MAYO_5_META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: MAYO_5
type: signature
claimed-nist-level: 5
length-public-key: 5008
length-secret-key: 40
length-signature: 838
nistkat-sha256: f2c1c69045c7d15e714a04119965e8a7007ef54f9293158587560227c97b237d
principal-submitters:
- Ward Beullens
- Fabio Campos
- Sofía Celi
- Basil Hess
- Matthias J. Kannwischer
implementations:
- name: opt
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_5 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
signature_keypair: pqmayo_MAYO_5_opt_crypto_sign_keypair
signature_signature: pqmayo_MAYO_5_opt_crypto_sign_signature
signature_verify: pqmayo_MAYO_5_opt_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_5/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_5/api.h ./src/simple_arithmetic.h ./src/generic/arithmetic_common.h ./src/generic/echelon_form.h ./src/generic/arithmetic_96.h ./src/generic/arithmetic_64.h ./src/generic/arithmetic_128.h ./src/arithmetic.h ./src/common/aes_ctr.h
- name: avx2
version: https://github.com/PQCMayo/MAYO-C/tree/nibbling-mayo
folder_name: .
compile_opts: -DMAYO_VARIANT=MAYO_5 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
signature_keypair: pqmayo_MAYO_5_avx2_crypto_sign_keypair
signature_signature: pqmayo_MAYO_5_avx2_crypto_sign_signature
signature_verify: pqmayo_MAYO_5_avx2_crypto_sign_verify
sources: LICENSE NOTICE ./src/arithmetic.c ./src/mayo_5/api.c ./src/common/aes128ctr.c ./src/params.c ./src/mayo.c ./include/mayo.h ./include/mem.h ./src/mayo_5/api.h ./src/simple_arithmetic.h ./src/arithmetic.h ./src/common/aes_ctr.h ./src/AVX2/arithmetic_128.h ./src/AVX2/arithmetic_96.h ./src/AVX2/echelon_form.h ./src/AVX2/shuffle_arithmetic_128.h ./src/AVX2/shuffle_arithmetic_96.h ./src/AVX2/arithmetic_64.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic_64.h
supported_platforms:
- architecture: x86_64
operating_systems:
- Darwin
- Linux
required_flags:
- avx2
2 changes: 1 addition & 1 deletion apps/PQCgenKAT_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protection within the United States.
*/

#include "api.h"
#include "rng.h"
#include "randombytes.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
16 changes: 8 additions & 8 deletions apps/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
static int example_mayo(const mayo_params_t* p) {

unsigned long long msglen = 32;
unsigned long long smlen = p->sig_bytes + msglen;
unsigned long long smlen = PARAM_sig_bytes(p) + msglen;

unsigned char *pk = calloc(p->cpk_bytes, 1);
unsigned char *sk = calloc(p->csk_bytes, 1);
unsigned char *pk = calloc(PARAM_cpk_bytes(p), 1);
unsigned char *sk = calloc(PARAM_csk_bytes(p), 1);

unsigned char *epk = calloc(p->epk_bytes, 1);
unsigned char *epk = calloc(PARAM_epk_bytes(p), 1);
sk_t *esk = calloc(sizeof(sk_t), 1);

unsigned char *sig = calloc(p->sig_bytes + msglen, 1);
unsigned char *sig = calloc(PARAM_sig_bytes(p) + msglen, 1);

unsigned char msg[32] = { 0xe };
unsigned char msg2[32] = { 0 };

printf("Example with %s\n", p->name);
printf("Example with %s\n", PARAM_name(p));

printf("mayo_keypair -> ");
int res = mayo_keypair(p, pk, sk);
Expand Down Expand Up @@ -129,7 +129,7 @@ static int example_mayo(const mayo_params_t* p) {
err:
free(pk);
free(epk);
mayo_secure_free(sk, p->csk_bytes);
mayo_secure_free(sk, PARAM_csk_bytes(p));
mayo_secure_free(esk, sizeof(sk_t));
free(sig);
return res;
Expand All @@ -145,6 +145,6 @@ int main(void) {
}
}
#else
return example_mayo(&MAYO_VARIANT);
return example_mayo(0);
#endif
}
34 changes: 34 additions & 0 deletions apps/example_nistapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static int example_mayo(void) {

unsigned long long msglen = 32;
unsigned long long smlen = CRYPTO_BYTES + msglen;
unsigned long long siglen = CRYPTO_BYTES;

unsigned char *pk = calloc(CRYPTO_PUBLICKEYBYTES, 1);
unsigned char *sk = calloc(CRYPTO_SECRETKEYBYTES, 1);
Expand Down Expand Up @@ -76,6 +77,39 @@ static int example_mayo(void) {
res = 0;
printf("OK\n");
}

printf("crypto_sign_signature -> ");
res = crypto_sign_signature(sig, &siglen, msg, msglen, sk);
if (res) {
printf("FAIL\n");
res = -1;
goto err;
} else {
printf("OK\n");
}

printf("crypto_sign_verify (with correct signature) -> ");
res = crypto_sign_verify(sig, siglen, msg, msglen, pk);
if (res) {
printf("FAIL\n");
res = -1;
goto err;
} else {
res = 0;
printf("OK\n");
}

printf("crypto_sign_verify (with altered signature) -> ");
sig[0] = ~sig[0];
res = crypto_sign_verify(sig, siglen, msg, msglen, pk);
if (!res) {
printf("FAIL\n");
res = -1;
goto err;
} else {
res = 0;
printf("OK\n");
}

err:
free(pk);
Expand Down
Loading

0 comments on commit af6ddc7

Please sign in to comment.