Bladeren bron

auto-generate metaheaders

master
Michael Hamburg 8 jaren geleden
bovenliggende
commit
a9dcd153df
4 gewijzigde bestanden met toevoegingen van 39 en 50 verwijderingen
  1. +1
    -1
      src/gen_headers/gen_file.py
  2. +38
    -1
      src/gen_headers/main.py
  3. +0
    -32
      src/public_include/decaf.h
  4. +0
    -16
      src/public_include/decaf.hxx

+ 1
- 1
src/gen_headers/gen_file.py Bestand weergeven

@@ -29,7 +29,7 @@ def gen_file(name,doc,code,author="Mike Hamburg"):
ns_name = name % data
_,_,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 = redoc(ns_name, ns_doc % data, author)


+ 38
- 1
src/gen_headers/main.py Bestand weergeven

@@ -1,7 +1,8 @@
from gen_file import gend_files
from gen_file import gen_file,gend_files

import os
import argparse
import re

parser = argparse.ArgumentParser(description='Generate Decaf headers and other such 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 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():
_,_,name_suffix = name.partition(".")
prefix = prefixes[name_suffix]


+ 0
- 32
src/public_include/decaf.h Bestand weergeven

@@ -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__ */


+ 0
- 16
src/public_include/decaf.hxx Bestand weergeven

@@ -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__ */

Laden…
Annuleren
Opslaan