Код: Выделить всё
privateKey.sign(hashData,
padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=32),
utils.Prehashed(hashes.SHA256()))
Затем он проверяет эту сгенерированную подпись, извлекая открытый ключ из того же файла .pem и затем вызывая проверьте API следующим образом
Код: Выделить всё
publicKey.verify(
generated_signature,
hashData,
padding.PSS(
mgf=padding.MGF1(hashes.SHA256()),
salt_length=32
),
utils.Prehashed(hashes.SHA256())
)
Код: Выделить всё
failed to verify with private key from key file 'key.pem'.
Код: Выделить всё
#define _CRT_SECURE_NO_WARNINGS
#include "openssl/pem.h"
#include "openssl/err.h"
#include "openssl/evp.h"
#include "openssl/rsa.h"
#include "openssl/sha.h"
#include
#include
#include
#include
#include
#include "ms/applink.c"
void handleOpenSSLErrors()
{
ERR_print_errors_fp(stderr);
abort();
}
// Load RSA private key from a PEM file
EVP_PKEY* loadPrivateKey(const std::string& filePath)
{
FILE* keyFile = nullptr;
errno_t r_code = fopen_s(&keyFile, filePath.c_str(), "rb");
if (!keyFile) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79262027/signature-generated-using-openssl-c-api-does-not-match-with-same-code-in-pytho[/url]
Мобильная версия