compilation error with openssl-1.1.0 and DH_get0_key

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

compilation error with openssl-1.1.0 and DH_get0_key

Robert Watson
I'm trying to update a crypto library for crtmpserver to work with openssl 1.1.0.  The software is no longer actively maintained and my c++ skills are somewhat rudimentary but I keep getting a compilation error for something that seems trivial.

Here's the code snippet:
bool DHWrapper::CopyPublicKey(uint8_t *pDst, int32_t dstLength) {
    if (_pDH == NULL) {
        FATAL("DHWrapper not initialized");
        return false;
    }
    BIGNUM *_keyPublic,*_keyPrivate;
    _keyPublic = BN_new();
    _keyPrivate = BN_new();
    DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );
    CopyKey(_keyPublic, pDst, dstLength);
    return true;
}

Here's the compilation error:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp: In member function ‘bool DHWrapper::CopyPublicKey(uint8_t*, int32_t)’:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp:92:47: error: cannot convert ‘BIGNUM {aka bignum_st}’ to ‘const BIGNUM** {aka const bignum_st**}’ for argument ‘2’ to ‘void DH_get0_key(const DH*, const BIGNUM**, const BIGNUM**)’
  DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );
                                               ^
make[2]: *** [common/CMakeFiles/common.dir/build.make:591: common/CMakeFiles/common.dir/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:231: common/CMakeFiles/common.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

What am I doing wrong? Thanks,
Robert


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error with openssl-1.1.0 and DH_get0_key

OpenSSL - User mailing list
On 02/21/2018 10:16 AM, Robert Watson wrote:
I'm trying to update a crypto library for crtmpserver to work with openssl 1.1.0.  The software is no longer actively maintained and my c++ skills are somewhat rudimentary but I keep getting a compilation error for something that seems trivial.

Here's the code snippet:
bool DHWrapper::CopyPublicKey(uint8_t *pDst, int32_t dstLength) {
    if (_pDH == NULL) {
        FATAL("DHWrapper not initialized");
        return false;
    }
    BIGNUM *_keyPublic,*_keyPrivate;
    _keyPublic = BN_new();
    _keyPrivate = BN_new();
    DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );

Use '&' instead of '*'

-Ben

    CopyKey(_keyPublic, pDst, dstLength);
    return true;
}

Here's the compilation error:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp: In member function ‘bool DHWrapper::CopyPublicKey(uint8_t*, int32_t)’:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp:92:47: error: cannot convert ‘BIGNUM {aka bignum_st}’ to ‘const BIGNUM** {aka const bignum_st**}’ for argument ‘2’ to ‘void DH_get0_key(const DH*, const BIGNUM**, const BIGNUM**)’
  DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );
                                               ^
make[2]: *** [common/CMakeFiles/common.dir/build.make:591: common/CMakeFiles/common.dir/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:231: common/CMakeFiles/common.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

What am I doing wrong? Thanks,
Robert





--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error with openssl-1.1.0 and DH_get0_key

Matt Caswell-2


On 21/02/18 16:20, Benjamin Kaduk via openssl-users wrote:

> On 02/21/2018 10:16 AM, Robert Watson wrote:
>> I'm trying to update a crypto library for crtmpserver to work with
>> openssl 1.1.0.  The software is no longer actively maintained and my
>> c++ skills are somewhat rudimentary but I keep getting a compilation
>> error for something that seems trivial.
>>
>> Here's the code snippet:
>> bool DHWrapper::CopyPublicKey(uint8_t *pDst, int32_t dstLength) {
>>     if (_pDH == NULL) {
>>         FATAL("DHWrapper not initialized");
>>         return false;
>>     }
>>     BIGNUM *_keyPublic,*_keyPrivate;
>>     _keyPublic = BN_new();
>>     _keyPrivate = BN_new();
>>     DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );
>
> Use '&' instead of '*'

Yes, this is the problem. In addition to that though you have a memory
leak. DH_get0_key() will overwrite the values pointed to by _keyPublic
and_keyPrivate. So don't initialise them first with the BN_new() calls.

Matt


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error with openssl-1.1.0 and DH_get0_key

Robert Watson
In reply to this post by OpenSSL - User mailing list
Thanks for suggestion, don't understand why the compiler didn't complain about the first argument.  Unfortunately, that just brings out other problem....
code:
bool DHWrapper::CopyPublicKey(uint8_t *pDst, int32_t dstLength) {
    if (_pDH == NULL) {
        FATAL("DHWrapper not initialized");
        return false;
    }
    BIGNUM *_keyPublic, *_keyPrivate;
    _keyPublic = BN_new();
    _keyPrivate = BN_new();
    DH_get0_key( _pDH, &_keyPublic, &_keyPrivate );
    CopyKey(_keyPublic, pDst, dstLength);
    return true;
}
Still fails compilation with:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp: In member function ‘bool DHWrapper::CopyPublicKey(uint8_t*, int32_t)’:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp:92:21: error: invalid conversion from ‘BIGNUM** {aka bignum_st**}’ to ‘const BIGNUM** {aka const bignum_st**}’ [-fpermissive]
  DH_get0_key( _pDH, &_keyPublic, &_keyPrivate );
                     ^~~~~~~~~~~
In file included from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/misc/crypto.h:26:0,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/buffering/iobuffer.h:27,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/buffering/buffering.h:23,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/utils.h:23,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/common.h:25:
/usr/include/openssl/dh.h:183:6: note:   initializing argument 2 of ‘void DH_get0_key(const DH*, const BIGNUM**, const BIGNUM**)’
 void DH_get0_key(const DH *dh,
      ^~~~~~~~~~~
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp:92:34: error: invalid conversion from ‘BIGNUM** {aka bignum_st**}’ to ‘const BIGNUM** {aka const bignum_st**}’ [-fpermissive]
  DH_get0_key( _pDH, &_keyPublic, &_keyPrivate );
                                  ^~~~~~~~~~~~
In file included from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/misc/crypto.h:26:0,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/buffering/iobuffer.h:27,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/buffering/buffering.h:23,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/utils/utils.h:23,
                 from /build/crtmpserver/src/crtmpserver/sources/common/include/common.h:25:
/usr/include/openssl/dh.h:183:6: note:   initializing argument 3 of ‘void DH_get0_key(const DH*, const BIGNUM**, const BIGNUM**)’
 void DH_get0_key(const DH *dh,
      ^~~~~~~~~~~
make[2]: *** [common/CMakeFiles/common.dir/build.make:591: common/CMakeFiles/common.dir/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:231: common/CMakeFiles/common.dir/all] Error 2
make: *** [Makefile:130: all] Error 2



On Wed, Feb 21, 2018 at 8:20 AM, Benjamin Kaduk <[hidden email]> wrote:
On 02/21/2018 10:16 AM, Robert Watson wrote:
I'm trying to update a crypto library for crtmpserver to work with openssl 1.1.0.  The software is no longer actively maintained and my c++ skills are somewhat rudimentary but I keep getting a compilation error for something that seems trivial.

Here's the code snippet:
bool DHWrapper::CopyPublicKey(uint8_t *pDst, int32_t dstLength) {
    if (_pDH == NULL) {
        FATAL("DHWrapper not initialized");
        return false;
    }
    BIGNUM *_keyPublic,*_keyPrivate;
    _keyPublic = BN_new();
    _keyPrivate = BN_new();
    DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );

Use '&' instead of '*'

-Ben

    CopyKey(_keyPublic, pDst, dstLength);
    return true;
}

Here's the compilation error:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp: In member function ‘bool DHWrapper::CopyPublicKey(uint8_t*, int32_t)’:
/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp:92:47: error: cannot convert ‘BIGNUM {aka bignum_st}’ to ‘const BIGNUM** {aka const bignum_st**}’ for argument ‘2’ to ‘void DH_get0_key(const DH*, const BIGNUM**, const BIGNUM**)’
  DH_get0_key( _pDH, *_keyPublic, *_keyPrivate );
                                               ^
make[2]: *** [common/CMakeFiles/common.dir/build.make:591: common/CMakeFiles/common.dir/build/crtmpserver/src/crtmpserver/sources/common/src/utils/misc/crypto.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:231: common/CMakeFiles/common.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

What am I doing wrong? Thanks,
Robert






--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users