mirror of
https://gitea.tendokyu.moe/moegrid/sega-mount.git
synced 2026-10-08 22:39:49 +03:00
首次提交
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace bcrypt_util {
|
||||
// 将const T*转换为PUCHAR,供BCrypt API使用(BCrypt参数声明为非const但实际不修改输入)
|
||||
template<typename T>
|
||||
PUCHAR to_puchar(const T *p) {
|
||||
return reinterpret_cast<PUCHAR>(const_cast<T *>(p));
|
||||
}
|
||||
|
||||
// 打开BCrypt算法提供者并设置链模式
|
||||
bool open(BCRYPT_ALG_HANDLE &hAlg, const wchar_t *chaining, std::string *err = nullptr);
|
||||
|
||||
// 获取对称密钥对象所需缓冲区大小
|
||||
bool get_object_length(BCRYPT_ALG_HANDLE hAlg, ULONG &cb_obj, std::string *err = nullptr);
|
||||
|
||||
// 生成对称密钥,key_obj由调用方持有
|
||||
bool generate_symmetric_key(BCRYPT_ALG_HANDLE hAlg,
|
||||
BCRYPT_KEY_HANDLE &hKey,
|
||||
std::vector<uint8_t> &key_obj,
|
||||
const uint8_t *key, ULONG key_len,
|
||||
std::string *err = nullptr);
|
||||
}
|
||||
Reference in New Issue
Block a user