text: // SPDX-License-Identifier: MIT
  
  #include <stdlib.h>
  
  #include <oqs/sig_falcon.h>
  
  #include "randombytes.h"
  
  #if defined(OQS_ENABLE_SIG_falcon_1024)
  
  OQS_SIG *OQS_SIG_falcon_1024_new() {
  
  	OQS_SIG *sig = malloc(sizeof(OQS_SIG));
  	if (sig == NULL) {
  		return NULL;
  	}
  	sig->method_name = OQS_SIG_alg_falcon_1024;
  	sig->alg_version = "supercop-20201018 via https://github.com/jschanck/package-pqclean/tree/cea1fa5a/falcon";
  
  	sig->claimed_nist_level = 5;
  	sig->euf_cma = true;
  
  	sig->length_public_key = OQS_SIG_falcon_1024_length_public_key;
  	sig->length_secret_key = OQS_SIG_falcon_1024_length_secret_key;
  	sig->length_signature = OQS_SIG_falcon_1024_length_signature;
  
  	sig->keypair = OQS_SIG_falcon_1024_keypair;
  	sig->sign = OQS_SIG_falcon_1024_sign;
  	sig->verify = OQS_SIG_falcon_1024_verify;
  
  	return sig;
  }
  
  extern int PQCLEAN_FALCON1024_CLEAN_crypto_sign_keypair(uint8_t *pk, uint8_t *sk, uint8_t *seed, size_t seedlen);
  extern int PQCLEAN_FALCON1024_CLEAN_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk);
  extern int PQCLEAN_FALCON1024_CLEAN_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk);
  
  #if defined(OQS_ENABLE_SIG_falcon_1024_avx2)
  extern int PQCLEAN_FALCON1024_AVX2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk, uint8_t *seed, size_t seedlen);
  extern int PQCLEAN_FALCON1024_AVX2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk);
  extern int PQCLEAN_FALCON1024_AVX2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk);
  #endif
  
  OQS_API OQS_STATUS OQS_SIG_falcon_1024_keypair(uint8_t *public_key, uint8_t *secret_key)
  {
  	uint8_t seed[48];
  
  	randombytes(seed, sizeof seed);
  
  	return OQS_SIG_falcon_1024_keypair_seed(public_key, secret_key, seed, sizeof seed);
  }
  		
  OQS_API OQS_STATUS OQS_SIG_falcon_1024_keypair_seed(uint8_t *public_key, uint8_t *secret_key, uint8_t *seed, size_t seedlen) {
  #if defined(OQS_ENABLE_SIG_falcon_1024_avx2)
  #if defined(OQS_DIST_BUILD)
  	if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2)) {
  #endif /* OQS_DIST_BUILD */
  		return (OQS_STATUS) PQCLEAN_FALCON1024_AVX2_crypto_sign_keypair(public_key, secret_key, seed, seedlen);
  #if defined(OQS_DIST_BUILD)
  	} else {
  		return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_keypair(public_key, secret_key, seed, seedlen);
  	}
  #endif /* OQS_DIST_BUILD */
  #else
  	return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_keypair(public_key, secret_key, seed, seedlen);
  #endif
  }
  
  OQS_API OQS_STATUS OQS_SIG_falcon_1024_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) {
  #if defined(OQS_ENABLE_SIG_falcon_1024_avx2)
  #if defined(OQS_DIST_BUILD)
  	if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2)) {
  #endif /* OQS_DIST_BUILD */
  		return (OQS_STATUS) PQCLEAN_FALCON1024_AVX2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key);
  #if defined(OQS_DIST_BUILD)
  	} else {
  		return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_signature(signature, signature_len, message, message_len, secret_key);
  	}
  #endif /* OQS_DIST_BUILD */
  #else
  	return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_signature(signature, signature_len, message, message_len, secret_key);
  #endif
  }
  
  OQS_API OQS_STATUS OQS_SIG_falcon_1024_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) {
  #if defined(OQS_ENABLE_SIG_falcon_1024_avx2)
  #if defined(OQS_DIST_BUILD)
  	if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2)) {
  #endif /* OQS_DIST_BUILD */
  		return (OQS_STATUS) PQCLEAN_FALCON1024_AVX2_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
  #if defined(OQS_DIST_BUILD)
  	} else {
  		return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
  	}
  #endif /* OQS_DIST_BUILD */
  #else
  	return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key);
  #endif
  }
  
  #endif
  