Operating System - HP-UX
1753506 Members
5114 Online
108794 Solutions
New Discussion юеВ

Re: can't get new crypt2() function to work

 
SOLVED
Go to solution
kobylka
Valued Contributor

Re: can't get new crypt2() function to work

Hi!

I'm glad to see that it finally works. Congrats!

Kind regards,

Kobylka
d miller_2
Advisor

Re: can't get new crypt2() function to work

This solution finally worked:

# cat /tmp/encrypter.c
#include
#include
main()
{
char *username;
char *oldhash;
char *salt;
char *key;
char *hashstring;
username = "user1";
key = "mypass";
oldhash = "$6$"; /* "$6$" = SHA512, "aa" = 3DES */
salt = crypt2_passwd_salt(oldhash, username);
hashstring = crypt2(key, salt);
printf("username = %s\n", username);
printf("salt = %s\n", salt);
printf("key = %s\n", key);
printf("hashstring = %s\n", hashstring);
}

# cc +DD64 /tmp/encrypter.c -o /tmp/encrypter -L/usr/lib/hpux64 -lsec

# /tmp/encrypter
username = user1
salt = $6$VSw26.nD
key = mypass
hashstring = $6$VSw26.nD$yAt6TGoOlc9DLUY341qs0Kqo8D8HXFvZicqTSltK0z6ayTJ/dj9pn7RbH
Q8mhC.t7QabgjRUg0Ts/QnKcAm7A1

Dennis Handly
Acclaimed Contributor

Re: can't get new crypt2() function to work

>I'd give you 15 points for sticking with this issue through so many iterations.

You can give points that sum more than 10, if multiple replies.

>kobylka: find $l -name '*.sl' -exec nm {} \; -print | grep -i -e crypt2 -e '^/'

You may want to use:
nm -pxNA to do more than one lib at a time:
find $l -name "lib*" -exec nm -pxAN +

> -L/usr/lib/hpux32

There is no need to specify the default lib path with -L, remove it. Let the driver select the correct path.

>It should work using just -L/usr/lib too.

Not for Integrity, there are no libs there and Darren showed it failing.
kobylka
Valued Contributor

Re: can't get new crypt2() function to work

Hi!

> find $l -name "lib*" -exec nm -pxAN +

Thanks for pointing this out! The -A (-r) flags are quite useful in this situation!


> There is no need to specify the default lib path with -L, remove it. Let the driver select the correct path.

What confused me a lot was that:

# cc +DD64 /tmp/encrypter.c -o /tmp/encrypter -L/usr/lib -lsec

resulted in a library named libsec.sl on Itanium hardware trying to be linked.

So we went along using

# cc +DD64 /tmp/encrypter.c -o /tmp/encrypter -L/usr/lib/hpux64 -lsec

>>It should work using just -L/usr/lib too.

>Not for Integrity, there are no libs there and Darren showed it failing.

Thanks for clarification.


Dennis, always nice to meet you in posts :)

Kind regards,

Kobylka
d miller_2
Advisor

Re: can't get new crypt2() function to work

Thanks, guys, for continuing to post to this thread. Trying this one more time, I confirmed that -L/usr/lib doesn't work, while -L/usr/lib/hpux64 does:

# cc +DD64 /tmp/encrypter2.c -o /tmp/encrypter2 -L/usr/lib/ -lsec
ld: Mismatched ABI (not an ELF file) for -lsec, found /usr/lib//libsec.sl
Fatal error.

# cc +DD64 /tmp/encrypter2.c -o /tmp/encrypter2 -L/usr/lib/hpux64 -lsec

# echo $?
0

I wish the /usr/lib option DID work. I would rather not platform-specific compiler options in the instructions accompanying my program, but it looks like I'll have to.

Darren
Dennis Handly
Acclaimed Contributor

Re: can't get new crypt2() function to work

>I confirmed that -L/usr/lib doesn't work, while -L/usr/lib/hpux64 does:

Did you also confirm that you can leave out both?

>I wish the /usr/lib option DID work.

Why? There are no shlibs there for Integrity. And on Integrity, there can be 4 library directories.

>I would rather not platform-specific compiler options in the instructions accompanying my program

In this case you don't have too, since the driver will figure this out. And since +DD64 is already OS specific, the horse is already out of the barn.