[openssl-dev] Linker error when adding new cipher in crypto folder

Schmicker, Robert rschm2 at unh.newhaven.edu
Tue Jan 10 16:15:22 UTC 2017


rschm2> Hello,
rschm2>
rschm2> I am attempting to add a new cipher into the crypto library. I have
rschm2> done the following so far?
rschm2>
rschm2> 1. Added my code to the openssl/crypto folder
rschm2> 2. Created a build.info<http://build.info> for make to compile my code (created this
rschm2> based off of openssl/crypto/dh?s build.info<http://build.info>)
rschm2> 3. Added my cipher name to the list of ciphers to compile in Configure
rschm2> 4. Compiled and installed all code without errors and object files for
rschm2> my new cipher are created in openssl/crypto/mycipher/
rschm2> 5. Created a test.c file that verifies that the library is installed
rschm2> and working properly by generating a MD5 hash of a string
rschm2> Compiled as:
rschm2> gcc test.c -I/usr/local/openssl/include/openssl/ -o test -lcrypto -
rschm2> lssl -Wall
rschm2> 6. I am able to properly include <openssl/mycipher.h> in my test.c
rschm2> file
rschm2>
rschm2> However, as soon as I make a call to my cipher in test.c I get a
rschm2> linker error and gcc is unable to find any of my functions.
rschm2>
rschm2> It seems that the header file I have in the openssl/include folder
rschm2> isn?t being linked somehow to my code in the openssl/cypto folder.
rschm2>
rschm2> I feel like I?m missing a step here?
rschm2>
rschm2> Any help is much appreciated!

levitte>On way is to, as already mentioned, edit util/libcrypto.num.  The
levitte>other is to edit util/mkdef.pl and then run 'make update'.  In
levitte>mkdef.pl, you'll find a bunch of lines like this:

levitte>   $crypto.="include/openssl/whatever.h"

levitte>Simply add a line like that for mycipher.h.

levitte>(note: mkdef.pl might be a bit picky sometimes)

levitte>Cheers,
levitte>Richard

levitte>--
levitte>Richard Levitte         levitte at openssl.org<mailto:levitte at openssl.org>
levitte>OpenSSL Project         http://www.openssl.org/~levitte/

Hello,

I would just like to thank Richard Levitte and Viktor for their help as I was finally able to figure it out. In case anyone else would like this same process I have included some general documentation below:

1) git clone openssl project
2) edit util/mkdef.pl<http://util/mkdef.pl> for <openssl/mycipher.h> header file (header file must be extern and have (void) in function declaration if no arguments are being passed)
3) edit Configure (line 313ish) and add in crypto function amongst others
4) create build.info<http://build.info/> under /crypto/mycipher/ (follow other crypto build.info<http://build.info>’s to create)
5) ./config
6) make update
7) make -j <thread count>

Rob

On Dec 31, 2016, at 5:52 PM, openssl-dev-request at openssl.org<mailto:openssl-dev-request at openssl.org> wrote:

Re: Linker error when adding new cipher in crypto folder

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-dev/attachments/20170110/23e36120/attachment.html>


More information about the openssl-dev mailing list