sftcd / openssl

TLS/SSL and crypto library
https://www.openssl.org
Apache License 2.0
46 stars 20 forks source link

Build failure on windows #24

Closed pandaninjas closed 1 year ago

pandaninjas commented 1 year ago

configuration data:

Command line (with current working directory = .):

    C:\Strawberry\perl\bin\perl.exe Configure

Perl information:

    C:\Strawberry\perl\bin\perl.exe
    5.32.1 for MSWin32-x64-multi-thread

Enabled features:

    acvp_tests
    aria
    asm
    async
    autoalginit
    autoerrinit
    autoload-config
    bf
    blake2
    bulk
    cached-fetch
    camellia
    capieng
    cast
    chacha
    cmac
    cmp
    cms
    comp
    ct
    deprecated
    des
    dgram
    dh
    dsa
    dso
    dtls
    dynamic-engine
    ec
    ec2m
    ecdh
    ecdsa
    engine
    err
    filenames
    fips
    fips-securitychecks
    gost
    idea
    legacy
    makedepend
    md4
    mdc2
    module
    multiblock
    nextprotoneg
    pinshared
    ocb
    ocsp
    padlockeng
    pic
    poly1305
    posix-io
    psk
    rc2
    rc4
    rdrand
    rfc3779
    rmd160
    scrypt
    secure-memory
    seed
    shared
    siphash
    siv
    sm2
    sm3
    sm4
    sock
    srp
    srtp
    sse2
    ssl
    static-engine
    stdio
    tests
    threads
    tls
    ts
    ui-console
    uplink
    whirlpool
    tls1
    tls1-method
    tls1_1
    tls1_1-method
    tls1_2
    tls1_2-method
    tls1_3
    dtls1
    dtls1-method
    dtls1_2
    dtls1_2-method

Disabled features:

    afalgeng            [not-linux] OPENSSL_NO_AFALGENG
    asan                [default]   OPENSSL_NO_ASAN
    buildtest-c++       [default]
    crypto-mdebug       [default]   OPENSSL_NO_CRYPTO_MDEBUG
    devcryptoeng        [default]   OPENSSL_NO_DEVCRYPTOENG
    ec_nistp_64_gcc_128 [default]   OPENSSL_NO_EC_NISTP_64_GCC_128
    egd                 [default]   OPENSSL_NO_EGD
    external-tests      [default]   OPENSSL_NO_EXTERNAL_TESTS
    fuzz-libfuzzer      [default]   OPENSSL_NO_FUZZ_LIBFUZZER
    fuzz-afl            [default]   OPENSSL_NO_FUZZ_AFL
    ktls                [default]   OPENSSL_NO_KTLS
    md2                 [default]   OPENSSL_NO_MD2 (skip crypto\md2)
    msan                [default]   OPENSSL_NO_MSAN
    rc5                 [default]   OPENSSL_NO_RC5 (skip crypto\rc5)
    sctp                [default]   OPENSSL_NO_SCTP
    ssl-trace           [default]   OPENSSL_NO_SSL_TRACE
    trace               [default]   OPENSSL_NO_TRACE
    ubsan               [default]   OPENSSL_NO_UBSAN
    unit-test           [default]   OPENSSL_NO_UNIT_TEST
    weak-ssl-ciphers    [default]   OPENSSL_NO_WEAK_SSL_CIPHERS
    zlib                [default]
    zlib-dynamic        [default]
    ssl3                [default]   OPENSSL_NO_SSL3
    ssl3-method         [default]   OPENSSL_NO_SSL3_METHOD

Config target attributes:

    AR => "lib",
    ARFLAGS => "/nologo",
    AS => "nasm",
    ASFLAGS => "-g",
    CC => "cl",
    CFLAGS => "/W3 /wd4090 /nologo /O2",
    CPP => "\"\$(CC)\" /EP /C",
    HASHBANGPERL => "/usr/bin/env perl",
    LD => "link",
    LDFLAGS => "/nologo /debug",
    MT => "mt",
    MTFLAGS => "-nologo",
    RANLIB => "CODE(0x26b5e60)",
    RC => "rc",
    ar_resp_delim => "
",
    aroutflag => "/out:",
    asflags => "-Ox -f win64 -DNEAR",
    asm_arch => "x86_64",
    asoutflag => "-o ",
    bin_cflags => "/Zi /Fdapp.pdb",
    bin_lflags => "setargv.obj /subsystem:console /opt:ref",
    bn_ops => "SIXTY_FOUR_BIT",
    build_file => "makefile",
    build_scheme => [ "unified", "windows", "VC-common" ],
    cflags => "/Gs0 /GF /Gy /MD",
    coutflag => "/Fo",
    cpp_depend_flags => "/Zs /showIncludes",
    cppflags => "",
    defines => [ "OPENSSL_BUILDING_OPENSSL", "OPENSSL_SYS_WIN32", "WIN32_LEAN_AND_MEAN", "UNICODE", "_UNICODE", "_CRT_SECURE_NO_DEPRECATE", "_WINSOCK_DEPRECATED_NO_WARNINGS" ],
    disable => [  ],
    dso_cflags => "/Zi /Fddso.pdb",
    dso_scheme => "win32",
    enable => [  ],
    ex_libs => "ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib",
    includes => [  ],
    ld_implib_flag => "/implib:",
    ld_resp_delim => "
",
    lddefflag => "/def:",
    ldoutflag => "/out:",
    ldpostoutflag => "",
    ldresflag => " ",
    lflags => "",
    lib_cflags => "/Zi /Fdossl_static.pdb",
    lib_cppflags => "",
    lib_defines => [ "L_ENDIAN" ],
    module_cflags => "",
    module_cxxflags => undef,
    module_ldflags => "/dll",
    mtinflag => "-manifest ",
    mtoutflag => "-outputresource:",
    multilib => "-x64",
    perl_platform => "Windows::MSVC",
    perlasm_scheme => "auto",
    rcoutflag => "/fo",
    shared_cflag => "",
    shared_defflag => "",
    shared_defines => [  ],
    shared_ldflag => "/dll",
    shared_rcflag => "",
    shared_target => "win-shared",
    sys_id => "WIN64A",
    thread_defines => [  ],
    thread_scheme => "winthreads",
    unistd => "<unistd.h>",
    uplink_arch => "x86_64",

Recorded environment:

    AR =
    ARFLAGS =
    AS =
    ASFLAGS =
    BUILDFILE =
    CC =
    CFLAGS =
    CPP =
    CPPDEFINES =
    CPPFLAGS =
    CPPINCLUDES =
    CROSS_COMPILE =
    CXX =
    CXXFLAGS =
    HASHBANGPERL =
    LD =
    LDFLAGS =
    LDLIBS =
    MT =
    MTFLAGS =
    OPENSSL_LOCAL_CONFIG_DIR =
    PERL =
    RANLIB =
    RC =
    RCFLAGS =
    RM =
    WINDRES =
    __CNF_CFLAGS =
    __CNF_CPPDEFINES =
    __CNF_CPPFLAGS =
    __CNF_CPPINCLUDES =
    __CNF_CXXFLAGS =
    __CNF_LDFLAGS =
    __CNF_LDLIBS =

Makevars:

    AR              = lib
    ARFLAGS         = /nologo
    AS              = nasm
    ASFLAGS         = -g
    CC              = cl
    CFLAGS          = /W3 /wd4090 /nologo /O2
    CPP             = "$(CC)" /EP /C
    CPPDEFINES      =
    CPPFLAGS        =
    CPPINCLUDES     =
    CXXFLAGS        =
    HASHBANGPERL    = /usr/bin/env perl
    LD              = link
    LDFLAGS         = /nologo /debug
    LDLIBS          =
    MT              = mt
    MTFLAGS         = -nologo
    PERL            = C:\Strawberry\perl\bin\perl.exe
    RANLIB          = ranlib
    RC              = rc
    RCFLAGS         =

NOTE: These variables only represent the configuration view.  The build file
template may have processed these variables further, please have a look at the
build file for more exact data:
    makefile

build file:

    makefile

build file templates:

    Configurations\common0.tmpl
    Configurations\windows-makefile.tmpl
    Configurations\common.tmpl

Error parts of log:

crypto\hpke.c(444): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(455): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(462): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(468): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(521): error C2057: expected constant expression
crypto\hpke.c(521): error C2466: cannot allocate an array of constant size 0
crypto\hpke.c(521): error C2133: 'tag': unknown size
crypto\hpke.c(545): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(556): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(563): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(577): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(742): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(745): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(894): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(897): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(954): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(1527): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(1538): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(1546): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(1992): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(2003): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(2011): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(2019): warning C4267: 'function': conversion from 'size_t' to 'const uint32_t', possible loss of data
crypto\hpke.c(2340): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(2374): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
crypto\hpke.c(2397): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
sftcd commented 1 year ago

Hiya,

Sorry, I don't have a windows dev environment, but a question - the error above seems to be:

crypto\hpke.c(521): error C2057: expected constant expression
crypto\hpke.c(521): error C2466: cannot allocate an array of constant size 0
crypto\hpke.c(521): error C2133: 'tag': unknown size

When I look at line 521 of crypto/hpke/hpke.c that's just a call to OPENSSL_free() and the source file names differ so are you perhaps some old branch or something?

The latest branch for this fork is "ECH-draft-13c" If you're just interested in HPKE, that's been merged so is in the master branch at https://github.com/openssl/openssl

S

pandaninjas commented 1 year ago

Hiya,

Sorry, I don't have a windows dev environment, but a question - the error above seems to be:

crypto\hpke.c(521): error C2057: expected constant expression
crypto\hpke.c(521): error C2466: cannot allocate an array of constant size 0
crypto\hpke.c(521): error C2133: 'tag': unknown size

When I look at line 521 of crypto/hpke/hpke.c that's just a call to OPENSSL_free() and the source file names differ so are you perhaps some old branch or something?

The latest branch for this fork is "ECH-draft-13c" If you're just interested in HPKE, that's been merged so is in the master branch at https://github.com/openssl/openssl

S

I think the problem is that hpke.c is a merged file with different things. Opening crypto/hpke.c which has been generated by some process, the problematic lines are

static int hpke_aead_enc(
            hpke_suite_t   suite,
            unsigned char *key, size_t keylen,
            unsigned char *iv, size_t ivlen,
            unsigned char *aad, size_t aadlen,
            unsigned char *plain, size_t plainlen,
            unsigned char *cipher, size_t *cipherlen)
{
    int erv=1;
    EVP_CIPHER_CTX *ctx=NULL;
    int len;
    size_t ciphertextlen;
    unsigned char *ciphertext=NULL;
    size_t taglen=hpke_aead_tab[suite.aead_id].taglen;
    unsigned char tag[taglen]; // this one is line 521
    if ((taglen+plainlen)>*cipherlen) {
        erv=__LINE__; goto err;
    }

It seems that my compiler has somehow mangled the code that was originally here https://github.com/sftcd/openssl/blob/f06ef1657a3d4322153b26231a7afa3d55724e52/crypto/hpke/hpke.c#L220

sftcd commented 1 year ago

Is it possible to start from a clean build and see what happens?

pandaninjas commented 1 year ago

It seems like the error happens from a clean build (with a redone configure)

pandaninjas commented 1 year ago

Also I am on the ECH-without-ESNI branch

sftcd commented 1 year ago

ah, that last is your issue, the right branch to use is ECH-draft-13c (sorry for the opaque/silly naming;-)

pandaninjas commented 1 year ago

It seems to work, but I needed to specify the proper architecture through configure. Closing this issue