summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs12')
-rw-r--r--src/lib/libcrypto/pkcs12/Makefile286
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c38
2 files changed, 302 insertions, 22 deletions
diff --git a/src/lib/libcrypto/pkcs12/Makefile b/src/lib/libcrypto/pkcs12/Makefile
new file mode 100644
index 0000000000..3a7498fe7a
--- /dev/null
+++ b/src/lib/libcrypto/pkcs12/Makefile
@@ -0,0 +1,286 @@
1#
2# OpenSSL/crypto/pkcs12/Makefile
3#
4
5DIR= pkcs12
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC= p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c \
21 p12_init.c p12_key.c p12_kiss.c p12_mutl.c\
22 p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c
23LIBOBJ= p12_add.o p12_asn.o p12_attr.o p12_crpt.o p12_crt.o p12_decr.o \
24 p12_init.o p12_key.o p12_kiss.o p12_mutl.o\
25 p12_utl.o p12_npas.o pk12err.o p12_p8d.o p12_p8e.o
26
27SRC= $(LIBSRC)
28
29EXHEADER= pkcs12.h
30HEADER= $(EXHEADER)
31
32ALL= $(GENERAL) $(SRC) $(HEADER)
33
34top:
35 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
36
37test:
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
48
49links:
50 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
51 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
52 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
53
54install:
55 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
56 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
73
74dclean:
75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE)
77
78clean:
79 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81# DO NOT DELETE THIS LINE -- make depend depends on it.
82
83p12_add.o: ../../e_os.h ../../include/openssl/asn1.h
84p12_add.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
85p12_add.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
86p12_add.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
87p12_add.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
88p12_add.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
89p12_add.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
90p12_add.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
91p12_add.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
92p12_add.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
93p12_add.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
94p12_add.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
95p12_add.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_add.c
96p12_asn.o: ../../e_os.h ../../include/openssl/asn1.h
97p12_asn.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
98p12_asn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
99p12_asn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
100p12_asn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
101p12_asn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
102p12_asn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
103p12_asn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
104p12_asn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
105p12_asn.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
106p12_asn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
107p12_asn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
108p12_asn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
109p12_asn.o: ../cryptlib.h p12_asn.c
110p12_attr.o: ../../e_os.h ../../include/openssl/asn1.h
111p12_attr.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
112p12_attr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
113p12_attr.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
114p12_attr.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
115p12_attr.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
116p12_attr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
117p12_attr.o: ../../include/openssl/opensslconf.h
118p12_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
119p12_attr.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
120p12_attr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
121p12_attr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
122p12_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
123p12_attr.o: ../cryptlib.h p12_attr.c
124p12_crpt.o: ../../e_os.h ../../include/openssl/asn1.h
125p12_crpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
126p12_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
127p12_crpt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
128p12_crpt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
129p12_crpt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
130p12_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
131p12_crpt.o: ../../include/openssl/opensslconf.h
132p12_crpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
133p12_crpt.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
134p12_crpt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
135p12_crpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
136p12_crpt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
137p12_crpt.o: ../cryptlib.h p12_crpt.c
138p12_crt.o: ../../e_os.h ../../include/openssl/asn1.h
139p12_crt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
140p12_crt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
141p12_crt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
142p12_crt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
143p12_crt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
144p12_crt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
145p12_crt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
146p12_crt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
147p12_crt.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
148p12_crt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
149p12_crt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
150p12_crt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_crt.c
151p12_decr.o: ../../e_os.h ../../include/openssl/asn1.h
152p12_decr.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
153p12_decr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
154p12_decr.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
155p12_decr.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
156p12_decr.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
157p12_decr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
158p12_decr.o: ../../include/openssl/opensslconf.h
159p12_decr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
160p12_decr.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
161p12_decr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
162p12_decr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
163p12_decr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
164p12_decr.o: ../cryptlib.h p12_decr.c
165p12_init.o: ../../e_os.h ../../include/openssl/asn1.h
166p12_init.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
167p12_init.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
168p12_init.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
169p12_init.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
170p12_init.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
171p12_init.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
172p12_init.o: ../../include/openssl/opensslconf.h
173p12_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
174p12_init.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
175p12_init.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
176p12_init.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
177p12_init.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
178p12_init.o: ../cryptlib.h p12_init.c
179p12_key.o: ../../e_os.h ../../include/openssl/asn1.h
180p12_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
181p12_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
182p12_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
183p12_key.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
184p12_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h
185p12_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
186p12_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
187p12_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
188p12_key.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
189p12_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
190p12_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
191p12_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
192p12_key.o: ../cryptlib.h p12_key.c
193p12_kiss.o: ../../e_os.h ../../include/openssl/asn1.h
194p12_kiss.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
195p12_kiss.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
196p12_kiss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
197p12_kiss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
198p12_kiss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
199p12_kiss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
200p12_kiss.o: ../../include/openssl/opensslconf.h
201p12_kiss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
202p12_kiss.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
203p12_kiss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
204p12_kiss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
205p12_kiss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
206p12_kiss.o: ../cryptlib.h p12_kiss.c
207p12_mutl.o: ../../e_os.h ../../include/openssl/asn1.h
208p12_mutl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
209p12_mutl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
210p12_mutl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
211p12_mutl.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
212p12_mutl.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
213p12_mutl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
214p12_mutl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
215p12_mutl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
216p12_mutl.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
217p12_mutl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
218p12_mutl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
219p12_mutl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
220p12_mutl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_mutl.c
221p12_npas.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
222p12_npas.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
223p12_npas.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
224p12_npas.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
225p12_npas.o: ../../include/openssl/err.h ../../include/openssl/evp.h
226p12_npas.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
227p12_npas.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
228p12_npas.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
229p12_npas.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
230p12_npas.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
231p12_npas.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
232p12_npas.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
233p12_npas.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
234p12_npas.o: p12_npas.c
235p12_p8d.o: ../../e_os.h ../../include/openssl/asn1.h
236p12_p8d.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
237p12_p8d.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
238p12_p8d.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
239p12_p8d.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
240p12_p8d.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
241p12_p8d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
242p12_p8d.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
243p12_p8d.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
244p12_p8d.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
245p12_p8d.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
246p12_p8d.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
247p12_p8d.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_p8d.c
248p12_p8e.o: ../../e_os.h ../../include/openssl/asn1.h
249p12_p8e.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
250p12_p8e.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
251p12_p8e.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
252p12_p8e.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
253p12_p8e.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
254p12_p8e.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
255p12_p8e.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
256p12_p8e.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
257p12_p8e.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
258p12_p8e.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
259p12_p8e.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
260p12_p8e.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_p8e.c
261p12_utl.o: ../../e_os.h ../../include/openssl/asn1.h
262p12_utl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
263p12_utl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
264p12_utl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
265p12_utl.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
266p12_utl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
267p12_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
268p12_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
269p12_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
270p12_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
271p12_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
272p12_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
273p12_utl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_utl.c
274pk12err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
275pk12err.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
276pk12err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
277pk12err.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
278pk12err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
279pk12err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
280pk12err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
281pk12err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
282pk12err.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
283pk12err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
284pk12err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
285pk12err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
286pk12err.o: pk12err.c
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 424203f648..a29794bbbc 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -107,7 +107,6 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
107 unsigned char *B, *D, *I, *p, *Ai; 107 unsigned char *B, *D, *I, *p, *Ai;
108 int Slen, Plen, Ilen, Ijlen; 108 int Slen, Plen, Ilen, Ijlen;
109 int i, j, u, v; 109 int i, j, u, v;
110 int ret = 0;
111 BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */ 110 BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */
112 EVP_MD_CTX ctx; 111 EVP_MD_CTX ctx;
113#ifdef DEBUG_KEYGEN 112#ifdef DEBUG_KEYGEN
@@ -145,8 +144,10 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
145 I = OPENSSL_malloc (Ilen); 144 I = OPENSSL_malloc (Ilen);
146 Ij = BN_new(); 145 Ij = BN_new();
147 Bpl1 = BN_new(); 146 Bpl1 = BN_new();
148 if (!D || !Ai || !B || !I || !Ij || !Bpl1) 147 if (!D || !Ai || !B || !I || !Ij || !Bpl1) {
149 goto err; 148 PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI,ERR_R_MALLOC_FAILURE);
149 return 0;
150 }
150 for (i = 0; i < v; i++) D[i] = id; 151 for (i = 0; i < v; i++) D[i] = id;
151 p = I; 152 p = I;
152 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; 153 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen];
@@ -163,22 +164,28 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
163 } 164 }
164 memcpy (out, Ai, min (n, u)); 165 memcpy (out, Ai, min (n, u));
165 if (u >= n) { 166 if (u >= n) {
167 OPENSSL_free (Ai);
168 OPENSSL_free (B);
169 OPENSSL_free (D);
170 OPENSSL_free (I);
171 BN_free (Ij);
172 BN_free (Bpl1);
173 EVP_MD_CTX_cleanup(&ctx);
166#ifdef DEBUG_KEYGEN 174#ifdef DEBUG_KEYGEN
167 fprintf(stderr, "Output KEY (length %d)\n", tmpn); 175 fprintf(stderr, "Output KEY (length %d)\n", tmpn);
168 h__dump(tmpout, tmpn); 176 h__dump(tmpout, tmpn);
169#endif 177#endif
170 ret = 1; 178 return 1;
171 goto end;
172 } 179 }
173 n -= u; 180 n -= u;
174 out += u; 181 out += u;
175 for (j = 0; j < v; j++) B[j] = Ai[j % u]; 182 for (j = 0; j < v; j++) B[j] = Ai[j % u];
176 /* Work out B + 1 first then can use B as tmp space */ 183 /* Work out B + 1 first then can use B as tmp space */
177 if (!BN_bin2bn (B, v, Bpl1)) goto err; 184 BN_bin2bn (B, v, Bpl1);
178 if (!BN_add_word (Bpl1, 1)) goto err; 185 BN_add_word (Bpl1, 1);
179 for (j = 0; j < Ilen ; j+=v) { 186 for (j = 0; j < Ilen ; j+=v) {
180 if (!BN_bin2bn (I + j, v, Ij)) goto err; 187 BN_bin2bn (I + j, v, Ij);
181 if (!BN_add (Ij, Ij, Bpl1)) goto err; 188 BN_add (Ij, Ij, Bpl1);
182 BN_bn2bin (Ij, B); 189 BN_bn2bin (Ij, B);
183 Ijlen = BN_num_bytes (Ij); 190 Ijlen = BN_num_bytes (Ij);
184 /* If more than 2^(v*8) - 1 cut off MSB */ 191 /* If more than 2^(v*8) - 1 cut off MSB */
@@ -194,19 +201,6 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
194 } else BN_bn2bin (Ij, I + j); 201 } else BN_bn2bin (Ij, I + j);
195 } 202 }
196 } 203 }
197
198err:
199 PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI,ERR_R_MALLOC_FAILURE);
200
201end:
202 OPENSSL_free (Ai);
203 OPENSSL_free (B);
204 OPENSSL_free (D);
205 OPENSSL_free (I);
206 BN_free (Ij);
207 BN_free (Bpl1);
208 EVP_MD_CTX_cleanup(&ctx);
209 return ret;
210} 204}
211#ifdef DEBUG_KEYGEN 205#ifdef DEBUG_KEYGEN
212void h__dump (unsigned char *p, int len) 206void h__dump (unsigned char *p, int len)