61 #if !defined(OPENSSL_NO_HMAC) && !defined(OPENSSL_NO_SHA)
71 static void h__dump (
const unsigned char *
p,
int len);
81 const unsigned char *salt,
int saltlen,
int iter,
83 int keylen,
unsigned char *out)
86 int cplen, j,
k, tkeylen, mdlen;
99 else if(passlen == -1)
100 passlen = strlen(pass);
110 itmp[0] = (
unsigned char)((i >> 24) & 0xff);
111 itmp[1] = (
unsigned char)((i >> 16) & 0xff);
112 itmp[2] = (
unsigned char)((i >> 8) & 0xff);
113 itmp[3] = (
unsigned char)(i & 0xff);
122 memcpy(p, digtmp, cplen);
123 for(j = 1; j < iter; j++)
125 HMAC(digest, pass, passlen,
126 digtmp, mdlen, digtmp, NULL);
127 for(k = 0; k < cplen; k++)
136 fprintf(stderr,
"Password:\n");
137 h__dump (pass, passlen);
138 fprintf(stderr,
"Salt:\n");
139 h__dump (salt, saltlen);
140 fprintf(stderr,
"Iteration count %d\n", iter);
141 fprintf(stderr,
"Key:\n");
142 h__dump (out, keylen);
148 const unsigned char *salt,
int saltlen,
int iter,
149 int keylen,
unsigned char *out)
158 unsigned char out[4];
159 unsigned char salt[] = {0x12, 0x34, 0x56, 0x78};
161 fprintf(stderr,
"Out %02X %02X %02X %02X\n",
162 out[0], out[1], out[2], out[3]);
176 const unsigned char *pbuf;
191 if(!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
226 PBE2PARAM_free(pbe2);
235 const unsigned char *pbuf;
236 int saltlen, iter, plen;
238 unsigned int keylen = 0;
239 int prf_nid, hmac_md_nid;
262 if(!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) {
311 PBKDF2PARAM_free(kdf);
316 static void h__dump (
const unsigned char *
p,
int len)
318 for (; len --; p++) fprintf(stderr,
"%02X ", *p);
319 fprintf(stderr,
"\n");