Skip to content

Commit

Permalink
English:
Browse files Browse the repository at this point in the history
Implemented PBKDF2 (Password-Based Key Derivation Function Specification Version 2.1), which uses the SHA2-512 bit version of the hash algorithm.
and implemented the Scrypt algorithm based on it
https://www.rfc-editor.org/rfc/rfc7914
https://www.rfc-editor.org/rfc/rfc8018
https://en.wikipedia.org/wiki/PBKDF2
https://en.wikipedia.org/wiki/Scrypt
https://github.com/Tarsnap/scrypt
https://www.tarsnap.com/scrypt/scrypt.pdf

OaldresPuzzle_Cryptic 2.0 Packet Cryptography Algorithm Module Complete
The key of the encryption and decryption function is using matrix transformation, addition, subtraction, multiplication, and data from unpredictable pseudo-random numbers as the core.
This performs data encryption and after data decryption
The current pseudo-random number and matrix will be changed and the state will be preserved.
It also has a substantially adjusted nonlinear function internally, using a principle similar to that of sequence ciphers
If the provided master key has been used up, after the counter has passed a certain number of times.
A 64-bit version of the pseudo-random number engine of Mersenne_Twister 19937 is used and the seed number is set based on the previous key data, then the salted data is generated and finally the old master key data and the salted data are passed to the Scrypt algorithm to generate a new secure master key.

Completed the infinite garbled code generation module, based on hash functions as well as pseudo-random number states, belonging to custom key derivation functions.

Tried and tested, using one of the basic principles of lattice cryptography (learning with errors), an algorithm for generating unpredictable keys and able to resist the computational power of quantum computers

Minor fix: When testing the Key Derivation Function, added a hint and a word to modify the error

Chinese:

实现了使用SHA2-512比特版本的哈希算法的PBKDF2 (Password-Based Key Derivation Function Specification Version 2.1)
并以此为基础实现了Scrypt算法
https://www.rfc-editor.org/rfc/rfc7914
https://www.rfc-editor.org/rfc/rfc8018
https://en.wikipedia.org/wiki/PBKDF2
https://en.wikipedia.org/wiki/Scrypt
https://github.com/Tarsnap/scrypt
https://www.tarsnap.com/scrypt/scrypt.pdf

OaldresPuzzle_Cryptic 2.0 分组密码算法模块完成
加密解密函数的密钥是利用矩阵变换、加减法、乘法,数据来自不可预测的伪随机数作为核心。
这个进行数据加密,数据解密之后
当前的伪随机数以及矩阵将会将会改变并且保留状态。
同时内部具有一个大幅度调整的非线性函数,使用了类似于序列密码的原理
如果提供的主密钥已经使用完毕,在计数器经过一定的次数之后。
使用Mersenne_Twister19937的伪随机数引擎的64比特版本,并根据以前的密钥数据设置种子数,然后生成盐渍数据,最后把旧的主密钥数据和盐渍数据传递给Scrypt算法,生成新的安全主密钥。

完成了无限乱码生成模块,基于哈希函数以及伪随机数状态,属于自定义密钥派生函数。

尝试并测试了,使用其中的格子密码学的基本原理(在错误中学习),实现了生成不可预测的密钥的算法,并且能够抵抗量子计算机的计算能力

小修正: 测试Key Derivation Function时,增加了提示和修改错误的字
  • Loading branch information
Twilight-Dream-Of-Magic committed Nov 14, 2022
1 parent 2cc0411 commit 404b0d5
Show file tree
Hide file tree
Showing 8 changed files with 4,692 additions and 56 deletions.
10 changes: 5 additions & 5 deletions include/CommonSecurity/KeyDerivationFunction/AlgorithmArgon2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,7 @@ namespace CommonSecurity::KDF::Argon2
this->SetHashedDigestByte( optional_module_generate_hashed_digest_bytes.value() );
this->SetHashWorkerState();

std::cout << "Argon2 Infomation: Hashed digest data of the original data has been generated." << std::endl;
std::cout << "Argon2 Information: Hashed digest data of the original data has been generated." << std::endl;

if constexpr ( std::same_as<HashedDigestType, std::vector<std::uint8_t>> )
generate_hashed_data = _parameters_context_._generate_hashed_digest_bytes_;
Expand Down Expand Up @@ -2578,9 +2578,9 @@ namespace CommonSecurity::KDF::Argon2
{
bool whether_same_bytes = std::ranges::equal( generate_hashed_digest_bytes.begin(), generate_hashed_digest_bytes.end(), other_generate_hashed_digest_bytes.begin(), other_generate_hashed_digest_bytes.end() );
if ( whether_same_bytes )
std::cout << "Argon2 Information: The hashed password does match the supplied hash!" << std::endl;
std::cout << "Argon2 Caution Information: The hashed password does match the supplied hash!" << std::endl;
else
std::cout << "Argon2 Information: The hashed password does not match the supplied hash!" << std::endl;
std::cout << "Argon2 Caution Information: The hashed password does not match the supplied hash!" << std::endl;

return whether_same_bytes;
}
Expand Down Expand Up @@ -2612,9 +2612,9 @@ namespace CommonSecurity::KDF::Argon2
);

if ( whether_same_string )
std::cout << "Argon2 Information: The hashed password does match the supplied hash!" << std::endl;
std::cout << "Argon2 Caution Information: The hashed password does match the supplied hash!" << std::endl;
else
std::cout << "Argon2 Information: The hashed password does not match the supplied hash!" << std::endl;
std::cout << "Argon2 Caution Information: The hashed password does not match the supplied hash!" << std::endl;

return whether_same_string;
}
Expand Down
Loading

0 comments on commit 404b0d5

Please sign in to comment.