RealPath:
WebPath:
2017/03/02 13:59 (JST) 更新
各種モジュール >>

OpenSSL利用(ソースから)

Contents

依存: NASM の導入

  • インストール先 … C:\NASM

手動で PATH 追加も行っておく。

OpenSSL導入

パッケージ入手

https://www.openssl.org/source/openssl-1.0.2k.tar.gz

ビルド・インストール

Developer Command Prompt for VS 2017 RC にて。

Developer Command Prompt for VS 2017 RC
> tar xzvf openssl-1.0.2k.tar.gz
> cd openssl-1.0.2k
> perl Configure VC-WIN32 --prefix=C:/openssl enable-static-engine
Configuring for VC-WIN32
    no-ec_nistp_64_gcc_128 [default]  OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
    no-gmp          [default]  OPENSSL_NO_GMP (skip dir)
    no-jpake        [experimental] OPENSSL_NO_JPAKE (skip dir)
    no-krb5         [krb5-flavor not specified] OPENSSL_NO_KRB5
    no-libunbound   [experimental] OPENSSL_NO_LIBUNBOUND (skip dir)
    no-md2          [default]  OPENSSL_NO_MD2 (skip dir)
    no-rc5          [default]  OPENSSL_NO_RC5 (skip dir)
    no-rfc3779      [default]  OPENSSL_NO_RFC3779 (skip dir)
    no-sctp         [default]  OPENSSL_NO_SCTP (skip dir)
    no-shared       [default]
    no-ssl-trace    [default]  OPENSSL_NO_SSL_TRACE (skip dir)
    no-ssl2         [default]  OPENSSL_NO_SSL2 (skip dir)
    no-store        [experimental] OPENSSL_NO_STORE (skip dir)
    no-unit-test    [default]  OPENSSL_NO_UNIT_TEST (skip dir)
    no-weak-ssl-ciphers [default]  OPENSSL_NO_WEAK_SSL_CIPHERS (skip dir)
    no-zlib         [default]
    no-zlib-dynamic [default]
IsMK1MF=1
CC            =cl
CFLAG         =-DOPENSSL_THREADS  -DDSO_WIN32 -W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
EX_LIBS       =
CPUID_OBJ     =x86cpuid.o
BN_ASM        =bn-586.o co-586.o x86-mont.o x86-gf2m.o
EC_ASM        =
DES_ENC       =des-586.o crypt586.o
AES_ENC       =aes-586.o vpaes-x86.o aesni-x86.o
BF_ENC        =bf-586.o
CAST_ENC      =cast-586.o
RC4_ENC       =rc4-586.o
RC5_ENC       =rc5-586.o
MD5_OBJ_ASM   =md5-586.o
SHA1_OBJ_ASM  =sha1-586.o sha256-586.o sha512-586.o
RMD160_OBJ_ASM=rmd-586.o
CMLL_ENC      =cmll-x86.o
MODES_OBJ     =ghash-x86.o
ENGINES_OBJ   =
PROCESSOR     =
RANLIB        =/mingw64/bin/ranlib
ARFLAGS       =
PERL          =/usr/bin/perl
THIRTY_TWO_BIT mode
BN_LLONG mode
RC4_INDEX mode
RC4_CHUNK is undefined

Configured for VC-WIN32.

> ms\do_nasm
> nmake /f ms\nt.mak
> nmake /f ms\nt.mak test
> nmake /f ms\nt.mak install
....
Copying: inc32/openssl/x509v3.h to C:/openssl/include/openssl/x509v3.h
        perl util/copy.pl "out32\openssl.exe C:\openssl\bin"
Copying: out32/openssl.exe to C:/openssl/bin/openssl.exe
        perl util/mkdir-p.pl "C:\openssl\ssl"
created directory `C:/openssl/ssl'
        perl util/copy.pl apps\openssl.cnf "C:\openssl\ssl"
Copying: apps/openssl.cnf to C:/openssl/ssl/openssl.cnf
        perl util/copy.pl "out32\ssleay32.lib" "C:\openssl\lib"
Copying: out32/ssleay32.lib to C:/openssl/lib/ssleay32.lib
        perl util/copy.pl "out32\libeay32.lib" "C:\openssl\lib"
Copying: out32/libeay32.lib to C:/openssl/lib/libeay32.lib

インストール確認

Developer Command Prompt for VS 2017 RC
> dir c:\openssl\lib
....
2017-02-11  09:15        12,335,718 libeay32.lib
2017-02-11  09:15         2,053,706 ssleay32.lib

OpenSSL利用プログラム例

  • Additional Include Directories = c:\openssl\include
  • Additional Library Directories = c:\openssl\lib
  • Additional Dependencies = libeay32.lib;....
sample.cpp
#include <openssl/crypto.h>
#include <stdio.h>
int main() {
    void* p = OPENSSL_malloc(1);
    printf("hello\n");
    OPENSSL_free(p);
}

参考