Visual Studio и ошибка C2027: использование неопределенного типа rsa_st

аюсь использовать OpenSSL с Visual Studio C Project.

Я скомпилировал openssl с помощью команды visual studio nmake, затем установил все в предопределенную папку (C: \ openssl), используя:

nmake install

Структура папок следующая:

bin

include/openssl

lib

Внутри include / openssl есть заголовочные файлы .h.

В моей Visual Studio 2012 я создал пустой общий проект c ++ и включил C: \ openssl \ include

[Project properties -> C/C++ -> General -> Additional Include Directories]

Я также добавил каталог lib и файлы .lib.

Но когда я компилирую код, я получаю

left of 'key_len' specifies undefined struct/union 'evp_cipher_st'

Внутри моего кода у меня есть эти строки

const EVP_CIPHER *cipher = EVP_get_cipherbyname("aes-256-cbc");
//some other code
return cipher->key_len;

В файле ossl_typ.h для определения evp_cipher_st, он объявлен как

typedef struct evp_cipher_st EVP_CIPHER;

и нет никакого определения для структуры тела!

Копая больше в исходное дерево, evp_cipher_st определен в crypto \ include \ internal \ evp_int.h, который не включен в папку include папки установки openssl.

Я также попытался включить crypto \ include \ internal \ evp_int.h из коробки, но это приводит к большему количеству проблем.

Есть идеи, как это исправить?

ОБНОВИТЬ:

Вот полная функция и моя главная, включая все включает:

#include <winsock2.h>
#include <Ws2tcpip.h>
#include <mswsock.h>
#include <windows.h>
#include <minwindef.h>
#include <malloc.h>
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef int socklen_t;
#include "wingetopt.h"
#include <Wincrypt.h>
#include <iphlpapi.h>
#include "Shlwapi.h"
#include <Bcrypt.h>

#define inline __inline
#define STATUS_SUCCESS 0

#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Shlwapi.lib")

#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
#include <time.h>

int generate_aes_key(const unsigned char *input_key, uint16_t input_key_size,
            unsigned char *output_key, uint16_t *outputkey_size) {

        const EVP_MD *dgst = NULL;
        unsigned char iv[EVP_MAX_IV_LENGTH];
        const EVP_CIPHER *cipher = EVP_get_cipherbyname("aes-256-cbc");

        if(!cipher) {

            return -1;
        }

        dgst = EVP_get_digestbyname("sha256");

        if(!dgst) {

            fprintf(stderr, "no such digest\n");
            return -2;
        }

        if(!EVP_BytesToKey(cipher, dgst, NULL, input_key, input_key_size, 1, output_key, iv)) {

            return -3;
        }

        *outputkey_size = (uint16_t)cipher->key_len;

        return 0;
}

int main(int argc, char *argv[]) {

    char secret[] = "MIIFBTCCAu2gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwTjELMAkGA1UEBhMCR0Ix";

    unsigned char shared_secret[500];
    uint16_t aes_keylen = 0;

    //bunch of codes 

    if(generate_aes_key((unsigned char *)secret, strlen(secret), shared_secret, &aes_keylen) < 0) {

        fprintf(stderr, "Could not get initial shared secret\n");
        return 0;
    }

    //other codes
}

Версия Openssl:

OpenSSL_1_1_0-pre6-1266-g487d3a726

Над версией находится последнее имя тега из git, я думаю, что оно является самым свежим до сих пор. Последняя версия коммита и дата следующие:

487d3a726a1970e84853434561d88cb4ac212d15

Автор: EasySec Дата: Вт 17 Янв 17:21:55 2017 +0100

И, наконец, вот вывод компиляции Visual Studio 2012:

Build started 1/28/2017 8:23:02 PM.
 1>Project "C:\CODE\mycode.vcxproj" on node 2 (Build target(s)).
 1>ClCompile:
     C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /I"c:\openssl\include" /ZI /nologo /W3 /WX- /Od /Oy- /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc110.pdb" /Gd /TC /analyze- /errorReport:prompt src\main.c ... 

     wingetopt.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     crypto.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
 1>c:\CODE\src\crypto.c(517): error C2037: left of 'key_len' specifies undefined struct/union 'evp_cipher_st'
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     client.c
 1>c:\openssl\include\openssl\lhash.h(198): warning C4090: 'function' : different 'const' qualifiers
     Generating Code...
 1>Done Building Project "C:\CODE\mycode.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:08.55

Ответы на вопрос(1)

Ваш ответ на вопрос