📄 kdf2.cpp
字号:
/************************************************** KDF2 Source File ** (C) 1999-2002 The Botan Project **************************************************/#include <botan/kdf2.h>#include <botan/lookup.h>namespace Botan {/************************************************** KDF2 Key Derivation Mechanism **************************************************/SymmetricKey KDF2::derive(const byte in[], u32bit length, u32bit out_len) const { SecureVector<byte> output; u32bit counter = 1; while(out_len) { hash->update(in, length); for(u32bit j = 0; j != 4; j++) hash->update(get_byte(j, counter)); hash->update(P); SecureVector<byte> hash_result = hash->final(); u32bit added = std::min(hash_result.size(), out_len); output.append(hash_result, added); out_len -= added; counter++; } return SymmetricKey(output); }/************************************************** KDF2 Constructor **************************************************/KDF2::KDF2(const std::string& hash_name, const std::string& Pstr) : P(Pstr) { hash = get_hash(hash_name); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -