Hello,
> Does somebody know how can I derive ks1,ks2 and ks3 shedules from password
> entered by command line:
> openssl enc -des3 -in pass.dec -out pass.enc -pass file:password.txt
To generate this input keys, IV to this key schedules function
EVP_BytesToKey() is used (example attached).
But I suggest to use PKCS5_PBKDF2_HMAC_SHA1() function.
> What's name is of cryptography library what openssl works with?
OpenSSL is crypto library itself.
Best regards,
Marek Marcola <[EMAIL PROTECTED]>
#include <string.h>
#include <openssl/evp.h>
#ifdef WIN32
typedef unsigned __int64 spc_uint64_t;
#else
typedef unsigned long long spc_uint64_t;
#endif
void spc_pbkdf2(unsigned char *pw, unsigned int pwlen, char *salt,
spc_uint64_t saltlen, unsigned int ic, unsigned char *dk,
spc_uint64_t dklen);
int main()
{
const EVP_CIPHER *cipher=EVP_aes_256_cbc();
const EVP_MD *dgst=EVP_sha1();
u_char pass[256];
char salt[256];
u_char key[256];
u_char iv[256];
int i;
printf("key_len: %d\n", cipher->key_len);
printf(" iv_len: %d\n", cipher->iv_len);
strcpy((char*)pass, "password");
strcpy((char*)salt, "ATHENA.MIT.EDUraeburn");
EVP_BytesToKey(cipher, dgst, salt, pass, strlen((char*)pass), 1, key, iv);
printf(" key:\n ");
for(i=0; i<cipher->key_len; i++){
printf("%02x", key[i]);
}
printf("\n");
printf(" iv:\n ");
for(i=0; i<cipher->iv_len; i++){
printf("%02x", iv[i]);
}
printf("\n");
spc_pbkdf2(pass, strlen((char*)pass), salt, strlen(salt), 1, key, 16);
//spc_pbkdf2(pass, strlen((char*)pass), salt, 8, 1, key, 16);
printf(" spc:\n ");
for(i=0; i<16; i++){
printf("%02x", key[i]);
}
printf("\n");
}