@@ -29,7 +29,7 @@ def gen_file(name,doc,code,author="Mike Hamburg"): | |||||
ns_name = name % data | ns_name = name % data | ||||
_,_,name_base = ns_name.rpartition("/") | _,_,name_base = ns_name.rpartition("/") | ||||
header_guard = "__DECAF_" + name_base.replace(".","_").upper() + "__" | |||||
header_guard = "__" + ns_name.replace(".","_").replace("/","_").upper() + "__" | |||||
ns_doc = dedent(doc).strip().rstrip() | ns_doc = dedent(doc).strip().rstrip() | ||||
ns_doc = redoc(ns_name, ns_doc % data, author) | ns_doc = redoc(ns_name, ns_doc % data, author) | ||||
@@ -1,7 +1,8 @@ | |||||
from gen_file import gend_files | |||||
from gen_file import gen_file,gend_files | |||||
import os | import os | ||||
import argparse | import argparse | ||||
import re | |||||
parser = argparse.ArgumentParser(description='Generate Decaf headers and other such files.') | parser = argparse.ArgumentParser(description='Generate Decaf headers and other such files.') | ||||
parser.add_argument('--hpre', required = True, help = "Where to put the header files") | parser.add_argument('--hpre', required = True, help = "Where to put the header files") | ||||
@@ -14,6 +15,42 @@ from decaf_hxx import decaf_hxx | |||||
from decaf_h import decaf_h | from decaf_h import decaf_h | ||||
from crypto_h import crypto_h | from crypto_h import crypto_h | ||||
root_hxx_code = "\n".join(( | |||||
"#include <%s>" % name | |||||
for name in sorted(gend_files) | |||||
if re.match("^decaf/decaf_\d+.hxx$",name) | |||||
)) | |||||
decaf_root_hxx = gen_file( | |||||
name = "decaf.hxx", | |||||
doc = """@brief Decaf curve metaheader.""", | |||||
code = "\n"+root_hxx_code+"\n" | |||||
) | |||||
root_h_code = "\n".join(( | |||||
"#include <%s>" % name | |||||
for name in sorted(gend_files) | |||||
if re.match("^decaf/decaf_\d+.h$",name) | |||||
)) | |||||
decaf_root_hxx = gen_file( | |||||
name = "decaf.h", | |||||
doc = """ | |||||
@brief Master header for Decaf library. | |||||
The Decaf library implements cryptographic operations on a elliptic curve | |||||
groups of prime order p. It accomplishes this by using a twisted Edwards | |||||
curve (isogenous to Ed448-Goldilocks or Ed25519) and wiping out the cofactor. | |||||
The formulas are all complete and have no special cases. However, some | |||||
functions can fail. For example, decoding functions can fail because not | |||||
every string is the encoding of a valid group element. | |||||
The formulas contain no data-dependent branches, timing or memory accesses, | |||||
except for decaf_XXX_base_double_scalarmul_non_secret. | |||||
""", | |||||
code = "\n"+root_h_code+"\n" | |||||
) | |||||
for name,code in gend_files.iteritems(): | for name,code in gend_files.iteritems(): | ||||
_,_,name_suffix = name.partition(".") | _,_,name_suffix = name.partition(".") | ||||
prefix = prefixes[name_suffix] | prefix = prefixes[name_suffix] | ||||
@@ -1,32 +0,0 @@ | |||||
/** | |||||
* @file decaf.h | |||||
* @author Mike Hamburg | |||||
* | |||||
* @copyright | |||||
* Copyright (c) 2015 Cryptography Research, Inc. \n | |||||
* Released under the MIT License. See LICENSE.txt for license information. | |||||
* | |||||
* @brief Master header for Decaf library. | |||||
* | |||||
* The Decaf library implements cryptographic operations on a elliptic curve | |||||
* groups of prime order p. It accomplishes this by using a twisted Edwards | |||||
* curve (isogenous to Ed448-Goldilocks or Ed25519) and wiping out the cofactor. | |||||
* | |||||
* The formulas are all complete and have no special cases. However, some | |||||
* functions can fail. For example, decoding functions can fail because not | |||||
* every string is the encoding of a valid group element. | |||||
* | |||||
* The formulas contain no data-dependent branches, timing or memory accesses, | |||||
* except for decaf_XXX_base_double_scalarmul_non_secret. | |||||
*/ | |||||
#ifndef __DECAF_H__ | |||||
#define __DECAF_H__ 1 | |||||
#include <stdint.h> | |||||
#include <sys/types.h> | |||||
#include <decaf/decaf_255.h> | |||||
#include <decaf/decaf_448.h> | |||||
#endif /* __DECAF_H__ */ | |||||
@@ -1,16 +0,0 @@ | |||||
/** | |||||
* @file decaf/decaf.hxx | |||||
* @copyright | |||||
* Copyright (c) 2016 Cryptography Research, Inc. \n | |||||
* Released under the MIT License. See LICENSE.txt for license information. | |||||
* @author Mike Hamburg | |||||
* @brief Decaf curve metaheader. | |||||
* @todo TODO remove/autogenerate all these headers. | |||||
*/ | |||||
#ifndef __DECAF_HXX__ | |||||
#define __DECAF_HXX__ 1 | |||||
#include <decaf/decaf_255.hxx> | |||||
#include <decaf/decaf_448.hxx> | |||||
#endif /* __DECAF_H__ */ |