1831210 Members
2979 Online
110021 Solutions
New Discussion

bigcrypt

 
SOLVED
Go to solution
Nivesh Patnaik_1
Occasional Advisor

bigcrypt

I am trying to use bigcrypt(char*, char*);

Based on the man page, I include
#include
#include

When compiling using "cc myfl.c" I get
/usr/ccs/bin/ld: Unsatisfied symbols:
bigcrypt (first referenced in myfl.c)(code)


What library should I be referencing to get this to work?
Thanks.
10 REPLIES 10
Sandman!
Honored Contributor

Re: bigcrypt

Hi,

What's the command you are using for compiling the C source code.

thanks!
James R. Ferguson
Acclaimed Contributor

Re: bigcrypt

Hi:

#include
#include
#include
char *bigcrypt(char *key, char *salt);
void main()
{
printf( "I am alive\n" );
}

...compiles ok for me.

Regards!

...JRF...
Michael Schulte zur Sur
Honored Contributor

Re: bigcrypt

JRF,

don't you have to call the function to get a linker error?

greetings,

Michael
Nivesh Patnaik_1
Occasional Advisor

Re: bigcrypt

Here are the contents of myfl.c

#include
#include
main(argc,argv)
int argc;
char *argv[];

{
char encrypted[40];
strcpy(encrypted,(char *)bigcrypt(argv[1],argv[2]));
printf("%s",encrypted);
exit(0);
}


Here is how I compile it on a plain vanilla HP-UX 11.00 box...


# cc myfl.c
/usr/ccs/bin/ld: Unsatisfied symbols:
bigcrypt (first referenced in myfl.o) (code)
#

I can compile the code just fine if I use crypt() and include different header files, but crypt() limits the encryption of a string upto 8 chars in length, and I need it to encrypt a bigger string for password encryption.
James R. Ferguson
Acclaimed Contributor

Re: bigcrypt

Hi (again):

Yes, of course I have to call the function to see the error --- I was just not thinking!

I too can reproduce the error. Sorry.

Regards!

...JRF...
Michael Schulte zur Sur
Honored Contributor

Re: bigcrypt

HI,

I guess you need to link the lib with bigcrypt to the program. Have a look at
http://web.mit.edu/ghudson/dev/xscreensaver-import/xscreensaver-4.14/driver/passwd-pwent.c

greetings,

Michael
Nivesh Patnaik_1
Occasional Advisor

Re: bigcrypt

I have looked at the code in the link above and tried including every header file applicable, with no luck. I still do not know what library file (under /usr/lib) contains bigcrypt so I don't know what to use with the -l option.

When I try an assortment of -L and -l options, for example
# cc myfl.c -L /usr/lib -l libc.2
/usr/ccs/bin/ld: Can't find library: "libc.2"

So I don't know if I need to setup environment variables...I have even tried
export LD_LIBRARY_PATH=/usr/lib
export SHLIB_PATH=/usr/lib

but that doesn't solve the "Can't find library" issue.
Sandman!
Honored Contributor
Solution

Re: bigcrypt

Hi Nivesh,

Your code is fine (although not ANSI C compliant). In order to use the bigcrypt API you need to link your source code with the shared version of the security library i.e. /usr/lib/libsec.sl. So your command for compilation should be:

# cc myfl.c -o myfl -lsec

Suggest changing...
>>printf("%s",encrypted);<<
TO
printf("%s\n",encrypted);

cheers!
Nivesh Patnaik_1
Occasional Advisor

Re: bigcrypt

Thanks Sandman, that did it!
Before I saw your reply, I was doing strings on every file under /usr/lib/ and grepping for bigcrypt and found libsec.2 had it.
I tried -llibsec.2 and it didn't work, and I wouldn't have know to use -lsec.
Thanks so much for the solution.
Nivesh Patnaik_1
Occasional Advisor

Re: bigcrypt

Sandman gave the solution. Thanks!