stef / libopaque

c implementation of the OPAQUE protocol with bindings for python, php, ruby, lua, zig, java, erlang, golang, js and SASL. also supports a threshold variants based on 2hashdh and 3hashtdh
GNU Lesser General Public License v3.0
71 stars 10 forks source link

opaque.h header does not compile in C++ environment #29

Closed WorldofJARcraft closed 2 years ago

WorldofJARcraft commented 2 years ago

The expression

uint8_t sec[OPAQUE_USER_SESSION_SECRET_LEN+pwdU_len]

in opaque.h is valid in C, but does not compile in C++ since the compiler does not know what pwdU_len will be at run time. I have changed the type to pointer and left the expected size as a comment.

stef commented 2 years ago

why would you compile this with c++?

WorldofJARcraft commented 2 years ago

I have a mixed code base with both C and C++. I included opaque.h from a C++ source file (as a meta-dependency), and it broke my build since C++ did not understand the two method declarations that followed the schema above.

stef commented 2 years ago

i think there is a way to use the cpp to distinguish between c and c++ compiler maybe use

#ifdef c++
.... just pointer
#else
... original array with size
#endif
WorldofJARcraft commented 2 years ago

i think there is a way to use the cpp to distinguish between c and c++ compiler maybe use

#ifdef c++
.... just pointer
#else
... original array with size
#endif

The latest change should do that, currently testing it in my CI.

WorldofJARcraft commented 2 years ago

The respective commit works in my test environment.

stef commented 2 years ago

awesome! :)