69 void h__dump (
unsigned char *
p,
int len);
74 #define min(a,b) ((a) < (b) ? (a) : (b))
78 int saltlen,
int id,
int iter,
int n,
unsigned char *out,
82 unsigned char *unipass;
93 id, iter, n, out, md_type);
104 int saltlen,
int id,
int iter,
int n,
unsigned char *out,
107 unsigned char *
B, *D, *
I, *
p, *Ai;
108 int Slen, Plen, Ilen, Ijlen;
114 unsigned char *tmpout = out;
127 fprintf(stderr,
"KEYGEN DEBUG\n");
128 fprintf(stderr,
"ID %d, ITER %d\n",
id, iter);
129 fprintf(stderr,
"Password (length %d):\n", passlen);
130 h__dump(pass, passlen);
131 fprintf(stderr,
"Salt (length %d):\n", saltlen);
132 h__dump(salt, saltlen);
141 Slen = v * ((saltlen+v-1)/v);
142 if(passlen) Plen = v * ((passlen+v-1)/v);
148 if (!D || !Ai || !B || !I || !Ij || !Bpl1)
150 for (i = 0; i < v; i++) D[i] =
id;
152 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen];
153 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen];
160 for (j = 1; j < iter; j++) {
166 memcpy (out, Ai,
min (n, u));
169 fprintf(stderr,
"Output KEY (length %d)\n", tmpn);
170 h__dump(tmpout, tmpn);
177 for (j = 0; j < v; j++) B[j] = Ai[j % u];
181 for (j = 0; j < Ilen ; j+=v) {
183 if (!
BN_add (Ij, Ij, Bpl1))
goto err;
189 memcpy (I + j, B + 1, v);
190 #ifndef PKCS12_BROKEN_KEYGEN
192 }
else if (Ijlen < v) {
193 memset(I + j, 0, v - Ijlen);
214 void h__dump (
unsigned char *
p,
int len)
216 for (; len --; p++) fprintf(stderr,
"%02X", *p);
217 fprintf(stderr,
"\n");