Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename #24

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 91 additions & 91 deletions api.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class key {
/// This is the log2 of the number of hashes we can compute in parallel
virtual unsigned num_log_track(void) = 0;

// Pointers into the addr structure that we use; SHA-256
// Pointers into the addr structure that we use; SHA-2
// uses a different (shorter) addr structure
unsigned offset_layer, offset_tree, offset_type;
unsigned offset_kp_addr1, offset_kp_addr2;
Expand Down Expand Up @@ -533,8 +533,8 @@ class key {
};

///
/// This abstract class is for SHA256-based parameter sets
class sha256_hash : public key {
/// This abstract class is for SHA2-based parameter sets
class sha2_hash : public key {
protected:
/// This precomputes the intermediate state of the public seed (so
/// we don't have to recompute it everytime we need it).
Expand All @@ -553,7 +553,7 @@ class sha256_hash : public key {
const unsigned char *msg, size_t len_msg );

// These are implementations of the prf_msg/h_msg functions
// that use SHA512 internally. It is used by the SHA256-L3, L5
// that use SHA512 internally. It is used by the SHA2-L3, L5
// parameter sets, in this class so that child L5 classes
// can redirect the virtual functions to these
void prf_msg_512( unsigned char *result,
Expand All @@ -569,16 +569,16 @@ class sha256_hash : public key {
virtual unsigned num_track(void);
virtual unsigned num_log_track(void);

sha256_hash(void);
sha2_hash(void);
public:
virtual void set_public_key(const unsigned char *public_key);
virtual void set_private_key(const unsigned char *private_key);
};

/// This abstract class is for SHAKE256-based parameter sets
class shake256_hash : public key {
/// This abstract class is for SHAKE2-based parameter sets
class shake_hash : public key {
protected:
SHAKE256_PRECOMPUTE pre_pub_seed; //!< The prehashed public seed
SHAKE256_PRECOMPUTE pre_pub_seed; //!< The SHA256 prehashed public seed

virtual unsigned num_track(void);
virtual unsigned num_log_track(void);
Expand Down Expand Up @@ -619,8 +619,8 @@ class haraka_hash : public key {
virtual void set_private_key(const unsigned char *private_key);
};

/// This abstract class is for SHA256-simple-based parameter sets
class key_sha256_simple : public sha256_hash {
/// This abstract class is for SHA2-simple-based parameter sets
class key_sha2_simple : public sha2_hash {
protected:
virtual void thash(unsigned char *out,
const unsigned char *in,
Expand All @@ -631,8 +631,8 @@ class key_sha256_simple : public sha256_hash {
};


/// This abstract class is for SHA256-robust-based parameter sets
class key_sha256_robust : public sha256_hash {
/// This abstract class is for SHA2-robust-based parameter sets
class key_sha2_robust : public sha2_hash {
protected:
virtual void thash(unsigned char *out,
const unsigned char *in,
Expand All @@ -641,8 +641,8 @@ class key_sha256_robust : public sha256_hash {
unsigned char **in,
unsigned int inblocks, addr_t* addrxn);
};
// And the L3, L5 versions of the SHA256 parameter sets
class key_sha256_L35_simple : public key_sha256_simple {
// And the L3, L5 versions of the SHA2 parameter sets
class key_sha2_L35_simple : public key_sha2_simple {
/// The prehashed public seed for SHA-512
uint64_t state_seeded_512[8];

Expand All @@ -667,7 +667,7 @@ class key_sha256_L35_simple : public key_sha256_simple {
const unsigned char *r,
const unsigned char *msg, size_t len_msg );
};
class key_sha256_L35_robust : public key_sha256_robust {
class key_sha2_L35_robust : public key_sha2_robust {
/// The prehashed public seed for SHA-512
uint64_t state_seeded_512[8];

Expand All @@ -693,8 +693,8 @@ class key_sha256_L35_robust : public key_sha256_robust {
const unsigned char *msg, size_t len_msg );
};

/// This abstract class is for SHAKE256-simple-based parameter sets
class key_shake256_simple : public shake256_hash {
/// This abstract class is for SHAKE-simple-based parameter sets
class key_shake_simple : public shake_hash {
protected:
virtual void thash(unsigned char *out,
const unsigned char *in,
Expand All @@ -704,8 +704,8 @@ class key_shake256_simple : public shake256_hash {
unsigned int inblocks, addr_t* addrxn);
};

/// This abstract class is for SHAKE256-robust-based parameter sets
class key_shake256_robust : public shake256_hash {
/// This abstract class is for SHAKE-robust-based parameter sets
class key_shake_robust : public shake_hash {
protected:
virtual void thash(unsigned char *out,
const unsigned char *in,
Expand Down Expand Up @@ -744,148 +744,148 @@ class key_haraka_robust : public haraka_hash {
//
// And now the individual parameter set classes

/// The class for keys with the SHA256 simple 128F parameter set
class key_sha256_128f_simple : public key_sha256_simple {
/// The class for keys with the SHA2 simple 128F parameter set
class key_sha2_128f_simple : public key_sha2_simple {
public:
key_sha256_128f_simple(void) { set_128f(); }
key_sha2_128f_simple(void) { set_128f(); }
};

/// The class for keys with the SHA256 robust 128F parameter set
class key_sha256_128f_robust : public key_sha256_robust {
/// The class for keys with the SHA2 robust 128F parameter set
class key_sha2_128f_robust : public key_sha2_robust {
public:
key_sha256_128f_robust(void) { set_128f(); }
key_sha2_128f_robust(void) { set_128f(); }
};

/// The class for keys with the SHA256 simple 128S parameter set
class key_sha256_128s_simple : public key_sha256_simple {
/// The class for keys with the SHA2 simple 128S parameter set
class key_sha2_128s_simple : public key_sha2_simple {
public:
key_sha256_128s_simple(void) { set_128s(); }
key_sha2_128s_simple(void) { set_128s(); }
};

/// The class for keys with the SHA256 robust 128S parameter set
class key_sha256_128s_robust : public key_sha256_robust {
/// The class for keys with the SHA2 robust 128S parameter set
class key_sha2_128s_robust : public key_sha2_robust {
public:
key_sha256_128s_robust(void) { set_128s(); }
key_sha2_128s_robust(void) { set_128s(); }
};

/// The class for keys with the SHA256 simple 192F parameter set
class key_sha256_192f_simple : public key_sha256_L35_simple {
/// The class for keys with the SHA2 simple 192F parameter set
class key_sha2_192f_simple : public key_sha2_L35_simple {
public:
key_sha256_192f_simple(void) { set_192f(); }
key_sha2_192f_simple(void) { set_192f(); }
};

/// The class for keys with the SHA256 robust 192F parameter set
class key_sha256_192f_robust : public key_sha256_L35_robust {
/// The class for keys with the SHA2 robust 192F parameter set
class key_sha2_192f_robust : public key_sha2_L35_robust {
public:
key_sha256_192f_robust(void) { set_192f(); }
key_sha2_192f_robust(void) { set_192f(); }
};

/// The class for keys with the SHA256 simple 192S parameter set
class key_sha256_192s_simple : public key_sha256_L35_simple {
/// The class for keys with the SHA2 simple 192S parameter set
class key_sha2_192s_simple : public key_sha2_L35_simple {
public:
key_sha256_192s_simple(void) { set_192s(); }
key_sha2_192s_simple(void) { set_192s(); }
};

/// The class for keys with the SHA256 robust 192S parameter set
class key_sha256_192s_robust : public key_sha256_L35_robust {
/// The class for keys with the SHA2 robust 192S parameter set
class key_sha2_192s_robust : public key_sha2_L35_robust {
public:
key_sha256_192s_robust(void) { set_192s(); }
key_sha2_192s_robust(void) { set_192s(); }
};

/// The class for keys with the SHA256 simple 256F parameter set
class key_sha256_256f_simple : public key_sha256_L35_simple {
/// The class for keys with the SHA2 simple 256F parameter set
class key_sha2_256f_simple : public key_sha2_L35_simple {
public:
key_sha256_256f_simple(void) { set_256f(); }
key_sha2_256f_simple(void) { set_256f(); }
};

/// The class for keys with the SHA256 robust 256F parameter set
class key_sha256_256f_robust : public key_sha256_L35_robust {
/// The class for keys with the SHA2 robust 256F parameter set
class key_sha2_256f_robust : public key_sha2_L35_robust {
public:
key_sha256_256f_robust(void) { set_256f(); }
key_sha2_256f_robust(void) { set_256f(); }
};

/// The class for keys with the SHA256 simple 256S parameter set
class key_sha256_256s_simple : public key_sha256_L35_simple {
/// The class for keys with the SHA2 simple 256S parameter set
class key_sha2_256s_simple : public key_sha2_L35_simple {
public:
key_sha256_256s_simple(void) { set_256s(); }
key_sha2_256s_simple(void) { set_256s(); }
};

/// The class for keys with the SHA256 robust 256S parameter set
class key_sha256_256s_robust : public key_sha256_L35_robust {
/// The class for keys with the SHA2 robust 256S parameter set
class key_sha2_256s_robust : public key_sha2_L35_robust {
public:
key_sha256_256s_robust(void) { set_256s(); }
key_sha2_256s_robust(void) { set_256s(); }
};

/// The class for keys with the SHAKE256 simple 128F parameter set
class key_shake256_128f_simple : public key_shake256_simple {
/// The class for keys with the SHAKE simple 128F parameter set
class key_shake_128f_simple : public key_shake_simple {
public:
key_shake256_128f_simple(void) { set_128f(); }
key_shake_128f_simple(void) { set_128f(); }
};

/// The class for keys with the SHAKE256 robust 128F parameter set
class key_shake256_128f_robust : public key_shake256_robust {
/// The class for keys with the SHAKE robust 128F parameter set
class key_shake_128f_robust : public key_shake_robust {
public:
key_shake256_128f_robust(void) { set_128f(); }
key_shake_128f_robust(void) { set_128f(); }
};

/// The class for keys with the SHAKE256 simple 128S parameter set
class key_shake256_128s_simple : public key_shake256_simple {
/// The class for keys with the SHAKE simple 128S parameter set
class key_shake_128s_simple : public key_shake_simple {
public:
key_shake256_128s_simple(void) { set_128s(); }
key_shake_128s_simple(void) { set_128s(); }
};

/// The class for keys with the SHAKE256 robust 128S parameter set
class key_shake256_128s_robust : public key_shake256_robust {
/// The class for keys with the SHAKE robust 128S parameter set
class key_shake_128s_robust : public key_shake_robust {
public:
key_shake256_128s_robust(void) { set_128s(); }
key_shake_128s_robust(void) { set_128s(); }
};

/// The class for keys with the SHAKE256 simple 192F parameter set
class key_shake256_192f_simple : public key_shake256_simple {
/// The class for keys with the SHAKE simple 192F parameter set
class key_shake_192f_simple : public key_shake_simple {
public:
key_shake256_192f_simple(void) { set_192f(); }
key_shake_192f_simple(void) { set_192f(); }
};

/// The class for keys with the SHAKE256 robust 192F parameter set
class key_shake256_192f_robust : public key_shake256_robust {
/// The class for keys with the SHAKE robust 192F parameter set
class key_shake_192f_robust : public key_shake_robust {
public:
key_shake256_192f_robust(void) { set_192f(); }
key_shake_192f_robust(void) { set_192f(); }
};

/// The class for keys with the SHAKE256 simple 192S parameter set
class key_shake256_192s_simple : public key_shake256_simple {
/// The class for keys with the SHAKE simple 192S parameter set
class key_shake_192s_simple : public key_shake_simple {
public:
key_shake256_192s_simple(void) { set_192s(); }
key_shake_192s_simple(void) { set_192s(); }
};

/// The class for keys with the SHAKE256 robust 192S parameter set
class key_shake256_192s_robust : public key_shake256_robust {
/// The class for keys with the SHAKE robust 192S parameter set
class key_shake_192s_robust : public key_shake_robust {
public:
key_shake256_192s_robust(void) { set_192s(); }
key_shake_192s_robust(void) { set_192s(); }
};

/// The class for keys with the SHAKE256 simple 256F parameter set
class key_shake256_256f_simple : public key_shake256_simple {
/// The class for keys with the SHAKE simple 256F parameter set
class key_shake_256f_simple : public key_shake_simple {
public:
key_shake256_256f_simple(void) { set_256f(); }
key_shake_256f_simple(void) { set_256f(); }
};

/// The class for keys with the SHAKE256 robust 256F parameter set
class key_shake256_256f_robust : public key_shake256_robust {
/// The class for keys with the SHAKE robust 256F parameter set
class key_shake_256f_robust : public key_shake_robust {
public:
key_shake256_256f_robust(void) { set_256f(); }
key_shake_256f_robust(void) { set_256f(); }
};

/// The class for keys with the SHAKE256 simple 256S parameter set
class key_shake256_256s_simple : public key_shake256_simple {
/// The class for keys with the SHAKE simple 256S parameter set
class key_shake_256s_simple : public key_shake_simple {
public:
key_shake256_256s_simple(void) { set_256s(); }
key_shake_256s_simple(void) { set_256s(); }
};

/// The class for keys with the SHAKE256 robust 256S parameter set
class key_shake256_256s_robust : public key_shake256_robust {
/// The class for keys with the SHAKE robust 256S parameter set
class key_shake_256s_robust : public key_shake_robust {
public:
key_shake256_256s_robust(void) { set_256s(); }
key_shake_256s_robust(void) { set_256s(); }
};

/// The class for keys with the HARAKA simple 128F parameter set
Expand Down
8 changes: 4 additions & 4 deletions internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ const int max_wots_digits = 67; //<! Maximum number of digits
const int max_wots_bytes = max_len_hash * max_wots_digits; //<! The maximum
//<! size of a WOTS+ value
const int addr_bytes = 32; //<! Standard addr structures are 32 bytes lon
const int sha256_addr_bytes = 22; //<! SHA256 uses a shortened addr structure
//<! that's 22 bytes long
const int sha2_addr_bytes = 22; //<! SHA2 uses a shortened addr structure
//<! that's 22 bytes long
const int sha256_output_size = 32; //<! The size of an untruncated SHA256 output
const int sha256_block_size = 64; //<! SHA256 processes things in 64 byte chunks
const unsigned sha512_output_size = 64; //<! SHA-512 generates 64 bytes
//<! (or 512 bits) of output
const int max_mgf1_input = max_len_hash + sha256_addr_bytes; //<! The
const int max_mgf1_input = max_len_hash + sha2_addr_bytes; //<! The
//<! maximum seed size for an MGF1 input; this
//<! maximum occurs during a message hash for L5
//<! SHA256-robust parameter sets.
//<! SHA2-robust parameter sets.
const unsigned max_track = 8; //<! The maximum number of hashes we can do in
//<! parallel (on a single thread) is 8

Expand Down
4 changes: 2 additions & 2 deletions nist/nist_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ extern "C" {
// The NIST API assumes that the parameter set is compiled in
// This is what chooses it
#if !defined( SPX_PARAMETER_SET )
#define SPX_PARAMETER_SET sha256_128f_robust
#define SPX_PARAMETER_SET sha2_128f_robust
#endif

#define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
typedef sphincs_plus :: CONCAT( key_, SPX_PARAMETER_SET ) KEY_TYPE;
// sphincs_plus::key_sha256_128f_robust in the default case
// sphincs_plus::key_sha2_128f_robust in the default case

extern "C" { /* These functions use the C ABI */

Expand Down
Loading