Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
Structure refactoring 1
Browse files Browse the repository at this point in the history
  • Loading branch information
chardoncs committed May 27, 2023
1 parent 98ed9f2 commit 6e0629d
Show file tree
Hide file tree
Showing 99 changed files with 294 additions and 271 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ add_executable(pgfetestcpp ${test_dir}/test.cpp)
# add_executable(totptest ${test_dir}/totptest.c)
# add_executable(totptestcpp ${test_dir}/totptest.cpp)

target_include_directories(pgfe PRIVATE
target_include_directories(pgfe PUBLIC
${include_dir}
)

target_include_directories(pgfe PRIVATE
${src_dir}
)

target_link_libraries(pgfetest pgfe)
target_link_libraries(pgfetestcpp pgfe)
# target_link_libraries(totptest pgfe)
Expand Down
52 changes: 0 additions & 52 deletions include/backend/keccak-backend.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <mutex>
#include <string>

#include "../generic.h"
#include "../sequential_data.hpp"
#include "libpgfe/generic.h"
#include "libpgfe/sequential_data.hpp"

namespace libpgfe {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include <cstring>
#include <string>

#include "../generic.h"
#include "../sequential_data.hpp"
#include "../utils.hpp"
#include "libpgfe/generic.h"
#include "libpgfe/sequential_data.hpp"
#include "libpgfe/utils.hpp"

namespace libpgfe {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

#include <string>

#include "abstract_encoder.hpp"
#include "libpgfe/abstract_encoder.hpp"

#include "../algorithm-choice.h"
#include "../algorithm_selectable.hpp"
#include "../generic.h"
#include "../generic.hpp"
#include "libpgfe/algorithm-choice.h"
#include "libpgfe/algorithm_selectable.hpp"
#include "libpgfe/generic.h"
#include "libpgfe/generic.hpp"

namespace libpgfe {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

#include <string>

#include "../algorithm_selectable.hpp"
#include "../backend/otp-generic.h"
#include "../generic.h"
#include "../sequential_data.hpp"
#include "libpgfe/algorithm_selectable.hpp"
#include "libpgfe/generic.h"
#include "libpgfe/otp_types.h"
#include "libpgfe/sequential_data.hpp"

namespace libpgfe {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <string>

#include "../sequential_data.hpp"
#include "libpgfe/sequential_data.hpp"

namespace libpgfe {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <cstring>
#include <string>

#include "algorithm-choice.h"
#include "libpgfe/algorithm-choice.h"

namespace libpgfe {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef LIBPGFE_BASE_ENCODING_H
#define LIBPGFE_BASE_ENCODING_H

#include "generic.h"
#include "libpgfe/generic.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion include/base16.hpp → include/libpgfe/base16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#error libpgfe error: C++ headers are not compatible with C source
#endif

#include "backend_cpp/abstract_base_encoding.hpp"
#include "libpgfe/abstract_base_encoding.hpp"

namespace libpgfe {

Expand Down
2 changes: 1 addition & 1 deletion include/base32.hpp → include/libpgfe/base32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#error libpgfe error: C++ headers are not compatible with C source
#endif

#include "backend_cpp/abstract_base_encoding.hpp"
#include "libpgfe/abstract_base_encoding.hpp"

namespace libpgfe {

Expand Down
2 changes: 1 addition & 1 deletion include/base64.hpp → include/libpgfe/base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#error libpgfe error: C++ headers are not compatible with C source
#endif

#include "backend_cpp/abstract_base_encoding.hpp"
#include "libpgfe/abstract_base_encoding.hpp"

namespace libpgfe {

Expand Down
2 changes: 1 addition & 1 deletion include/blowfish.h → include/libpgfe/blowfish.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
extern "C" {
#endif

#include "backend/generic-internal.h"
#include "libpgfe/generic.h"

#define __PGFE_BF_N 16
#define __PGFE_BF_Np2 18
Expand Down
4 changes: 2 additions & 2 deletions include/blowfish.hpp → include/libpgfe/blowfish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

#include <string>

#include "backend_cpp/abstract_symmetric_crypter.hpp"
#include "blowfish.h"
#include "libpgfe/abstract_symmetric_crypter.hpp"
#include "libpgfe/blowfish.h"

namespace libpgfe {

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion include/generic.h → include/libpgfe/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stddef.h>
#include <stdint.h>

#include "algorithm-choice.h"
#include "libpgfe/algorithm-choice.h"

#ifdef __cplusplus
extern "C" {
Expand Down
12 changes: 6 additions & 6 deletions include/generic.hpp → include/libpgfe/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#include <string>
#include <unordered_map>

#include "algorithm-choice.h"
#include "exceptions.hpp"
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
#include "sha3.h"
#include "libpgfe/algorithm-choice.h"
#include "libpgfe/exceptions.hpp"
#include "libpgfe/md5.h"
#include "libpgfe/sha1.h"
#include "libpgfe/sha2.h"
#include "libpgfe/sha3.h"

#define __PGFE_BATCH_SHAKE_CASES(name) \
switch (cur_alg) { \
Expand Down
4 changes: 4 additions & 0 deletions include/libpgfe/hash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "libpgfe/md5.h"
#include "libpgfe/sha1.h"
#include "libpgfe/sha2.h"
#include "libpgfe/sha3.h"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#error libpgfe error: C++ headers are not compatible with C source
#endif

#include "backend_cpp/abstract_hash_encoder.hpp"
#include "libpgfe/abstract_hash_encoder.hpp"

#include <memory>

Expand Down
11 changes: 5 additions & 6 deletions include/hmac.h → include/libpgfe/hmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
#ifndef LIBPGFE_HMAC_H
#define LIBPGFE_HMAC_H

#include "backend/generic-internal.h"
#include "generic.h"
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
#include "sha3.h"
#include "libpgfe/generic.h"
#include "libpgfe/md5.h"
#include "libpgfe/sha1.h"
#include "libpgfe/sha2.h"
#include "libpgfe/sha3.h"

#ifdef __cplusplus
extern "C" {
Expand Down
8 changes: 4 additions & 4 deletions include/hmac_encoder.hpp → include/libpgfe/hmac_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include <memory>
#include <vector>

#include "backend_cpp/abstract_hash_encoder.hpp"
#include "generic.h"
#include "generic.hpp"
#include "hmac.h"
#include "libpgfe/abstract_hash_encoder.hpp"
#include "libpgfe/generic.h"
#include "libpgfe/generic.hpp"
#include "libpgfe/hmac.h"

namespace libpgfe {

Expand Down
4 changes: 2 additions & 2 deletions include/hotp.h → include/libpgfe/hotp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#ifndef LIBPGFE_HOTP_H
#define LIBPGFE_HOTP_H

#include "backend/generic-internal.h"
#include "backend/otp-generic.h"
#include "libpgfe/generic.h"
#include "libpgfe/otp_types.h"

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions include/hotp.hpp → include/libpgfe/hotp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

#include <memory>

#include "backend_cpp/abstract_otp.hpp"
#include "base32.hpp"
#include "libpgfe/abstract_otp.hpp"
#include "libpgfe/base32.hpp"

namespace libpgfe {

Expand Down
3 changes: 1 addition & 2 deletions include/md5.h → include/libpgfe/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

#include <stdio.h>

#include "backend/generic-internal.h"
#include "generic.h"
#include "libpgfe/generic.h"

#ifdef __cplusplus
extern "C" {
Expand Down
17 changes: 17 additions & 0 deletions include/libpgfe/otp_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef LIBPGFE_OTP_TYPES_H
#define LIBPGFE_OTP_TYPES_H

#ifdef __cplusplus
extern "C" {
#endif

typedef uint32_t pgfe_otp_t;

typedef uint64_t pgfe_otp_counter_t;

typedef pgfe_encode_t pgfe_otp_secret_t;

#ifdef __cplusplus
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <ostream>
#include <string>

#include "generic.h"
#include "utils.h"
#include "libpgfe/generic.h"
#include "libpgfe/utils.h"

namespace libpgfe {

Expand Down
2 changes: 1 addition & 1 deletion include/sha1.h → include/libpgfe/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdio.h>

#include "backend/generic-internal.h"
#include "libpgfe/generic.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion include/sha2.h → include/libpgfe/sha2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdio.h>

#include "backend/generic-internal.h"
#include "libpgfe/generic.h"

#ifdef __cplusplus
extern "C" {
Expand Down
23 changes: 21 additions & 2 deletions include/sha3.h → include/libpgfe/sha3.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,32 @@

#include <stdio.h>

#include "backend/keccak-backend.h"
#include "generic.h"
#include "libpgfe/generic.h"

#ifdef __cplusplus
extern "C" {
#endif

#define __PGFE_KECCAK_MAX_RATE 1536

typedef uint64_t pgfe_keccak_lane_t;

typedef pgfe_keccak_lane_t pgfe_keccak_bitcube_t[5][5];

// Generic Keccak Sponge Context
struct pgfe_keccak_sponge_ctx
{
pgfe_keccak_bitcube_t state; // Keccak sponge state array
pgfe_encode_t data_queue[to_byte(__PGFE_KECCAK_MAX_RATE)]; // Data queue
uint32_t rate, capacity, inqueue_bits, out_length; // Rate, capacity, bits in queue, output bit length
uint16_t nr; // Number of rounds (Usually 24)
int squeezing; // Is squeezing
unsigned int squeezable; // Size of squeezable bits
pgfe_encode_t ap; // Reserved appendix for adapting SHA-3
uint8_t ap_len; // Bit length of appendix
int ap_added; // Is appendix added
};

#define PGFE_SHA3_224_DIGEST_SIZE 28
#define PGFE_SHA3_256_DIGEST_SIZE 32
#define PGFE_SHA3_384_DIGEST_SIZE 48
Expand Down
Loading

0 comments on commit 6e0629d

Please sign in to comment.