Reputation: 760
I would like to try around with openssl and want to therefore alter the source.
I found code that includes #include <openssl/ec.h>
and obviously uses functions from that header. However I can not find the file ec.c which to my knowledge of C usually is located with the header (at /usr/include/openssl/ec.h
). Same in the github source of openssl (https://github.com/openssl/openssl), ec.h is located at openssl-master/include/openssl
but there is no ec.c
So: Where does gcc look to find the methods defined in ec.h?
Thank you for answers!
Upvotes: 0
Views: 958
Reputation: 1408
I understand you want to modify the OpenSSL source code. In C programming it is not necessary that all the /h files should have a corresponding .c file.
There must be one to many mappings between header files and source files. Even though you din't have corresponding ec.c for ec.h file under OpenSSL, the functionalities declared in ec.h might be defined some where else(in any other source file of openSSL or some other dependency). Finally your OpenSSL binaries that is libeay.lib/.so and SSLeay.lib/.so (Considering linux platform) would have the symbols defined for the corresponding function declarations.
I assume you are trying to look into the system installed OpenSSL library where you would find only the header files and the binaries not the source code. You can download the OpenSSL source from the git repository and try to make the changes to the sources and build it.
As told earlier you may have the functions defined some where in source format or binary format so that the final output (binaries) got linked to the definitions.
Upvotes: 0
Reputation: 29017
For large library projects (like openssl) it is normal to put the header files in an include
directory, and the source files in a separate source directory. Client applications need the include files and the compiled library - but they don't need the library source files.
To answer your question:
https://github.com/openssl/openssl/blob/master/apps/ec.c
Also, the functions are not defined in ec.h
. They are declared there, and defined in the corresponding .c file. The distinction between declaration and definition is an important one in both C and C++.
Finally, there doesn't have to be a single ec.c
file corresponding to an ec.h
header. It's a common convention, but other libraries might be structured so that there was a single header (for ease of use by the user), but a number of separate source files (to help organize the library). So you might have ec_core.c
, ec_sign.c
, ec_encrypt.c
, ec_key_exchange.c
.
Upvotes: 1