私はC++ Builder 10 Seattleでアプリケーションをコンパイルしていて、OpenSSL for RSAを使用しようとしています。C++ BuilderでOpenSSLを使用する
:、私はエラーメッセージが表示されました[ilink32 Error] Error: 'C:\USERS\ERICWANG\DESKTOP\TESTOPENSSL2\LIB\LIBEAY32.LIB' contains invalid OMF record, type 0x21 (possibly COFF)
#include <stdio.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
bool generate_key()
{
int ret = 0;
RSA *r = NULL;
BIGNUM *bne = NULL;
BIO *bp_public = NULL, *bp_private = NULL;
int bits = 2048;
unsigned long e = RSA_F4;
// 1. generate rsa key
bne = BN_new();
ret = BN_set_word(bne,e);
if(ret != 1){
goto free_all;
}
r = RSA_new();
ret = RSA_generate_key_ex(r, bits, bne, NULL);
if(ret != 1){
goto free_all;
}
// 2. save public key
bp_public = BIO_new_file("public.pem", "w+");
ret = PEM_write_bio_RSAPublicKey(bp_public, r);
if(ret != 1){
goto free_all;
}
// 3. save private key
bp_private = BIO_new_file("private.pem", "w+");
ret = PEM_write_bio_RSAPrivateKey(bp_private, r, NULL, NULL, 0, NULL, NULL);
// 4. free
free_all:
BIO_free_all(bp_public);
BIO_free_all(bp_private);
RSA_free(r);
BN_free(bne);
return (ret == 1);
}
int main(int argc, char* argv[])
{
generate_key();
return 0;
}
私は私のプロジェクトにlibeay32.lib
とssleay32.lib
を追加しました:
ここHow to Use OpenSSL to Generate RSA Keys in C/C++
コードです:
私はこのチュートリアルに従っ私はいくつかのヒントを見ましたcoff2omf
とimplib
ツールを使用していましたが、どちらも機能しませんでした。
私は、
libeay32.lib
を変換するためにcoff2omf.exe
を使用しました。私は、同じフォルダにcoff2omf.exe
とlibeay32.lib
を入れて、このコマンドを入力する:coff2omf libeay32.lib Blibeay32.lib
それは言った:
ERROR: COFF error: libeay32.lib : invalid machine type detected
私は
implib.exe
を使用して.dll
ファイルにlibeay32.lib
を変換しようとしました。私は、このコマンドを入力する:implib libeay32.lib Blibeay32.dll
それは言った:
Error : unable to open file
そして、私の
libeay32.lib
は、1キロバイトのファイルにそのサイズを変更します。つまり、ファイルが間違っていたことを意味します。
** XE10 **はありません。 ** 10.0シアトル**、** 10.1ベルリン**など –