Calculating HMAC for a key based on password and salt

Lahiru Dissanayake <[email protected]> Wed, 13 Mar 2013 12:48:26 +0800
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <CAHeAcfDMsmXHw7=A5mSofvdHpMVtJYOEce3HW6ch5KHwjpWBUQ@mail.gmail.com>
Hi,

I need to compute the HMAC of a message using a key that's derived from a
password and a salt. I tried,

char *password = "password";
char *salt = "12345678";

CRYPT_CONTEXT keyContext;
int status = cryptCreateContext(&keyContext, CRYPT_UNUSED,
CRYPT_ALGO_HMAC_SHA2);
status = cryptSetAttribute(keyContext, CRYPT_CTXINFO_KEYING_ITERATIONS, 2000
);
status = cryptSetAttributeString(keyContext, CRYPT_CTXINFO_KEYING_SALT,
salt, strlen(salt));
status = cryptSetAttributeString(keyContext, CRYPT_CTXINFO_KEYING_VALUE,
password, strlen(password));

However I get -16 as the status of the last statement. Are password based
keys not meant to be used with HMAC in Cryptlib, or am I doing something
wrong?

Thanks,
Lahiru

_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.