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

Commit e9ffbff

Browse files
committed
Merge branch 'next'
2 parents 70308ca + 83aa719 commit e9ffbff

86 files changed

Lines changed: 405 additions & 308 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/qna.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ Since v0.2.0, *libpgfe* has been "self-sufficient" and does not depend on any th
99
## Q2: Interested in supporting Big Endian?
1010

1111
I will think about it eventually, but not now! Because byte order compatibility will dramatically increase complexity of the code,
12-
and I currently don't have enough time or effort to tackle it. Also, I do not have Big Endian machines or virtual machines, so the additional code would be left untested, which is what I don't want to happen.
12+
and I currently don't have enough time or effort to tackle it. Also, I do not have Big Endian machines or virtual machines, so the additional code would be left untested, which is not what I expect.
1313

14-
## Q3: Why not MSVC?
14+
## Q3: Why not [Assembly Language](https://en.wikipedia.org/wiki/Assembly_language)?
15+
16+
1. I'm not familiar with Assembly.
17+
18+
2. Assembly is machine-dependent.
19+
20+
3. C is fast enough for *libpgfe*. It's no need to use Assembly to do those optimizations.
21+
22+
## Q4: Why not MSVC?
1523

1624
> ***PS:** MSVC = Microsoft Visual C++*
1725
18-
Firstly, this library prioritizes POSIX compatibility, instead of Windows compatibility.
26+
1. This library prioritizes POSIX compatibility, instead of Windows compatibility.
1927

20-
Secondly, *libpgfe* need some necessary features that are not included in *MSVC*. For instance, like the C code below:
28+
2. *libpgfe* needs some necessary features that are not included in *MSVC*. For instance, like the C code below. *MSVC* will refuse to compile that code, because a variable is used as the array's size, while *Clang* and *GCC* are OK with it.
2129

2230
```c
2331
int main() {
@@ -27,5 +35,3 @@ int main() {
2735
return 0;
2836
}
2937
```
30-
31-
*MSVC* will refuse to compile that code, because of a variable is used as the array's size, while *Clang* and *GCC* are OK with it.

CMakeLists.txt

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16.0)
33
set(CMAKE_C_COMPILER clang)
44
set(CMAKE_CXX_COMPILER clang++)
55

6-
project(libpgfe VERSION 0.4.0 LANGUAGES C CXX)
6+
project(libpgfe VERSION 0.5.0 LANGUAGES C CXX)
77

88
set(CMAKE_C_STANDARD 11)
99
set(CMAKE_CXX_STANDARD 14)
@@ -12,51 +12,53 @@ include(CTest)
1212
enable_testing()
1313

1414
set(src_dir "src")
15+
set(src_c_dir "${src_dir}/c")
16+
set(src_cpp_dir "${src_dir}/cpp")
1517
set(include_dir "include")
1618
set(test_dir "test")
1719

1820
add_library(pgfe SHARED
19-
${src_dir}/generic.c
20-
${src_dir}/generic-internal.c
21-
${src_dir}/templates.c
22-
${src_dir}/utils.c
23-
${src_dir}/sha-internal.c
24-
${src_dir}/sha2-backend.c
25-
${src_dir}/keccak-backend.c
26-
${src_dir}/md5-backend.c
27-
${src_dir}/sha1.c ${src_dir}/sha224.c ${src_dir}/sha256.c ${src_dir}/sha384.c ${src_dir}/sha512.c
28-
${src_dir}/sha3-224.c ${src_dir}/sha3-256.c ${src_dir}/sha3-384.c ${src_dir}/sha3-512.c
29-
${src_dir}/md5.c
30-
${src_dir}/shake.c
31-
${src_dir}/hmac.c
32-
${src_dir}/otp-generic.c
33-
${src_dir}/hotp.c ${src_dir}/totp.c
34-
${src_dir}/base-encoding-internal.c
35-
${src_dir}/base64.c ${src_dir}/base32.c ${src_dir}/base16.c
36-
${src_dir}/sequential_data.cpp
37-
${src_dir}/utils.cpp
38-
${src_dir}/algorithm_selectable.cpp
39-
${src_dir}/hash_encoder.cpp
40-
${src_dir}/hmac_encoder.cpp
41-
${src_dir}/abstract_base_encoding.cpp
42-
${src_dir}/base16.cpp
43-
${src_dir}/base32.cpp
44-
${src_dir}/base64.cpp
45-
${src_dir}/abstract_otp.cpp
46-
${src_dir}/hotp.cpp ${src_dir}/totp.cpp)
21+
${src_c_dir}/generic.c
22+
${src_c_dir}/generic-internal.c
23+
${src_c_dir}/utils.c
24+
${src_c_dir}/hash/sha-internal.c
25+
${src_c_dir}/hash/sha2-backend.c
26+
${src_c_dir}/hash/keccak-backend.c
27+
${src_c_dir}/hash/md5-backend.c
28+
${src_c_dir}/hash/sha1.c ${src_c_dir}/hash/sha224.c ${src_c_dir}/hash/sha256.c ${src_c_dir}/hash/sha384.c ${src_c_dir}/hash/sha512.c
29+
${src_c_dir}/hash/sha3-224.c ${src_c_dir}/hash/sha3-256.c ${src_c_dir}/hash/sha3-384.c ${src_c_dir}/hash/sha3-512.c
30+
${src_c_dir}/hash/md5.c
31+
${src_c_dir}/hash/shake.c
32+
${src_c_dir}/hmac/hmac.c
33+
${src_c_dir}/otp/otp-generic.c
34+
${src_c_dir}/otp/hotp.c ${src_c_dir}/otp/totp.c
35+
${src_c_dir}/base_encoding/base-encoding-internal.c
36+
${src_c_dir}/base_encoding/base64.c ${src_c_dir}/base_encoding/base32.c ${src_c_dir}/base_encoding/base16.c
37+
${src_cpp_dir}/generic.cpp
38+
${src_cpp_dir}/sequential_data.cpp
39+
${src_cpp_dir}/utils.cpp
40+
${src_cpp_dir}/algorithm_selectable.cpp
41+
${src_cpp_dir}/hash/hash_encoder.cpp
42+
${src_cpp_dir}/hmac/hmac_encoder.cpp
43+
${src_cpp_dir}/base_encoding/abstract_base_encoding.cpp
44+
${src_cpp_dir}/base_encoding/base16.cpp
45+
${src_cpp_dir}/base_encoding/base32.cpp
46+
${src_cpp_dir}/base_encoding/base64.cpp
47+
${src_cpp_dir}/otp/abstract_otp.cpp
48+
${src_cpp_dir}/otp/hotp.cpp ${src_cpp_dir}/otp/totp.cpp)
4749
add_executable(pgfetest ${test_dir}/test.c)
50+
add_executable(pgfetestcpp ${test_dir}/test.cpp)
4851
# add_executable(totptest ${test_dir}/totptest.c)
4952
# add_executable(totptestcpp ${test_dir}/totptest.cpp)
50-
add_executable(pgfetestcpp ${test_dir}/test.cpp)
5153

5254
target_include_directories(pgfe PRIVATE
5355
${src_dir}
5456
${include_dir}
5557
)
5658

5759
target_link_libraries(pgfetest pgfe)
58-
# target_link_libraries(totptest pgfe)
5960
target_link_libraries(pgfetestcpp pgfe)
61+
# target_link_libraries(totptest pgfe)
6062
# target_link_libraries(totptestcpp pgfe)
6163

6264
include(${test_dir}/cmake/test_meta.cmake)

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
include meta.mak
1+
include metadata.mak
22

3-
.PHONY: all rebuild clean test install uninstall
3+
.PHONY: all rebuild clean test install uninstall init-scripts
44

55
all:
66
@echo 'Building...'
@@ -37,3 +37,6 @@ uninstall:
3737
@echo 'Removing shared library...'
3838
@rm -vrf $(LIB_DIR)/$(TARGET_FILE)
3939
@echo done
40+
41+
init-scripts:
42+
@chmod u+x ./scripts/{comment_header,update_meta,deploy}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
*libpgfe* currently supports hash encoding (e.g. SHA256, MD5), HMAC encoding, HOTP/TOTP and Base 16/32/64.
1313

14-
| Item | Content |
14+
*libpgfe* is currently under heavy development, more features and optimization will be added in the future.
15+
16+
| Entry | Info |
1517
| :----------- | :------------------ |
1618
| C Standard | [C11 (ISO/IEC 9899:2011)](https://en.wikipedia.org/wiki/C11_(C_standard_revision)) |
1719
| C++ Standard | [C++14 (ISO/IEC 14882:2014)](https://en.wikipedia.org/wiki/C++14) |
@@ -20,9 +22,7 @@
2022

2123
[*Any questions?*](.github/qna.md)
2224

23-
## Endianness (Byte order)
24-
25-
> [*What is it anyway??*](https://en.wikipedia.org/wiki/Endianness)
25+
## [Endianness (Byte order)](https://en.wikipedia.org/wiki/Endianness)
2626

2727
The implementation philosophy of *libpgfe* assumes that the systems running this library are **Little Endian**, since it is widely used by architectures and OS. Therefore, this library should not run properly on Big Endian systems.
2828

include/algorithm_selectable.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AlgorithmSelectable
2828
void select_algorithm(pgfe_algorithm_choice choice);
2929

3030
public:
31-
pgfe_algorithm_choice algorithm();
31+
pgfe_algorithm_choice algorithm() const;
3232
};
3333
} // namespace PGFE
3434
} // namespace chardon55
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <stdbool.h>
1212

13-
#include "generic.h"
13+
#include "../generic.h"
1414

1515
#ifdef __cplusplus
1616
extern "C" {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef LIBPGFE_GENERIC_INTERNAL_H
99
#define LIBPGFE_GENERIC_INTERNAL_H
1010

11-
#include "generic.h"
11+
#include "../generic.h"
1212

1313
#ifdef __cplusplus
1414
extern "C" {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
#include <stdint.h>
1212

13-
#include "generic.h"
14-
#include "hmac.h"
13+
#include "../generic.h"
14+
#include "../hmac.h"
1515

1616
#ifdef __cplusplus
1717
extern "C" {

0 commit comments

Comments
 (0)