summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormarkus <>2003-05-11 21:36:58 +0000
committermarkus <>2003-05-11 21:36:58 +0000
commit5e3b0c7b72d8aaff81be19f7eb4d18887c9b628e (patch)
tree856136ff65a464744cae1b12c4aa538694a479c6 /src
parent122b1fe1ae368cb84ac4ef26348c8944757cb720 (diff)
parent1c98a87f0daac81245653c227eb2f2508a22a965 (diff)
downloadopenbsd-5e3b0c7b72d8aaff81be19f7eb4d18887c9b628e.tar.gz
openbsd-5e3b0c7b72d8aaff81be19f7eb4d18887c9b628e.tar.bz2
openbsd-5e3b0c7b72d8aaff81be19f7eb4d18887c9b628e.zip
This commit was generated by cvs2git to track changes on a CVS vendor
branch.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/asm/x86_64-gcc.c575
-rw-r--r--src/lib/libcrypto/doc/EVP_PKEY_new.pod47
-rw-r--r--src/lib/libcrypto/doc/EVP_PKEY_set1_RSA.pod80
-rw-r--r--src/lib/libcrypto/doc/OBJ_nid2obj.pod149
-rw-r--r--src/lib/libcrypto/doc/PKCS12_create.pod57
-rw-r--r--src/lib/libcrypto/doc/PKCS12_parse.pod50
-rw-r--r--src/lib/libcrypto/doc/PKCS7_decrypt.pod53
-rw-r--r--src/lib/libcrypto/doc/PKCS7_encrypt.pod65
-rw-r--r--src/lib/libcrypto/doc/PKCS7_sign.pod85
-rw-r--r--src/lib/libcrypto/doc/PKCS7_verify.pod116
-rw-r--r--src/lib/libcrypto/doc/SMIME_read_PKCS7.pod71
-rw-r--r--src/lib/libcrypto/doc/SMIME_write_PKCS7.pod59
-rw-r--r--src/lib/libcrypto/doc/X509_NAME_ENTRY_get_object.pod72
-rw-r--r--src/lib/libcrypto/doc/X509_NAME_add_entry_by_txt.pod110
-rw-r--r--src/lib/libcrypto/doc/X509_NAME_get_index_by_NID.pod106
-rw-r--r--src/lib/libcrypto/doc/X509_NAME_print_ex.pod105
-rw-r--r--src/lib/libcrypto/doc/X509_new.pod37
-rw-r--r--src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod29
-rw-r--r--src/lib/libcrypto/doc/d2i_DSAPublicKey.pod82
-rw-r--r--src/lib/libcrypto/doc/d2i_X509.pod231
-rw-r--r--src/lib/libcrypto/doc/d2i_X509_ALGOR.pod30
-rw-r--r--src/lib/libcrypto/doc/d2i_X509_CRL.pod37
-rw-r--r--src/lib/libcrypto/doc/d2i_X509_NAME.pod31
-rw-r--r--src/lib/libcrypto/doc/d2i_X509_REQ.pod36
-rw-r--r--src/lib/libcrypto/doc/d2i_X509_SIG.pod30
-rw-r--r--src/lib/libcrypto/doc/engine.pod12
-rw-r--r--src/lib/libcrypto/mem_clr.c75
27 files changed, 2424 insertions, 6 deletions
diff --git a/src/lib/libcrypto/bn/asm/x86_64-gcc.c b/src/lib/libcrypto/bn/asm/x86_64-gcc.c
new file mode 100644
index 0000000000..b97b394661
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/x86_64-gcc.c
@@ -0,0 +1,575 @@
1/*
2 * x86_64 BIGNUM accelerator version 0.1, December 2002.
3 *
4 * Implemented by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5 * project.
6 *
7 * Rights for redistribution and usage in source and binary forms are
8 * granted according to the OpenSSL license. Warranty of any kind is
9 * disclaimed.
10 *
11 * Q. Version 0.1? It doesn't sound like Andy, he used to assign real
12 * versions, like 1.0...
13 * A. Well, that's because this code is basically a quick-n-dirty
14 * proof-of-concept hack. As you can see it's implemented with
15 * inline assembler, which means that you're bound to GCC and that
16 * there must be a room for fine-tuning.
17 *
18 * Q. Why inline assembler?
19 * A. x86_64 features own ABI I'm not familiar with. Which is why
20 * I decided to let the compiler take care of subroutine
21 * prologue/epilogue as well as register allocation.
22 *
23 * Q. How much faster does it get?
24 * A. Unfortunately people sitting on x86_64 hardware are prohibited
25 * to disclose the performance numbers, so they (SuSE labs to be
26 * specific) wouldn't tell me. However! Very similar coding technique
27 * (reaching out for 128-bit result from 64x64-bit multiplication)
28 * results in >3 times performance improvement on MIPS and I see no
29 * reason why gain on x86_64 would be so much different:-)
30 */
31
32#define BN_ULONG unsigned long
33
34/*
35 * "m"(a), "+m"(r) is the way to favor DirectPath µ-code;
36 * "g"(0) let the compiler to decide where does it
37 * want to keep the value of zero;
38 */
39#define mul_add(r,a,word,carry) do { \
40 register BN_ULONG high,low; \
41 asm ("mulq %3" \
42 : "=a"(low),"=d"(high) \
43 : "a"(word),"m"(a) \
44 : "cc"); \
45 asm ("addq %2,%0; adcq %3,%1" \
46 : "+r"(carry),"+d"(high)\
47 : "a"(low),"g"(0) \
48 : "cc"); \
49 asm ("addq %2,%0; adcq %3,%1" \
50 : "+m"(r),"+d"(high) \
51 : "r"(carry),"g"(0) \
52 : "cc"); \
53 carry=high; \
54 } while (0)
55
56#define mul(r,a,word,carry) do { \
57 register BN_ULONG high,low; \
58 asm ("mulq %3" \
59 : "=a"(low),"=d"(high) \
60 : "a"(word),"g"(a) \
61 : "cc"); \
62 asm ("addq %2,%0; adcq %3,%1" \
63 : "+r"(carry),"+d"(high)\
64 : "a"(low),"g"(0) \
65 : "cc"); \
66 (r)=carry, carry=high; \
67 } while (0)
68
69#define sqr(r0,r1,a) \
70 asm ("mulq %2" \
71 : "=a"(r0),"=d"(r1) \
72 : "a"(a) \
73 : "cc");
74
75BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
76 {
77 BN_ULONG c1=0;
78
79 if (num <= 0) return(c1);
80
81 while (num&~3)
82 {
83 mul_add(rp[0],ap[0],w,c1);
84 mul_add(rp[1],ap[1],w,c1);
85 mul_add(rp[2],ap[2],w,c1);
86 mul_add(rp[3],ap[3],w,c1);
87 ap+=4; rp+=4; num-=4;
88 }
89 if (num)
90 {
91 mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
92 mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
93 mul_add(rp[2],ap[2],w,c1); return c1;
94 }
95
96 return(c1);
97 }
98
99BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
100 {
101 BN_ULONG c1=0;
102
103 if (num <= 0) return(c1);
104
105 while (num&~3)
106 {
107 mul(rp[0],ap[0],w,c1);
108 mul(rp[1],ap[1],w,c1);
109 mul(rp[2],ap[2],w,c1);
110 mul(rp[3],ap[3],w,c1);
111 ap+=4; rp+=4; num-=4;
112 }
113 if (num)
114 {
115 mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
116 mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
117 mul(rp[2],ap[2],w,c1);
118 }
119 return(c1);
120 }
121
122void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
123 {
124 if (n <= 0) return;
125
126 while (n&~3)
127 {
128 sqr(r[0],r[1],a[0]);
129 sqr(r[2],r[3],a[1]);
130 sqr(r[4],r[5],a[2]);
131 sqr(r[6],r[7],a[3]);
132 a+=4; r+=8; n-=4;
133 }
134 if (n)
135 {
136 sqr(r[0],r[1],a[0]); if (--n == 0) return;
137 sqr(r[2],r[3],a[1]); if (--n == 0) return;
138 sqr(r[4],r[5],a[2]);
139 }
140 }
141
142BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
143{ BN_ULONG ret,waste;
144
145 asm ("divq %3"
146 : "=a"(ret),"=d"(waste)
147 : "a"(l),"d"(h),"g"(d)
148 : "cc");
149
150 return ret;
151}
152
153BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int n)
154{ BN_ULONG ret,i;
155
156 if (n <= 0) return 0;
157
158 asm (
159 " subq %2,%2 \n"
160 ".align 16 \n"
161 "1: movq (%4,%2,8),%0 \n"
162 " adcq (%5,%2,8),%0 \n"
163 " movq %0,(%3,%2,8) \n"
164 " leaq 1(%2),%2 \n"
165 " loop 1b \n"
166 " sbbq %0,%0 \n"
167 : "+a"(ret),"+c"(n),"+r"(i)
168 : "r"(rp),"r"(ap),"r"(bp)
169 : "cc"
170 );
171
172 return ret&1;
173}
174
175#ifndef SIMICS
176BN_ULONG bn_sub_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int n)
177{ BN_ULONG ret,i;
178
179 if (n <= 0) return 0;
180
181 asm (
182 " subq %2,%2 \n"
183 ".align 16 \n"
184 "1: movq (%4,%2,8),%0 \n"
185 " sbbq (%5,%2,8),%0 \n"
186 " movq %0,(%3,%2,8) \n"
187 " leaq 1(%2),%2 \n"
188 " loop 1b \n"
189 " sbbq %0,%0 \n"
190 : "+a"(ret),"+c"(n),"+r"(i)
191 : "r"(rp),"r"(ap),"r"(bp)
192 : "cc"
193 );
194
195 return ret&1;
196}
197#else
198/* Simics 1.4<7 has buggy sbbq:-( */
199#define BN_MASK2 0xffffffffffffffffL
200BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
201 {
202 BN_ULONG t1,t2;
203 int c=0;
204
205 if (n <= 0) return((BN_ULONG)0);
206
207 for (;;)
208 {
209 t1=a[0]; t2=b[0];
210 r[0]=(t1-t2-c)&BN_MASK2;
211 if (t1 != t2) c=(t1 < t2);
212 if (--n <= 0) break;
213
214 t1=a[1]; t2=b[1];
215 r[1]=(t1-t2-c)&BN_MASK2;
216 if (t1 != t2) c=(t1 < t2);
217 if (--n <= 0) break;
218
219 t1=a[2]; t2=b[2];
220 r[2]=(t1-t2-c)&BN_MASK2;
221 if (t1 != t2) c=(t1 < t2);
222 if (--n <= 0) break;
223
224 t1=a[3]; t2=b[3];
225 r[3]=(t1-t2-c)&BN_MASK2;
226 if (t1 != t2) c=(t1 < t2);
227 if (--n <= 0) break;
228
229 a+=4;
230 b+=4;
231 r+=4;
232 }
233 return(c);
234 }
235#endif
236
237/* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */
238/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */
239/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
240/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
241
242#if 0
243/* original macros are kept for reference purposes */
244#define mul_add_c(a,b,c0,c1,c2) { \
245 BN_ULONG ta=(a),tb=(b); \
246 t1 = ta * tb; \
247 t2 = BN_UMULT_HIGH(ta,tb); \
248 c0 += t1; t2 += (c0<t1)?1:0; \
249 c1 += t2; c2 += (c1<t2)?1:0; \
250 }
251
252#define mul_add_c2(a,b,c0,c1,c2) { \
253 BN_ULONG ta=(a),tb=(b),t0; \
254 t1 = BN_UMULT_HIGH(ta,tb); \
255 t0 = ta * tb; \
256 t2 = t1+t1; c2 += (t2<t1)?1:0; \
257 t1 = t0+t0; t2 += (t1<t0)?1:0; \
258 c0 += t1; t2 += (c0<t1)?1:0; \
259 c1 += t2; c2 += (c1<t2)?1:0; \
260 }
261#else
262#define mul_add_c(a,b,c0,c1,c2) do { \
263 asm ("mulq %3" \
264 : "=a"(t1),"=d"(t2) \
265 : "a"(a),"m"(b) \
266 : "cc"); \
267 asm ("addq %2,%0; adcq %3,%1" \
268 : "+r"(c0),"+d"(t2) \
269 : "a"(t1),"g"(0) \
270 : "cc"); \
271 asm ("addq %2,%0; adcq %3,%1" \
272 : "+r"(c1),"+r"(c2) \
273 : "d"(t2),"g"(0) \
274 : "cc"); \
275 } while (0)
276
277#define sqr_add_c(a,i,c0,c1,c2) do { \
278 asm ("mulq %2" \
279 : "=a"(t1),"=d"(t2) \
280 : "a"(a[i]) \
281 : "cc"); \
282 asm ("addq %2,%0; adcq %3,%1" \
283 : "+r"(c0),"+d"(t2) \
284 : "a"(t1),"g"(0) \
285 : "cc"); \
286 asm ("addq %2,%0; adcq %3,%1" \
287 : "+r"(c1),"+r"(c2) \
288 : "d"(t2),"g"(0) \
289 : "cc"); \
290 } while (0)
291
292#define mul_add_c2(a,b,c0,c1,c2) do { \
293 asm ("mulq %3" \
294 : "=a"(t1),"=d"(t2) \
295 : "a"(a),"m"(b) \
296 : "cc"); \
297 asm ("addq %0,%0; adcq %2,%1" \
298 : "+d"(t2),"+r"(c2) \
299 : "g"(0) \
300 : "cc"); \
301 asm ("addq %0,%0; adcq %2,%1" \
302 : "+a"(t1),"+d"(t2) \
303 : "g"(0) \
304 : "cc"); \
305 asm ("addq %2,%0; adcq %3,%1" \
306 : "+r"(c0),"+d"(t2) \
307 : "a"(t1),"g"(0) \
308 : "cc"); \
309 asm ("addq %2,%0; adcq %3,%1" \
310 : "+r"(c1),"+r"(c2) \
311 : "d"(t2),"g"(0) \
312 : "cc"); \
313 } while (0)
314#endif
315
316#define sqr_add_c2(a,i,j,c0,c1,c2) \
317 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
318
319void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
320 {
321 BN_ULONG bl,bh;
322 BN_ULONG t1,t2;
323 BN_ULONG c1,c2,c3;
324
325 c1=0;
326 c2=0;
327 c3=0;
328 mul_add_c(a[0],b[0],c1,c2,c3);
329 r[0]=c1;
330 c1=0;
331 mul_add_c(a[0],b[1],c2,c3,c1);
332 mul_add_c(a[1],b[0],c2,c3,c1);
333 r[1]=c2;
334 c2=0;
335 mul_add_c(a[2],b[0],c3,c1,c2);
336 mul_add_c(a[1],b[1],c3,c1,c2);
337 mul_add_c(a[0],b[2],c3,c1,c2);
338 r[2]=c3;
339 c3=0;
340 mul_add_c(a[0],b[3],c1,c2,c3);
341 mul_add_c(a[1],b[2],c1,c2,c3);
342 mul_add_c(a[2],b[1],c1,c2,c3);
343 mul_add_c(a[3],b[0],c1,c2,c3);
344 r[3]=c1;
345 c1=0;
346 mul_add_c(a[4],b[0],c2,c3,c1);
347 mul_add_c(a[3],b[1],c2,c3,c1);
348 mul_add_c(a[2],b[2],c2,c3,c1);
349 mul_add_c(a[1],b[3],c2,c3,c1);
350 mul_add_c(a[0],b[4],c2,c3,c1);
351 r[4]=c2;
352 c2=0;
353 mul_add_c(a[0],b[5],c3,c1,c2);
354 mul_add_c(a[1],b[4],c3,c1,c2);
355 mul_add_c(a[2],b[3],c3,c1,c2);
356 mul_add_c(a[3],b[2],c3,c1,c2);
357 mul_add_c(a[4],b[1],c3,c1,c2);
358 mul_add_c(a[5],b[0],c3,c1,c2);
359 r[5]=c3;
360 c3=0;
361 mul_add_c(a[6],b[0],c1,c2,c3);
362 mul_add_c(a[5],b[1],c1,c2,c3);
363 mul_add_c(a[4],b[2],c1,c2,c3);
364 mul_add_c(a[3],b[3],c1,c2,c3);
365 mul_add_c(a[2],b[4],c1,c2,c3);
366 mul_add_c(a[1],b[5],c1,c2,c3);
367 mul_add_c(a[0],b[6],c1,c2,c3);
368 r[6]=c1;
369 c1=0;
370 mul_add_c(a[0],b[7],c2,c3,c1);
371 mul_add_c(a[1],b[6],c2,c3,c1);
372 mul_add_c(a[2],b[5],c2,c3,c1);
373 mul_add_c(a[3],b[4],c2,c3,c1);
374 mul_add_c(a[4],b[3],c2,c3,c1);
375 mul_add_c(a[5],b[2],c2,c3,c1);
376 mul_add_c(a[6],b[1],c2,c3,c1);
377 mul_add_c(a[7],b[0],c2,c3,c1);
378 r[7]=c2;
379 c2=0;
380 mul_add_c(a[7],b[1],c3,c1,c2);
381 mul_add_c(a[6],b[2],c3,c1,c2);
382 mul_add_c(a[5],b[3],c3,c1,c2);
383 mul_add_c(a[4],b[4],c3,c1,c2);
384 mul_add_c(a[3],b[5],c3,c1,c2);
385 mul_add_c(a[2],b[6],c3,c1,c2);
386 mul_add_c(a[1],b[7],c3,c1,c2);
387 r[8]=c3;
388 c3=0;
389 mul_add_c(a[2],b[7],c1,c2,c3);
390 mul_add_c(a[3],b[6],c1,c2,c3);
391 mul_add_c(a[4],b[5],c1,c2,c3);
392 mul_add_c(a[5],b[4],c1,c2,c3);
393 mul_add_c(a[6],b[3],c1,c2,c3);
394 mul_add_c(a[7],b[2],c1,c2,c3);
395 r[9]=c1;
396 c1=0;
397 mul_add_c(a[7],b[3],c2,c3,c1);
398 mul_add_c(a[6],b[4],c2,c3,c1);
399 mul_add_c(a[5],b[5],c2,c3,c1);
400 mul_add_c(a[4],b[6],c2,c3,c1);
401 mul_add_c(a[3],b[7],c2,c3,c1);
402 r[10]=c2;
403 c2=0;
404 mul_add_c(a[4],b[7],c3,c1,c2);
405 mul_add_c(a[5],b[6],c3,c1,c2);
406 mul_add_c(a[6],b[5],c3,c1,c2);
407 mul_add_c(a[7],b[4],c3,c1,c2);
408 r[11]=c3;
409 c3=0;
410 mul_add_c(a[7],b[5],c1,c2,c3);
411 mul_add_c(a[6],b[6],c1,c2,c3);
412 mul_add_c(a[5],b[7],c1,c2,c3);
413 r[12]=c1;
414 c1=0;
415 mul_add_c(a[6],b[7],c2,c3,c1);
416 mul_add_c(a[7],b[6],c2,c3,c1);
417 r[13]=c2;
418 c2=0;
419 mul_add_c(a[7],b[7],c3,c1,c2);
420 r[14]=c3;
421 r[15]=c1;
422 }
423
424void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
425 {
426 BN_ULONG bl,bh;
427 BN_ULONG t1,t2;
428 BN_ULONG c1,c2,c3;
429
430 c1=0;
431 c2=0;
432 c3=0;
433 mul_add_c(a[0],b[0],c1,c2,c3);
434 r[0]=c1;
435 c1=0;
436 mul_add_c(a[0],b[1],c2,c3,c1);
437 mul_add_c(a[1],b[0],c2,c3,c1);
438 r[1]=c2;
439 c2=0;
440 mul_add_c(a[2],b[0],c3,c1,c2);
441 mul_add_c(a[1],b[1],c3,c1,c2);
442 mul_add_c(a[0],b[2],c3,c1,c2);
443 r[2]=c3;
444 c3=0;
445 mul_add_c(a[0],b[3],c1,c2,c3);
446 mul_add_c(a[1],b[2],c1,c2,c3);
447 mul_add_c(a[2],b[1],c1,c2,c3);
448 mul_add_c(a[3],b[0],c1,c2,c3);
449 r[3]=c1;
450 c1=0;
451 mul_add_c(a[3],b[1],c2,c3,c1);
452 mul_add_c(a[2],b[2],c2,c3,c1);
453 mul_add_c(a[1],b[3],c2,c3,c1);
454 r[4]=c2;
455 c2=0;
456 mul_add_c(a[2],b[3],c3,c1,c2);
457 mul_add_c(a[3],b[2],c3,c1,c2);
458 r[5]=c3;
459 c3=0;
460 mul_add_c(a[3],b[3],c1,c2,c3);
461 r[6]=c1;
462 r[7]=c2;
463 }
464
465void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a)
466 {
467 BN_ULONG bl,bh;
468 BN_ULONG t1,t2;
469 BN_ULONG c1,c2,c3;
470
471 c1=0;
472 c2=0;
473 c3=0;
474 sqr_add_c(a,0,c1,c2,c3);
475 r[0]=c1;
476 c1=0;
477 sqr_add_c2(a,1,0,c2,c3,c1);
478 r[1]=c2;
479 c2=0;
480 sqr_add_c(a,1,c3,c1,c2);
481 sqr_add_c2(a,2,0,c3,c1,c2);
482 r[2]=c3;
483 c3=0;
484 sqr_add_c2(a,3,0,c1,c2,c3);
485 sqr_add_c2(a,2,1,c1,c2,c3);
486 r[3]=c1;
487 c1=0;
488 sqr_add_c(a,2,c2,c3,c1);
489 sqr_add_c2(a,3,1,c2,c3,c1);
490 sqr_add_c2(a,4,0,c2,c3,c1);
491 r[4]=c2;
492 c2=0;
493 sqr_add_c2(a,5,0,c3,c1,c2);
494 sqr_add_c2(a,4,1,c3,c1,c2);
495 sqr_add_c2(a,3,2,c3,c1,c2);
496 r[5]=c3;
497 c3=0;
498 sqr_add_c(a,3,c1,c2,c3);
499 sqr_add_c2(a,4,2,c1,c2,c3);
500 sqr_add_c2(a,5,1,c1,c2,c3);
501 sqr_add_c2(a,6,0,c1,c2,c3);
502 r[6]=c1;
503 c1=0;
504 sqr_add_c2(a,7,0,c2,c3,c1);
505 sqr_add_c2(a,6,1,c2,c3,c1);
506 sqr_add_c2(a,5,2,c2,c3,c1);
507 sqr_add_c2(a,4,3,c2,c3,c1);
508 r[7]=c2;
509 c2=0;
510 sqr_add_c(a,4,c3,c1,c2);
511 sqr_add_c2(a,5,3,c3,c1,c2);
512 sqr_add_c2(a,6,2,c3,c1,c2);
513 sqr_add_c2(a,7,1,c3,c1,c2);
514 r[8]=c3;
515 c3=0;
516 sqr_add_c2(a,7,2,c1,c2,c3);
517 sqr_add_c2(a,6,3,c1,c2,c3);
518 sqr_add_c2(a,5,4,c1,c2,c3);
519 r[9]=c1;
520 c1=0;
521 sqr_add_c(a,5,c2,c3,c1);
522 sqr_add_c2(a,6,4,c2,c3,c1);
523 sqr_add_c2(a,7,3,c2,c3,c1);
524 r[10]=c2;
525 c2=0;
526 sqr_add_c2(a,7,4,c3,c1,c2);
527 sqr_add_c2(a,6,5,c3,c1,c2);
528 r[11]=c3;
529 c3=0;
530 sqr_add_c(a,6,c1,c2,c3);
531 sqr_add_c2(a,7,5,c1,c2,c3);
532 r[12]=c1;
533 c1=0;
534 sqr_add_c2(a,7,6,c2,c3,c1);
535 r[13]=c2;
536 c2=0;
537 sqr_add_c(a,7,c3,c1,c2);
538 r[14]=c3;
539 r[15]=c1;
540 }
541
542void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
543 {
544 BN_ULONG bl,bh;
545 BN_ULONG t1,t2;
546 BN_ULONG c1,c2,c3;
547
548 c1=0;
549 c2=0;
550 c3=0;
551 sqr_add_c(a,0,c1,c2,c3);
552 r[0]=c1;
553 c1=0;
554 sqr_add_c2(a,1,0,c2,c3,c1);
555 r[1]=c2;
556 c2=0;
557 sqr_add_c(a,1,c3,c1,c2);
558 sqr_add_c2(a,2,0,c3,c1,c2);
559 r[2]=c3;
560 c3=0;
561 sqr_add_c2(a,3,0,c1,c2,c3);
562 sqr_add_c2(a,2,1,c1,c2,c3);
563 r[3]=c1;
564 c1=0;
565 sqr_add_c(a,2,c2,c3,c1);
566 sqr_add_c2(a,3,1,c2,c3,c1);
567 r[4]=c2;
568 c2=0;
569 sqr_add_c2(a,3,2,c3,c1,c2);
570 r[5]=c3;
571 c3=0;
572 sqr_add_c(a,3,c1,c2,c3);
573 r[6]=c1;
574 r[7]=c2;
575 }
diff --git a/src/lib/libcrypto/doc/EVP_PKEY_new.pod b/src/lib/libcrypto/doc/EVP_PKEY_new.pod
new file mode 100644
index 0000000000..10687e458d
--- /dev/null
+++ b/src/lib/libcrypto/doc/EVP_PKEY_new.pod
@@ -0,0 +1,47 @@
1=pod
2
3=head1 NAME
4
5EVP_PKEY_new, EVP_PKEY_free - private key allocation functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 EVP_PKEY *EVP_PKEY_new(void);
12 void EVP_PKEY_free(EVP_PKEY *key);
13
14
15=head1 DESCRIPTION
16
17The EVP_PKEY_new() function allocates an empty B<EVP_PKEY>
18structure which is used by OpenSSL to store private keys.
19
20EVP_PKEY_free() frees up the private key B<key>.
21
22=head1 NOTES
23
24The B<EVP_PKEY> structure is used by various OpenSSL functions
25which require a general private key without reference to any
26particular algorithm.
27
28The structure returned by EVP_PKEY_new() is empty. To add a
29private key to this empty structure the functions described in
30L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)> should be used.
31
32=head1 RETURN VALUES
33
34EVP_PKEY_new() returns either the newly allocated B<EVP_PKEY>
35structure of B<NULL> if an error occurred.
36
37EVP_PKEY_free() does not return a value.
38
39=head1 SEE ALSO
40
41L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)>
42
43=head1 HISTORY
44
45TBA
46
47=cut
diff --git a/src/lib/libcrypto/doc/EVP_PKEY_set1_RSA.pod b/src/lib/libcrypto/doc/EVP_PKEY_set1_RSA.pod
new file mode 100644
index 0000000000..2db692e271
--- /dev/null
+++ b/src/lib/libcrypto/doc/EVP_PKEY_set1_RSA.pod
@@ -0,0 +1,80 @@
1=pod
2
3=head1 NAME
4
5EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH, EVP_PKEY_set1_EC_KEY,
6EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA, EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY,
7EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH, EVP_PKEY_assign_EC_KEY,
8EVP_PKEY_type - EVP_PKEY assignment functions.
9
10=head1 SYNOPSIS
11
12 #include <openssl/evp.h>
13
14 int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key);
15 int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key);
16 int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key);
17 int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,EC_KEY *key);
18
19 RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
20 DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
21 DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
22 EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
23
24 int EVP_PKEY_assign_RSA(EVP_PKEY *pkey,RSA *key);
25 int EVP_PKEY_assign_DSA(EVP_PKEY *pkey,DSA *key);
26 int EVP_PKEY_assign_DH(EVP_PKEY *pkey,DH *key);
27 int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey,EC_KEY *key);
28
29 int EVP_PKEY_type(int type);
30
31=head1 DESCRIPTION
32
33EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
34EVP_PKEY_set1_EC_KEY() set the key referenced by B<pkey> to B<key>.
35
36EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
37EVP_PKEY_get1_EC_KEY() return the referenced key in B<pkey> or
38B<NULL> if the key is not of the correct type.
39
40EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
41and EVP_PKEY_assign_EC_KEY() also set the referenced key to B<key>
42however these use the supplied B<key> internally and so B<key>
43will be freed when the parent B<pkey> is freed.
44
45EVP_PKEY_type() returns the type of key corresponding to the value
46B<type>. The type of a key can be obtained with
47EVP_PKEY_type(pkey->type). The return value will be EVP_PKEY_RSA,
48EVP_PKEY_DSA, EVP_PKEY_DH or EVP_PKEY_EC for the corresponding
49key types or NID_undef if the key type is unassigned.
50
51=head1 NOTES
52
53In accordance with the OpenSSL naming convention the key obtained
54from or assigned to the B<pkey> using the B<1> functions must be
55freed as well as B<pkey>.
56
57EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
58EVP_PKEY_assign_EC_KEY() are implemented as macros.
59
60=head1 RETURN VALUES
61
62EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
63EVP_PKEY_set1_EC_KEY() return 1 for success or 0 for failure.
64
65EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
66EVP_PKEY_get1_EC_KEY() return the referenced key or B<NULL> if
67an error occurred.
68
69EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
70and EVP_PKEY_assign_EC_KEY() return 1 for success and 0 for failure.
71
72=head1 SEE ALSO
73
74L<EVP_PKEY_new(3)|EVP_PKEY_new(3)>
75
76=head1 HISTORY
77
78TBA
79
80=cut
diff --git a/src/lib/libcrypto/doc/OBJ_nid2obj.pod b/src/lib/libcrypto/doc/OBJ_nid2obj.pod
new file mode 100644
index 0000000000..7dcc07923f
--- /dev/null
+++ b/src/lib/libcrypto/doc/OBJ_nid2obj.pod
@@ -0,0 +1,149 @@
1=pod
2
3=head1 NAME
4
5OBJ_nid2obj, OBJ_nid2ln, OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid, OBJ_ln2nid, OBJ_sn2nid,
6OBJ_cmp, OBJ_dup, OBJ_txt2obj, OBJ_obj2txt, OBJ_create, OBJ_cleanup - ASN1 object utility
7functions
8
9=head1 SYNOPSIS
10
11 ASN1_OBJECT * OBJ_nid2obj(int n);
12 const char * OBJ_nid2ln(int n);
13 const char * OBJ_nid2sn(int n);
14
15 int OBJ_obj2nid(const ASN1_OBJECT *o);
16 int OBJ_ln2nid(const char *ln);
17 int OBJ_sn2nid(const char *sn);
18
19 int OBJ_txt2nid(const char *s);
20
21 ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
22 int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
23
24 int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
25 ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
26
27 int OBJ_create(const char *oid,const char *sn,const char *ln);
28 void OBJ_cleanup(void);
29
30=head1 DESCRIPTION
31
32The ASN1 object utility functions process ASN1_OBJECT structures which are
33a representation of the ASN1 OBJECT IDENTIFIER (OID) type.
34
35OBJ_nid2obj(), OBJ_nid2ln() and OBJ_nid2sn() convert the NID B<n> to
36an ASN1_OBJECT structure, its long name and its short name respectively,
37or B<NULL> is an error occurred.
38
39OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() return the corresponding NID
40for the object B<o>, the long name <ln> or the short name <sn> respectively
41or NID_undef if an error occurred.
42
43OBJ_txt2nid() returns NID corresponding to text string <s>. B<s> can be
44a long name, a short name or the numerical respresentation of an object.
45
46OBJ_txt2obj() converts the text string B<s> into an ASN1_OBJECT structure.
47If B<no_name> is 0 then long names and short names will be interpreted
48as well as numerical forms. If B<no_name> is 1 only the numerical form
49is acceptable.
50
51OBJ_obj2txt() converts the B<ASN1_OBJECT> B<a> into a textual representation.
52The representation is written as a null terminated string to B<buf>
53at most B<buf_len> bytes are written, truncating the result if necessary.
54The total amount of space required is returned. If B<no_name> is 0 then
55if the object has a long or short name then that will be used, otherwise
56the numerical form will be used. If B<no_name> is 1 then the numerical
57form will always be used.
58
59OBJ_cmp() compares B<a> to B<b>. If the two are identical 0 is returned.
60
61OBJ_dup() returns a copy of B<o>.
62
63OBJ_create() adds a new object to the internal table. B<oid> is the
64numerical form of the object, B<sn> the short name and B<ln> the
65long name. A new NID is returned for the created object.
66
67OBJ_cleanup() cleans up OpenSSLs internal object table: this should
68be called before an application exits if any new objects were added
69using OBJ_create().
70
71=head1 NOTES
72
73Objects in OpenSSL can have a short name, a long name and a numerical
74identifier (NID) associated with them. A standard set of objects is
75represented in an internal table. The appropriate values are defined
76in the header file B<objects.h>.
77
78For example the OID for commonName has the following definitions:
79
80 #define SN_commonName "CN"
81 #define LN_commonName "commonName"
82 #define NID_commonName 13
83
84New objects can be added by calling OBJ_create().
85
86Table objects have certain advantages over other objects: for example
87their NIDs can be used in a C language switch statement. They are
88also static constant structures which are shared: that is there
89is only a single constant structure for each table object.
90
91Objects which are not in the table have the NID value NID_undef.
92
93Objects do not need to be in the internal tables to be processed,
94the functions OBJ_txt2obj() and OBJ_obj2txt() can process the numerical
95form of an OID.
96
97=head1 EXAMPLES
98
99Create an object for B<commonName>:
100
101 ASN1_OBJECT *o;
102 o = OBJ_nid2obj(NID_commonName);
103
104Check if an object is B<commonName>
105
106 if (OBJ_obj2nid(obj) == NID_commonName)
107 /* Do something */
108
109Create a new NID and initialize an object from it:
110
111 int new_nid;
112 ASN1_OBJECT *obj;
113 new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
114
115 obj = OBJ_nid2obj(new_nid);
116
117Create a new object directly:
118
119 obj = OBJ_txt2obj("1.2.3.4", 1);
120
121=head1 BUGS
122
123OBJ_obj2txt() is awkward and messy to use: it doesn't follow the
124convention of other OpenSSL functions where the buffer can be set
125to B<NULL> to determine the amount of data that should be written.
126Instead B<buf> must point to a valid buffer and B<buf_len> should
127be set to a positive value. A buffer length of 80 should be more
128than enough to handle any OID encountered in practice.
129
130=head1 RETURN VALUES
131
132OBJ_nid2obj() returns an B<ASN1_OBJECT> structure or B<NULL> is an
133error occurred.
134
135OBJ_nid2ln() and OBJ_nid2sn() returns a valid string or B<NULL>
136on error.
137
138OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() and OBJ_txt2nid() return
139a NID or B<NID_undef> on error.
140
141=head1 SEE ALSO
142
143L<ERR_get_error(3)|ERR_get_error(3)>
144
145=head1 HISTORY
146
147TBA
148
149=cut
diff --git a/src/lib/libcrypto/doc/PKCS12_create.pod b/src/lib/libcrypto/doc/PKCS12_create.pod
new file mode 100644
index 0000000000..48f3bb8cb8
--- /dev/null
+++ b/src/lib/libcrypto/doc/PKCS12_create.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5PKCS12_create - create a PKCS#12 structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/pkcs12.h>
10
11 PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca,
12 int nid_key, int nid_cert, int iter, int mac_iter, int keytype);
13
14=head1 DESCRIPTION
15
16PKCS12_create() creates a PKCS#12 structure.
17
18B<pass> is the passphrase to use. B<name> is the B<friendlyName> to use for
19the supplied certifictate and key. B<pkey> is the private key to include in
20the structure and B<cert> its corresponding certificates. B<ca>, if not B<NULL>
21is an optional set of certificates to also include in the structure.
22
23B<nid_key> and B<nid_cert> are the encryption algorithms that should be used
24for the key and certificate respectively. B<iter> is the encryption algorithm
25iteration count to use and B<mac_iter> is the MAC iteration count to use.
26B<keytype> is the type of key.
27
28=head1 NOTES
29
30The parameters B<nid_key>, B<nid_cert>, B<iter>, B<mac_iter> and B<keytype>
31can all be set to zero and sensible defaults will be used.
32
33These defaults are: 40 bit RC2 encryption for certificates, triple DES
34encryption for private keys, a key iteration count of PKCS12_DEFAULT_ITER
35(currently 2048) and a MAC iteration count of 1.
36
37The default MAC iteration count is 1 in order to retain compatibility with
38old software which did not interpret MAC iteration counts. If such compatibility
39is not required then B<mac_iter> should be set to PKCS12_DEFAULT_ITER.
40
41B<keytype> adds a flag to the store private key. This is a non standard extension
42that is only currently interpreted by MSIE. If set to zero the flag is omitted,
43if set to B<KEY_SIG> the key can be used for signing only, if set to B<KEY_EX>
44it can be used for signing and encryption. This option was useful for old
45export grade software which could use signing only keys of arbitrary size but
46had restrictions on the permissible sizes of keys which could be used for
47encryption.
48
49=head1 SEE ALSO
50
51L<d2i_PKCS12(3)|d2i_PKCS12(3)>
52
53=head1 HISTORY
54
55PKCS12_create was added in OpenSSL 0.9.3
56
57=cut
diff --git a/src/lib/libcrypto/doc/PKCS12_parse.pod b/src/lib/libcrypto/doc/PKCS12_parse.pod
new file mode 100644
index 0000000000..51344f883a
--- /dev/null
+++ b/src/lib/libcrypto/doc/PKCS12_parse.pod
@@ -0,0 +1,50 @@
1=pod
2
3=head1 NAME
4
5PKCS12_parse - parse a PKCS#12 structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/pkcs12.h>
10
11int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca);
12
13=head1 DESCRIPTION
14
15PKCS12_parse() parses a PKCS12 structure.
16
17B<p12> is the B<PKCS12> structure to parse. B<pass> is the passphrase to use.
18If successful the private key will be written to B<*pkey>, the corresponding
19certificate to B<*cert> and any additional certificates to B<*ca>.
20
21=head1 NOTES
22
23The parameters B<pkey> and B<cert> cannot be B<NULL>. B<ca> can be <NULL>
24in which case additional certificates will be discarded. B<*ca> can also
25be a valid STACK in which case additional certificates are appended to
26B<*ca>. If B<*ca> is B<NULL> a new STACK will be allocated.
27
28The B<friendlyName> and B<localKeyID> attributes (if present) on each certificate
29will be stored in the B<alias> and B<keyid> attributes of the B<X509> structure.
30
31=head1 BUGS
32
33Only a single private key and corresponding certificate is returned by this function.
34More complex PKCS#12 files with multiple private keys will only return the first
35match.
36
37Only B<friendlyName> and B<localKeyID> attributes are currently stored in certificates.
38Other attributes are discarded.
39
40Attributes currently cannot be store in the private key B<EVP_PKEY> structure.
41
42=head1 SEE ALSO
43
44L<d2i_PKCS12(3)|d2i_PKCS12(3)>
45
46=head1 HISTORY
47
48PKCS12_parse was added in OpenSSL 0.9.3
49
50=cut
diff --git a/src/lib/libcrypto/doc/PKCS7_decrypt.pod b/src/lib/libcrypto/doc/PKCS7_decrypt.pod
new file mode 100644
index 0000000000..b0ca067b89
--- /dev/null
+++ b/src/lib/libcrypto/doc/PKCS7_decrypt.pod
@@ -0,0 +1,53 @@
1=pod
2
3=head1 NAME
4
5PKCS7_decrypt - decrypt content from a PKCS#7 envelopedData structure
6
7=head1 SYNOPSIS
8
9int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
10
11=head1 DESCRIPTION
12
13PKCS7_decrypt() extracts and decrypts the content from a PKCS#7 envelopedData
14structure. B<pkey> is the private key of the recipient, B<cert> is the
15recipients certificate, B<data> is a BIO to write the content to and
16B<flags> is an optional set of flags.
17
18=head1 NOTES
19
20OpenSSL_add_all_algorithms() (or equivalent) should be called before using this
21function or errors about unknown algorithms will occur.
22
23Although the recipients certificate is not needed to decrypt the data it is needed
24to locate the appropriate (of possible several) recipients in the PKCS#7 structure.
25
26The following flags can be passed in the B<flags> parameter.
27
28If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are deleted
29from the content. If the content is not of type B<text/plain> then an error is
30returned.
31
32=head1 RETURN VALUES
33
34PKCS7_decrypt() returns either 1 for success or 0 for failure.
35The error can be obtained from ERR_get_error(3)
36
37=head1 BUGS
38
39PKCS7_decrypt() must be passed the correct recipient key and certificate. It would
40be better if it could look up the correct key and certificate from a database.
41
42The lack of single pass processing and need to hold all data in memory as
43mentioned in PKCS7_sign() also applies to PKCS7_verify().
44
45=head1 SEE ALSO
46
47L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
48
49=head1 HISTORY
50
51PKCS7_decrypt() was added to OpenSSL 0.9.5
52
53=cut
diff --git a/src/lib/libcrypto/doc/PKCS7_encrypt.pod b/src/lib/libcrypto/doc/PKCS7_encrypt.pod
new file mode 100644
index 0000000000..1a507b22a2
--- /dev/null
+++ b/src/lib/libcrypto/doc/PKCS7_encrypt.pod
@@ -0,0 +1,65 @@
1=pod
2
3=head1 NAME
4
5PKCS7_encrypt - create a PKCS#7 envelopedData structure
6
7=head1 SYNOPSIS
8
9PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags);
10
11=head1 DESCRIPTION
12
13PKCS7_encrypt() creates and returns a PKCS#7 envelopedData structure. B<certs>
14is a list of recipient certificates. B<in> is the content to be encrypted.
15B<cipher> is the symmetric cipher to use. B<flags> is an optional set of flags.
16
17=head1 NOTES
18
19Only RSA keys are supported in PKCS#7 and envelopedData so the recipient certificates
20supplied to this function must all contain RSA public keys, though they do not have to
21be signed using the RSA algorithm.
22
23EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME use because
24most clients will support it.
25
26Some old "export grade" clients may only support weak encryption using 40 or 64 bit
27RC2. These can be used by passing EVP_rc2_40_cbc() and EVP_rc2_64_cbc() respectively.
28
29The algorithm passed in the B<cipher> parameter must support ASN1 encoding of its
30parameters.
31
32Many browsers implement a "sign and encrypt" option which is simply an S/MIME
33envelopedData containing an S/MIME signed message. This can be readily produced
34by storing the S/MIME signed message in a memory BIO and passing it to
35PKCS7_encrypt().
36
37The following flags can be passed in the B<flags> parameter.
38
39If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended
40to the data.
41
42Normally the supplied content is translated into MIME canonical format (as required
43by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation occurs. This
44option should be used if the supplied data is in binary format otherwise the translation
45will corrupt it. If B<PKCS7_BINARY> is set then B<PKCS7_TEXT> is ignored.
46
47=head1 RETURN VALUES
48
49PKCS7_encrypt() returns either a valid PKCS7 structure or NULL if an error occurred.
50The error can be obtained from ERR_get_error(3).
51
52=head1 BUGS
53
54The lack of single pass processing and need to hold all data in memory as
55mentioned in PKCS7_sign() also applies to PKCS7_verify().
56
57=head1 SEE ALSO
58
59L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
60
61=head1 HISTORY
62
63PKCS7_decrypt() was added to OpenSSL 0.9.5
64
65=cut
diff --git a/src/lib/libcrypto/doc/PKCS7_sign.pod b/src/lib/libcrypto/doc/PKCS7_sign.pod
new file mode 100644
index 0000000000..fc7e649b34
--- /dev/null
+++ b/src/lib/libcrypto/doc/PKCS7_sign.pod
@@ -0,0 +1,85 @@
1=pod
2
3=head1 NAME
4
5PKCS7_sign - create a PKCS#7 signedData structure
6
7=head1 SYNOPSIS
8
9PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, int flags);
10
11=head1 DESCRIPTION
12
13PKCS7_sign() creates and returns a PKCS#7 signedData structure. B<signcert>
14is the certificate to sign with, B<pkey> is the corresponsding private key.
15B<certs> is an optional additional set of certificates to include in the
16PKCS#7 structure (for example any intermediate CAs in the chain).
17
18The data to be signed is read from BIO B<data>.
19
20B<flags> is an optional set of flags.
21
22=head1 NOTES
23
24Any of the following flags (ored together) can be passed in the B<flags> parameter.
25
26Many S/MIME clients expect the signed content to include valid MIME headers. If
27the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended
28to the data.
29
30If B<PKCS7_NOCERTS> is set the signer's certificate will not be included in the
31PKCS7 structure, the signer's certificate must still be supplied in the B<signcert>
32parameter though. This can reduce the size of the signature if the signers certificate
33can be obtained by other means: for example a previously signed message.
34
35The data being signed is included in the PKCS7 structure, unless B<PKCS7_DETACHED>
36is set in which case it is omitted. This is used for PKCS7 detached signatures
37which are used in S/MIME plaintext signed messages for example.
38
39Normally the supplied content is translated into MIME canonical format (as required
40by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation occurs. This
41option should be used if the supplied data is in binary format otherwise the translation
42will corrupt it.
43
44The signedData structure includes several PKCS#7 autenticatedAttributes including
45the signing time, the PKCS#7 content type and the supported list of ciphers in
46an SMIMECapabilities attribute. If B<PKCS7_NOATTR> is set then no authenticatedAttributes
47will be used. If B<PKCS7_NOSMIMECAP> is set then just the SMIMECapabilities are
48omitted.
49
50If present the SMIMECapabilities attribute indicates support for the following
51algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any
52of these algorithms is disabled then it will not be included.
53
54=head1 BUGS
55
56PKCS7_sign() is somewhat limited. It does not support multiple signers, some
57advanced attributes such as counter signatures are not supported.
58
59The SHA1 digest algorithm is currently always used.
60
61When the signed data is not detached it will be stored in memory within the
62B<PKCS7> structure. This effectively limits the size of messages which can be
63signed due to memory restraints. There should be a way to sign data without
64having to hold it all in memory, this would however require fairly major
65revisions of the OpenSSL ASN1 code.
66
67Clear text signing does not store the content in memory but the way PKCS7_sign()
68operates means that two passes of the data must typically be made: one to compute
69the signatures and a second to output the data along with the signature. There
70should be a way to process the data with only a single pass.
71
72=head1 RETURN VALUES
73
74PKCS7_sign() returns either a valid PKCS7 structure or NULL if an error occurred.
75The error can be obtained from ERR_get_error(3).
76
77=head1 SEE ALSO
78
79L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_verify(3)|PKCS7_verify(3)>
80
81=head1 HISTORY
82
83PKCS7_sign() was added to OpenSSL 0.9.5
84
85=cut
diff --git a/src/lib/libcrypto/doc/PKCS7_verify.pod b/src/lib/libcrypto/doc/PKCS7_verify.pod
new file mode 100644
index 0000000000..07c9fdad40
--- /dev/null
+++ b/src/lib/libcrypto/doc/PKCS7_verify.pod
@@ -0,0 +1,116 @@
1=pod
2
3=head1 NAME
4
5PKCS7_verify - verify a PKCS#7 signedData structure
6
7=head1 SYNOPSIS
8
9int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, int flags);
10
11int PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
12
13=head1 DESCRIPTION
14
15PKCS7_verify() verifies a PKCS#7 signedData structure. B<p7> is the PKCS7
16structure to verify. B<certs> is a set of certificates in which to search for
17the signer's certificate. B<store> is a trusted certficate store (used for
18chain verification). B<indata> is the signed data if the content is not
19present in B<p7> (that is it is detached). The content is written to B<out>
20if it is not NULL.
21
22B<flags> is an optional set of flags, which can be used to modify the verify
23operation.
24
25PKCS7_get0_signers() retrieves the signer's certificates from B<p7>, it does
26B<not> check their validity or whether any signatures are valid. The B<certs>
27and B<flags> parameters have the same meanings as in PKCS7_verify().
28
29=head1 VERIFY PROCESS
30
31Normally the verify process proceeds as follows.
32
33Initially some sanity checks are performed on B<p7>. The type of B<p7> must
34be signedData. There must be at least one signature on the data and if
35the content is detached B<indata> cannot be B<NULL>.
36
37An attempt is made to locate all the signer's certificates, first looking in
38the B<certs> parameter (if it is not B<NULL>) and then looking in any certificates
39contained in the B<p7> structure itself. If any signer's certificates cannot be
40located the operation fails.
41
42Each signer's certificate is chain verified using the B<smimesign> purpose and
43the supplied trusted certificate store. Any internal certificates in the message
44are used as untrusted CAs. If any chain verify fails an error code is returned.
45
46Finally the signed content is read (and written to B<out> is it is not NULL) and
47the signature's checked.
48
49If all signature's verify correctly then the function is successful.
50
51Any of the following flags (ored together) can be passed in the B<flags> parameter
52to change the default verify behaviour. Only the flag B<PKCS7_NOINTERN> is
53meaningful to PKCS7_get0_signers().
54
55If B<PKCS7_NOINTERN> is set the certificates in the message itself are not
56searched when locating the signer's certificate. This means that all the signers
57certificates must be in the B<certs> parameter.
58
59If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are deleted
60from the content. If the content is not of type B<text/plain> then an error is
61returned.
62
63If B<PKCS7_NOVERIFY> is set the signer's certificates are not chain verified.
64
65If B<PKCS7_NOCHAIN> is set then the certificates contained in the message are
66not used as untrusted CAs. This means that the whole verify chain (apart from
67the signer's certificate) must be contained in the trusted store.
68
69If B<PKCS7_NOSIGS> is set then the signatures on the data are not checked.
70
71=head1 NOTES
72
73One application of B<PKCS7_NOINTERN> is to only accept messages signed by
74a small number of certificates. The acceptable certificates would be passed
75in the B<certs> parameter. In this case if the signer is not one of the
76certificates supplied in B<certs> then the verify will fail because the
77signer cannot be found.
78
79Care should be taken when modifying the default verify behaviour, for example
80setting B<PKCS7_NOVERIFY|PKCS7_NOSIGS> will totally disable all verification
81and any signed message will be considered valid. This combination is however
82useful if one merely wishes to write the content to B<out> and its validity
83is not considered important.
84
85Chain verification should arguably be performed using the signing time rather
86than the current time. However since the signing time is supplied by the
87signer it cannot be trusted without additional evidence (such as a trusted
88timestamp).
89
90=head1 RETURN VALUES
91
92PKCS7_verify() returns 1 for a successful verification and zero or a negative
93value if an error occurs.
94
95PKCS7_get0_signers() returns all signers or B<NULL> if an error occurred.
96
97The error can be obtained from L<ERR_get_error(3)|ERR_get_error(3)>
98
99=head1 BUGS
100
101The trusted certificate store is not searched for the signers certificate,
102this is primarily due to the inadequacies of the current B<X509_STORE>
103functionality.
104
105The lack of single pass processing and need to hold all data in memory as
106mentioned in PKCS7_sign() also applies to PKCS7_verify().
107
108=head1 SEE ALSO
109
110L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>
111
112=head1 HISTORY
113
114PKCS7_verify() was added to OpenSSL 0.9.5
115
116=cut
diff --git a/src/lib/libcrypto/doc/SMIME_read_PKCS7.pod b/src/lib/libcrypto/doc/SMIME_read_PKCS7.pod
new file mode 100644
index 0000000000..ffafa37887
--- /dev/null
+++ b/src/lib/libcrypto/doc/SMIME_read_PKCS7.pod
@@ -0,0 +1,71 @@
1=pod
2
3=head1 NAME
4
5SMIME_read_PKCS7 - parse S/MIME message.
6
7=head1 SYNOPSIS
8
9PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont);
10
11=head1 DESCRIPTION
12
13SMIME_read_PKCS7() parses a message in S/MIME format.
14
15B<in> is a BIO to read the message from.
16
17If cleartext signing is used then the content is saved in
18a memory bio which is written to B<*bcont>, otherwise
19B<*bcont> is set to B<NULL>.
20
21The parsed PKCS#7 structure is returned or B<NULL> if an
22error occurred.
23
24=head1 NOTES
25
26If B<*bcont> is not B<NULL> then the message is clear text
27signed. B<*bcont> can then be passed to PKCS7_verify() with
28the B<PKCS7_DETACHED> flag set.
29
30Otherwise the type of the returned structure can be determined
31using PKCS7_type().
32
33To support future functionality if B<bcont> is not B<NULL>
34B<*bcont> should be initialized to B<NULL>. For example:
35
36 BIO *cont = NULL;
37 PKCS7 *p7;
38
39 p7 = SMIME_read_PKCS7(in, &cont);
40
41=head1 BUGS
42
43The MIME parser used by SMIME_read_PKCS7() is somewhat primitive.
44While it will handle most S/MIME messages more complex compound
45formats may not work.
46
47The parser assumes that the PKCS7 structure is always base64
48encoded and will not handle the case where it is in binary format
49or uses quoted printable format.
50
51The use of a memory BIO to hold the signed content limits the size
52of message which can be processed due to memory restraints: a
53streaming single pass option should be available.
54
55=head1 RETURN VALUES
56
57SMIME_read_PKCS7() returns a valid B<PKCS7> structure or B<NULL>
58is an error occurred. The error can be obtained from ERR_get_error(3).
59
60=head1 SEE ALSO
61
62L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_type(3)|PKCS7_type(3)>
63L<SMIME_read_PKCS7(3)|SMIME_read_PKCS7(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>,
64L<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
65L<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
66
67=head1 HISTORY
68
69SMIME_read_PKCS7() was added to OpenSSL 0.9.5
70
71=cut
diff --git a/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod b/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod
new file mode 100644
index 0000000000..2cfad2e049
--- /dev/null
+++ b/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod
@@ -0,0 +1,59 @@
1=pod
2
3=head1 NAME
4
5SMIME_write_PKCS7 - convert PKCS#7 structure to S/MIME format.
6
7=head1 SYNOPSIS
8
9int SMIME_write_PKCS7(BIO *out, PKCS7 *p7, BIO *data, int flags);
10
11=head1 DESCRIPTION
12
13SMIME_write_PKCS7() adds the appropriate MIME headers to a PKCS#7
14structure to produce an S/MIME message.
15
16B<out> is the BIO to write the data to. B<p7> is the appropriate
17B<PKCS7> structure. If cleartext signing (B<multipart/signed>) is
18being used then the signed data must be supplied in the B<data>
19argument. B<flags> is an optional set of flags.
20
21=head1 NOTES
22
23The following flags can be passed in the B<flags> parameter.
24
25If B<PKCS7_DETACHED> is set then cleartext signing will be used,
26this option only makes sense for signedData where B<PKCS7_DETACHED>
27is also set when PKCS7_sign() is also called.
28
29If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain>
30are added to the content, this only makes sense if B<PKCS7_DETACHED>
31is also set.
32
33If cleartext signing is being used then the data must be read twice:
34once to compute the signature in PKCS7_sign() and once to output the
35S/MIME message.
36
37=head1 BUGS
38
39SMIME_write_PKCS7() always base64 encodes PKCS#7 structures, there
40should be an option to disable this.
41
42There should really be a way to produce cleartext signing using only
43a single pass of the data.
44
45=head1 RETURN VALUES
46
47SMIME_write_PKCS7() returns 1 for success or 0 for failure.
48
49=head1 SEE ALSO
50
51L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>,
52L<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
53L<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
54
55=head1 HISTORY
56
57SMIME_write_PKCS7() was added to OpenSSL 0.9.5
58
59=cut
diff --git a/src/lib/libcrypto/doc/X509_NAME_ENTRY_get_object.pod b/src/lib/libcrypto/doc/X509_NAME_ENTRY_get_object.pod
new file mode 100644
index 0000000000..d287c18564
--- /dev/null
+++ b/src/lib/libcrypto/doc/X509_NAME_ENTRY_get_object.pod
@@ -0,0 +1,72 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_ENTRY_get_object, X509_NAME_ENTRY_get_data,
6X509_NAME_ENTRY_set_object, X509_NAME_ENTRY_set_data,
7X509_NAME_ENTRY_create_by_txt, X509_NAME_ENTRY_create_by_NID,
8X509_NAME_ENTRY_create_by_OBJ - X509_NAME_ENTRY utility functions
9
10=head1 SYNOPSIS
11
12ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
13ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
14
15int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);
16int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, unsigned char *bytes, int len);
17
18X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, unsigned char *bytes, int len);
19X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type,unsigned char *bytes, int len);
20X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, ASN1_OBJECT *obj, int type,unsigned char *bytes, int len);
21
22=head1 DESCRIPTION
23
24X509_NAME_ENTRY_get_object() retrieves the field name of B<ne> in
25and B<ASN1_OBJECT> structure.
26
27X509_NAME_ENTRY_get_data() retrieves the field value of B<ne> in
28and B<ASN1_STRING> structure.
29
30X509_NAME_ENTRY_set_object() sets the field name of B<ne> to B<obj>.
31
32X509_NAME_ENTRY_set_data() sets the field value of B<ne> to string type
33B<type> and value determined by B<bytes> and B<len>.
34
35X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_NID()
36and X509_NAME_ENTRY_create_by_OBJ() create and return an
37B<X509_NAME_ENTRY> structure.
38
39=head1 NOTES
40
41X509_NAME_ENTRY_get_object() and X509_NAME_ENTRY_get_data() can be
42used to examine an B<X509_NAME_ENTRY> function as returned by
43X509_NAME_get_entry() for example.
44
45X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_NID(),
46and X509_NAME_ENTRY_create_by_OBJ() create and return an
47
48X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_OBJ(),
49X509_NAME_ENTRY_create_by_NID() and X509_NAME_ENTRY_set_data()
50are seldom used in practice because B<X509_NAME_ENTRY> structures
51are almost always part of B<X509_NAME> structures and the
52corresponding B<X509_NAME> functions are typically used to
53create and add new entries in a single operation.
54
55The arguments of these functions support similar options to the similarly
56named ones of the corresponding B<X509_NAME> functions such as
57X509_NAME_add_entry_by_txt(). So for example B<type> can be set to
58B<MBSTRING_ASC> but in the case of X509_set_data() the field name must be
59set first so the relevant field information can be looked up internally.
60
61=head1 RETURN VALUES
62
63=head1 SEE ALSO
64
65L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>,
66L<OBJ_nid2obj(3),OBJ_nid2obj(3)>
67
68=head1 HISTORY
69
70TBA
71
72=cut
diff --git a/src/lib/libcrypto/doc/X509_NAME_add_entry_by_txt.pod b/src/lib/libcrypto/doc/X509_NAME_add_entry_by_txt.pod
new file mode 100644
index 0000000000..4472a1c5cf
--- /dev/null
+++ b/src/lib/libcrypto/doc/X509_NAME_add_entry_by_txt.pod
@@ -0,0 +1,110 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID,
6X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions
7
8=head1 SYNOPSIS
9
10int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type, unsigned char *bytes, int len, int loc, int set);
11int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set);
12int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set);
13int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc, int set);
14X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
15
16=head1 DESCRIPTION
17
18X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and
19X509_NAME_add_entry_by_NID() add a field whose name is defined
20by a string B<field>, an object B<obj> or a NID B<nid> respectively.
21The field value to be added is in B<bytes> of length B<len>. If
22B<len> is -1 then the field length is calculated internally using
23strlen(bytes).
24
25The type of field is determined by B<type> which can either be a
26definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a
27standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is
28added to a position determined by B<loc> and B<set>.
29
30X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne>
31to B<name>. The new entry is added to a position determined by B<loc>
32and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after
33the call.
34
35X509_NAME_delete_entry() deletes an entry from B<name> at position
36B<loc>. The deleted entry is returned and must be freed up.
37
38=head1 NOTES
39
40The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8>
41is strongly recommened for the B<type> parameter. This allows the
42internal code to correctly determine the type of the field and to
43apply length checks according to the relevant standards. This is
44done using ASN1_STRING_set_by_NID().
45
46If instead an ASN1 type is used no checks are performed and the
47supplied data in B<bytes> is used directly.
48
49In X509_NAME_add_entry_by_txt() the B<field> string represents
50the field name using OBJ_txt2obj(field, 0).
51
52The B<loc> and B<set> parameters determine where a new entry should
53be added. For almost all applications B<loc> can be set to -1 and B<set>
54to 0. This adds a new entry to the end of B<name> as a single valued
55RelativeDistinguishedName (RDN).
56
57B<loc> actually determines the index where the new entry is inserted:
58if it is -1 it is appended.
59
60B<set> determines how the new type is added. If it is zero a
61new RDN is created.
62
63If B<set> is -1 or 1 it is added to the previous or next RDN
64structure respectively. This will then be a multivalued RDN:
65since multivalues RDNs are very seldom used B<set> is almost
66always set to zero.
67
68=head1 EXAMPLES
69
70Create an B<X509_NAME> structure:
71
72"C=UK, O=Disorganized Organization, CN=Joe Bloggs"
73
74 X509_NAME *nm;
75 nm = X509_NAME_new();
76 if (nm == NULL)
77 /* Some error */
78 if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
79 "C", "UK", -1, -1, 0))
80 /* Error */
81 if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
82 "O", "Disorganized Organization", -1, -1, 0))
83 /* Error */
84 if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
85 "CN", "Joe Bloggs", -1, -1, 0))
86 /* Error */
87
88=head1 RETURN VALUES
89
90X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(),
91X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for
92success of 0 if an error occurred.
93
94X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY>
95structure of B<NULL> if an error occurred.
96
97=head1 BUGS
98
99B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a
100different algorithm to determine field types. Since this form does
101not understand multicharacter types, performs no length checks and
102can result in invalid field types its use is strongly discouraged.
103
104=head1 SEE ALSO
105
106L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>
107
108=head1 HISTORY
109
110=cut
diff --git a/src/lib/libcrypto/doc/X509_NAME_get_index_by_NID.pod b/src/lib/libcrypto/doc/X509_NAME_get_index_by_NID.pod
new file mode 100644
index 0000000000..333323d734
--- /dev/null
+++ b/src/lib/libcrypto/doc/X509_NAME_get_index_by_NID.pod
@@ -0,0 +1,106 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_get_index_by_NID, X509_NAME_get_index_by_OBJ, X509_NAME_get_entry,
6X509_NAME_entry_count, X509_NAME_get_text_by_NID, X509_NAME_get_text_by_OBJ -
7X509_NAME lookup and enumeration functions
8
9=head1 SYNOPSIS
10
11int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
12int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, int lastpos);
13
14int X509_NAME_entry_count(X509_NAME *name);
15X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
16
17int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf,int len);
18int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf,int len);
19
20=head1 DESCRIPTION
21
22These functions allow an B<X509_NAME> structure to be examined. The
23B<X509_NAME> structure is the same as the B<Name> type defined in
24RFC2459 (and elsewhere) and used for example in certificate subject
25and issuer names.
26
27X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ() retrieve
28the next index matching B<nid> or B<obj> after B<lastpos>. B<lastpos>
29should initially be set to -1. If there are no more entries -1 is returned.
30
31X509_NAME_entry_count() returns the total number of entries in B<name>.
32
33X509_NAME_get_entry() retrieves the B<X509_NAME_ENTRY> from B<name>
34corresponding to index B<loc>. Acceptable values for B<loc> run from
350 to (X509_NAME_entry_count(name) - 1). The value returned is an
36internal pointer which must not be freed.
37
38X509_NAME_get_text_by_NID(), X509_NAME_get_text_by_OBJ() retrieve
39the "text" from the first entry in B<name> which matches B<nid> or
40B<obj>, if no such entry exists -1 is returned. At most B<len> bytes
41will be written and the text written to B<buf> will be null
42terminated. The length of the output string written is returned
43excluding the terminating null. If B<buf> is <NULL> then the amount
44of space needed in B<buf> (excluding the final null) is returned.
45
46=head1 NOTES
47
48X509_NAME_get_text_by_NID() and X509_NAME_get_text_by_OBJ() are
49legacy functions which have various limitations which make them
50of minimal use in practice. They can only find the first matching
51entry and will copy the contents of the field verbatim: this can
52be highly confusing if the target is a muticharacter string type
53like a BMPString or a UTF8String.
54
55For a more general solution X509_NAME_get_index_by_NID() or
56X509_NAME_get_index_by_OBJ() should be used followed by
57X509_NAME_get_entry() on any matching indices and then the
58various B<X509_NAME_ENTRY> utility functions on the result.
59
60=head1 EXAMPLES
61
62Process all entries:
63
64 int i;
65 X509_NAME_ENTRY *e;
66
67 for (i = 0; i < X509_NAME_entry_count(nm); i++)
68 {
69 e = X509_NAME_get_entry(nm, i);
70 /* Do something with e */
71 }
72
73Process all commonName entries:
74
75 int loc;
76 X509_NAME_ENTRY *e;
77
78 loc = -1;
79 for (;;)
80 {
81 lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos);
82 if (lastpos == -1)
83 break;
84 e = X509_NAME_get_entry(nm, lastpos);
85 /* Do something with e */
86 }
87
88=head1 RETURN VALUES
89
90X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ()
91return the index of the next matching entry or -1 if not found.
92
93X509_NAME_entry_count() returns the total number of entries.
94
95X509_NAME_get_entry() returns an B<X509_NAME> pointer to the
96requested entry or B<NULL> if the index is invalid.
97
98=head1 SEE ALSO
99
100L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>
101
102=head1 HISTORY
103
104TBA
105
106=cut
diff --git a/src/lib/libcrypto/doc/X509_NAME_print_ex.pod b/src/lib/libcrypto/doc/X509_NAME_print_ex.pod
new file mode 100644
index 0000000000..907c04f684
--- /dev/null
+++ b/src/lib/libcrypto/doc/X509_NAME_print_ex.pod
@@ -0,0 +1,105 @@
1=pod
2
3=head1 NAME
4
5X509_NAME_print_ex, X509_NAME_print_ex_fp, X509_NAME_print,
6X509_NAME_oneline - X509_NAME printing routines.
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
13 int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
14 char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
15 int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
16
17=head1 DESCRIPTION
18
19X509_NAME_print_ex() prints a human readable version of B<nm> to BIO B<out>. Each
20line (for multiline formats) is indented by B<indent> spaces. The output format
21can be extensively customised by use of the B<flags> parameter.
22
23X509_NAME_print_ex_fp() is identical to X509_NAME_print_ex() except the output is
24written to FILE pointer B<fp>.
25
26X509_NAME_oneline() prints an ASCII version of B<a> to B<buf>. At most B<size>
27bytes will be written. If B<buf> is B<NULL> then a buffer is dynamically allocated
28and returned, otherwise B<buf> is returned.
29
30X509_NAME_print() prints out B<name> to B<bp> indenting each line by B<obase>
31characters. Multiple lines are used if the output (including indent) exceeds
3280 characters.
33
34=head1 NOTES
35
36The functions X509_NAME_oneline() and X509_NAME_print() are legacy functions which
37produce a non standard output form, they don't handle multi character fields and
38have various quirks and inconsistencies. Their use is strongly discouraged in new
39applications.
40
41Although there are a large number of possible flags for most purposes
42B<XN_FLAG_ONELINE>, B<XN_FLAG_MULTILINE> or B<XN_FLAG_RFC2253> will suffice.
43As noted on the L<ASN1_STRING_print_ex(3)|ASN1_STRING_print_ex(3)> manual page
44for UTF8 terminals the B<ASN1_STRFLAGS_ESC_MSB> should be unset: so for example
45B<XN_FLAG_ONELINE & ~ASN1_STRFLAGS_ESC_MSB> would be used.
46
47The complete set of the flags supported by X509_NAME_print_ex() is listed below.
48
49Several options can be ored together.
50
51The options B<XN_FLAG_SEP_COMMA_PLUS>, B<XN_FLAG_SEP_CPLUS_SPC>,
52B<XN_FLAG_SEP_SPLUS_SPC> and B<XN_FLAG_SEP_MULTILINE> determine the field separators
53to use. Two distinct separators are used between distinct RelativeDistinguishedName
54components and separate values in the same RDN for a multi-valued RDN. Multi-valued
55RDNs are currently very rare so the second separator will hardly ever be used.
56
57B<XN_FLAG_SEP_COMMA_PLUS> uses comma and plus as separators. B<XN_FLAG_SEP_CPLUS_SPC>
58uses comma and plus with spaces: this is more readable that plain comma and plus.
59B<XN_FLAG_SEP_SPLUS_SPC> uses spaced semicolon and plus. B<XN_FLAG_SEP_MULTILINE> uses
60spaced newline and plus respectively.
61
62If B<XN_FLAG_DN_REV> is set the whole DN is printed in reversed order.
63
64The fields B<XN_FLAG_FN_SN>, B<XN_FLAG_FN_LN>, B<XN_FLAG_FN_OID>,
65B<XN_FLAG_FN_NONE> determine how a field name is displayed. It will
66use the short name (e.g. CN) the long name (e.g. commonName) always
67use OID numerical form (normally OIDs are only used if the field name is not
68recognised) and no field name respectively.
69
70If B<XN_FLAG_SPC_EQ> is set then spaces will be placed around the '=' character
71separating field names and values.
72
73If B<XN_FLAG_DUMP_UNKNOWN_FIELDS> is set then the encoding of unknown fields is
74printed instead of the values.
75
76If B<XN_FLAG_FN_ALIGN> is set then field names are padded to 20 characters: this
77is only of use for multiline format.
78
79Additionally all the options supported by ASN1_STRING_print_ex() can be used to
80control how each field value is displayed.
81
82In addition a number options can be set for commonly used formats.
83
84B<XN_FLAG_RFC2253> sets options which produce an output compatible with RFC2253 it
85is equivalent to:
86 B<ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV | XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS>
87
88
89B<XN_FLAG_ONELINE> is a more readable one line format it is the same as:
90 B<ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC | XN_FLAG_SPC_EQ | XN_FLAG_FN_SN>
91
92B<XN_FLAG_MULTILINE> is a multiline format is is the same as:
93 B<ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE | XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN>
94
95B<XN_FLAG_COMPAT> uses a format identical to X509_NAME_print(): in fact it calls X509_NAME_print() internally.
96
97=head1 SEE ALSO
98
99L<ASN1_STRING_print_ex(3)|ASN1_STRING_print_ex(3)>
100
101=head1 HISTORY
102
103TBA
104
105=cut
diff --git a/src/lib/libcrypto/doc/X509_new.pod b/src/lib/libcrypto/doc/X509_new.pod
new file mode 100644
index 0000000000..fd5fc65ce1
--- /dev/null
+++ b/src/lib/libcrypto/doc/X509_new.pod
@@ -0,0 +1,37 @@
1=pod
2
3=head1 NAME
4
5X509_new, X509_free - X509 certificate ASN1 allocation functions
6
7=head1 SYNOPSIS
8
9 X509 *X509_new(void);
10 void X509_free(X509 *a);
11
12=head1 DESCRIPTION
13
14The X509 ASN1 allocation routines, allocate and free an
15X509 structure, which represents an X509 certificate.
16
17X509_new() allocates and initializes a X509 structure.
18
19X509_free() frees up the B<X509> structure B<a>.
20
21=head1 RETURN VALUES
22
23If the allocation fails, X509_new() returns B<NULL> and sets an error
24code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
25Otherwise it returns a pointer to the newly allocated structure.
26
27X509_free() returns no value.
28
29=head1 SEE ALSO
30
31L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509(3)|d2i_X509(3)>
32
33=head1 HISTORY
34
35X509_new() and X509_free() are available in all versions of SSLeay and OpenSSL.
36
37=cut
diff --git a/src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod b/src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod
new file mode 100644
index 0000000000..45bb18492c
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod
@@ -0,0 +1,29 @@
1=pod
2
3=head1 NAME
4
5d2i_ASN1_OBJECT, i2d_ASN1_OBJECT - ASN1 OBJECT IDENTIFIER functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/objects.h>
10
11 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp, long length);
12 int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an ASN1 OBJECT IDENTIFIER.
17
18Othewise these behave in a similar way to d2i_X509() and i2d_X509()
19described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
20
21=head1 SEE ALSO
22
23L<d2i_X509(3)|d2i_X509(3)>
24
25=head1 HISTORY
26
27TBA
28
29=cut
diff --git a/src/lib/libcrypto/doc/d2i_DSAPublicKey.pod b/src/lib/libcrypto/doc/d2i_DSAPublicKey.pod
new file mode 100644
index 0000000000..6ebd30427b
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_DSAPublicKey.pod
@@ -0,0 +1,82 @@
1=pod
2
3=head1 NAME
4
5d2i_DSAPublicKey, i2d_DSAPublicKey, d2i_DSAPrivateKey, i2d_DSAPrivateKey,
6d2i_DSA_PUBKEY, i2d_DSA_PUBKEY, d2i_DSA_SIG, i2d_DSA_SIG - DSA key encoding
7and parsing functions.
8
9=head1 SYNOPSIS
10
11 #include <openssl/dsa.h>
12
13 DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
14
15 int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
16
17 DSA * d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);
18
19 int i2d_DSA_PUBKEY(const DSA *a, unsigned char **pp);
20
21 DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
22
23 int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
24
25 DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
26
27 int i2d_DSAparams(const DSA *a, unsigned char **pp);
28
29 DSA * d2i_DSA_SIG(DSA_SIG **a, const unsigned char **pp, long length);
30
31 int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
32
33=head1 DESCRIPTION
34
35d2i_DSAPublicKey() and i2d_DSAPublicKey() decode and encode the DSA public key
36components structure.
37
38d2i_DSA_PUKEY() and i2d_DSA_PUKEY() decode and encode an DSA public key using a
39SubjectPublicKeyInfo (certificate public key) structure.
40
41d2i_DSAPrivateKey(), i2d_DSAPrivateKey() decode and encode the DSA private key
42components.
43
44d2i_DSAparams(), i2d_DSAparams() decode and encode the DSA parameters using
45a B<Dss-Parms> structure as defined in RFC2459.
46
47d2i_DSA_SIG(), i2d_DSA_SIG() decode and encode a DSA signature using a
48B<Dss-Sig-Value> structure as defined in RFC2459.
49
50The usage of all of these functions is similar to the d2i_X509() and
51i2d_X509() described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
52
53=head1 NOTES
54
55The B<DSA> structure passed to the private key encoding functions should have
56all the private key components present.
57
58The data encoded by the private key functions is unencrypted and therefore
59offers no private key security.
60
61The B<DSA_PUBKEY> functions should be used in preference to the B<DSAPublicKey>
62functions when encoding public keys because they use a standard format.
63
64The B<DSAPublicKey> functions use an non standard format the actual data encoded
65depends on the value of the B<write_params> field of the B<a> key parameter.
66If B<write_params> is zero then only the B<pub_key> field is encoded as an
67B<INTEGER>. If B<write_params> is 1 then a B<SEQUENCE> consisting of the
68B<p>, B<q>, B<g> and B<pub_key> respectively fields are encoded.
69
70The B<DSAPrivateKey> functions also use a non standard structure consiting
71consisting of a SEQUENCE containing the B<p>, B<q>, B<g> and B<pub_key> and
72B<priv_key> fields respectively.
73
74=head1 SEE ALSO
75
76L<d2i_X509(3)|d2i_X509(3)>
77
78=head1 HISTORY
79
80TBA
81
82=cut
diff --git a/src/lib/libcrypto/doc/d2i_X509.pod b/src/lib/libcrypto/doc/d2i_X509.pod
new file mode 100644
index 0000000000..5e3c3d0985
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_X509.pod
@@ -0,0 +1,231 @@
1=pod
2
3=head1 NAME
4
5d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio,
6i2d_X509_fp - X509 encode and decode functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 X509 *d2i_X509(X509 **px, unsigned char **in, int len);
13 int i2d_X509(X509 *x, unsigned char **out);
14
15 X509 *d2i_X509_bio(BIO *bp, X509 **x);
16 X509 *d2i_X509_fp(FILE *fp, X509 **x);
17
18 int i2d_X509_bio(X509 *x, BIO *bp);
19 int i2d_X509_fp(X509 *x, FILE *fp);
20
21=head1 DESCRIPTION
22
23The X509 encode and decode routines encode and parse an
24B<X509> structure, which represents an X509 certificate.
25
26d2i_X509() attempts to decode B<len> bytes at B<*out>. If
27successful a pointer to the B<X509> structure is returned. If an error
28occurred then B<NULL> is returned. If B<px> is not B<NULL> then the
29returned structure is written to B<*px>. If B<*px> is not B<NULL>
30then it is assumed that B<*px> contains a valid B<X509>
31structure and an attempt is made to reuse it. If the call is
32successful B<*out> is incremented to the byte following the
33parsed data.
34
35i2d_X509() encodes the structure pointed to by B<x> into DER format.
36If B<out> is not B<NULL> is writes the DER encoded data to the buffer
37at B<*out>, and increments it to point after the data just written.
38If the return value is negative an error occurred, otherwise it
39returns the length of the encoded data.
40
41For OpenSSL 0.9.7 and later if B<*out> is B<NULL> memory will be
42allocated for a buffer and the encoded data written to it. In this
43case B<*out> is not incremented and it points to the start of the
44data just written.
45
46d2i_X509_bio() is similar to d2i_X509() except it attempts
47to parse data from BIO B<bp>.
48
49d2i_X509_fp() is similar to d2i_X509() except it attempts
50to parse data from FILE pointer B<fp>.
51
52i2d_X509_bio() is similar to i2d_X509() except it writes
53the encoding of the structure B<x> to BIO B<bp> and it
54returns 1 for success and 0 for failure.
55
56i2d_X509_fp() is similar to i2d_X509() except it writes
57the encoding of the structure B<x> to BIO B<bp> and it
58returns 1 for success and 0 for failure.
59
60=head1 NOTES
61
62The letters B<i> and B<d> in for example B<i2d_X509> stand for
63"internal" (that is an internal C structure) and "DER". So that
64B<i2d_X509> converts from internal to DER.
65
66The functions can also understand B<BER> forms.
67
68The actual X509 structure passed to i2d_X509() must be a valid
69populated B<X509> structure it can B<not> simply be fed with an
70empty structure such as that returned by X509_new().
71
72The encoded data is in binary form and may contain embedded zeroes.
73Therefore any FILE pointers or BIOs should be opened in binary mode.
74Functions such as B<strlen()> will B<not> return the correct length
75of the encoded structure.
76
77The ways that B<*in> and B<*out> are incremented after the operation
78can trap the unwary. See the B<WARNINGS> section for some common
79errors.
80
81The reason for the auto increment behaviour is to reflect a typical
82usage of ASN1 functions: after one structure is encoded or decoded
83another will processed after it.
84
85=head1 EXAMPLES
86
87Allocate and encode the DER encoding of an X509 structure:
88
89 int len;
90 unsigned char *buf, *p;
91
92 len = i2d_X509(x, NULL);
93
94 buf = OPENSSL_malloc(len);
95
96 if (buf == NULL)
97 /* error */
98
99 p = buf;
100
101 i2d_X509(x, &p);
102
103If you are using OpenSSL 0.9.7 or later then this can be
104simplified to:
105
106
107 int len;
108 unsigned char *buf;
109
110 buf = NULL;
111
112 len = i2d_X509(x, &buf);
113
114 if (len < 0)
115 /* error */
116
117Attempt to decode a buffer:
118
119 X509 *x;
120
121 unsigned char *buf, *p;
122
123 int len;
124
125 /* Something to setup buf and len */
126
127 p = buf;
128
129 x = d2i_X509(NULL, &p, len);
130
131 if (x == NULL)
132 /* Some error */
133
134Alternative technique:
135
136 X509 *x;
137
138 unsigned char *buf, *p;
139
140 int len;
141
142 /* Something to setup buf and len */
143
144 p = buf;
145
146 x = NULL;
147
148 if(!d2i_X509(&x, &p, len))
149 /* Some error */
150
151
152=head1 WARNINGS
153
154The use of temporary variable is mandatory. A common
155mistake is to attempt to use a buffer directly as follows:
156
157 int len;
158 unsigned char *buf;
159
160 len = i2d_X509(x, NULL);
161
162 buf = OPENSSL_malloc(len);
163
164 if (buf == NULL)
165 /* error */
166
167 i2d_X509(x, &buf);
168
169 /* Other stuff ... */
170
171 OPENSSL_free(buf);
172
173This code will result in B<buf> apparently containing garbage because
174it was incremented after the call to point after the data just written.
175Also B<buf> will no longer contain the pointer allocated by B<OPENSSL_malloc()>
176and the subsequent call to B<OPENSSL_free()> may well crash.
177
178The auto allocation feature (setting buf to NULL) only works on OpenSSL
1790.9.7 and later. Attempts to use it on earlier versions will typically
180cause a segmentation violation.
181
182Another trap to avoid is misuse of the B<xp> argument to B<d2i_X509()>:
183
184 X509 *x;
185
186 if (!d2i_X509(&x, &p, len))
187 /* Some error */
188
189This will probably crash somewhere in B<d2i_X509()>. The reason for this
190is that the variable B<x> is uninitialized and an attempt will be made to
191interpret its (invalid) value as an B<X509> structure, typically causing
192a segmentation violation. If B<x> is set to NULL first then this will not
193happen.
194
195=head1 BUGS
196
197In some versions of OpenSSL the "reuse" behaviour of d2i_X509() when
198B<*px> is valid is broken and some parts of the reused structure may
199persist if they are not present in the new one. As a result the use
200of this "reuse" behaviour is strongly discouraged.
201
202i2d_X509() will not return an error in many versions of OpenSSL,
203if mandatory fields are not initialized due to a programming error
204then the encoded structure may contain invalid data or omit the
205fields entirely and will not be parsed by d2i_X509(). This may be
206fixed in future so code should not assume that i2d_X509() will
207always succeed.
208
209=head1 RETURN VALUES
210
211d2i_X509(), d2i_X509_bio() and d2i_X509_fp() return a valid B<X509> structure
212or B<NULL> if an error occurs. The error code that can be obtained by
213L<ERR_get_error(3)|ERR_get_error(3)>.
214
215i2d_X509(), i2d_X509_bio() and i2d_X509_fp() return a the number of bytes
216successfully encoded or a negative value if an error occurs. The error code
217can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
218
219i2d_X509_bio() and i2d_X509_fp() returns 1 for success and 0 if an error
220occurs The error code can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
221
222=head1 SEE ALSO
223
224L<ERR_get_error(3)|ERR_get_error(3)>
225
226=head1 HISTORY
227
228d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio and i2d_X509_fp
229are available in all versions of SSLeay and OpenSSL.
230
231=cut
diff --git a/src/lib/libcrypto/doc/d2i_X509_ALGOR.pod b/src/lib/libcrypto/doc/d2i_X509_ALGOR.pod
new file mode 100644
index 0000000000..9e5cd92ca7
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_X509_ALGOR.pod
@@ -0,0 +1,30 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_ALGOR, i2d_X509_ALGOR - AlgorithmIdentifier functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/x509.h>
10
11 X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, unsigned char **pp, long length);
12 int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an B<X509_ALGOR> structure which is
17equivalent to the B<AlgorithmIdentifier> structure.
18
19Othewise these behave in a similar way to d2i_X509() and i2d_X509()
20described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
21
22=head1 SEE ALSO
23
24L<d2i_X509(3)|d2i_X509(3)>
25
26=head1 HISTORY
27
28TBA
29
30=cut
diff --git a/src/lib/libcrypto/doc/d2i_X509_CRL.pod b/src/lib/libcrypto/doc/d2i_X509_CRL.pod
new file mode 100644
index 0000000000..06c5b23c09
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_X509_CRL.pod
@@ -0,0 +1,37 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_CRL, i2d_X509_CRL, d2i_X509_CRL_bio, d2i_509_CRL_fp,
6i2d_X509_CRL_bio, i2d_X509_CRL_fp - PKCS#10 certificate request functions.
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 X509_CRL *d2i_X509_CRL(X509_CRL **a, unsigned char **pp, long length);
13 int i2d_X509_CRL(X509_CRL *a, unsigned char **pp);
14
15 X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **x);
16 X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **x);
17
18 int i2d_X509_CRL_bio(X509_CRL *x, BIO *bp);
19 int i2d_X509_CRL_fp(X509_CRL *x, FILE *fp);
20
21=head1 DESCRIPTION
22
23These functions decode and encode an X509 CRL (certificate revocation
24list).
25
26Othewise the functions behave in a similar way to d2i_X509() and i2d_X509()
27described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
28
29=head1 SEE ALSO
30
31L<d2i_X509(3)|d2i_X509(3)>
32
33=head1 HISTORY
34
35TBA
36
37=cut
diff --git a/src/lib/libcrypto/doc/d2i_X509_NAME.pod b/src/lib/libcrypto/doc/d2i_X509_NAME.pod
new file mode 100644
index 0000000000..343ffe1519
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_X509_NAME.pod
@@ -0,0 +1,31 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_NAME, i2d_X509_NAME - X509_NAME encoding functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/x509.h>
10
11 X509_NAME *d2i_X509_NAME(X509_NAME **a, unsigned char **pp, long length);
12 int i2d_X509_NAME(X509_NAME *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an B<X509_NAME> structure which is the
17the same as the B<Name> type defined in RFC2459 (and elsewhere) and used
18for example in certificate subject and issuer names.
19
20Othewise the functions behave in a similar way to d2i_X509() and i2d_X509()
21described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
22
23=head1 SEE ALSO
24
25L<d2i_X509(3)|d2i_X509(3)>
26
27=head1 HISTORY
28
29TBA
30
31=cut
diff --git a/src/lib/libcrypto/doc/d2i_X509_REQ.pod b/src/lib/libcrypto/doc/d2i_X509_REQ.pod
new file mode 100644
index 0000000000..be4ad68257
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_X509_REQ.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_REQ, i2d_X509_REQ, d2i_X509_REQ_bio, d2i_X509_REQ_fp,
6i2d_X509_REQ_bio, i2d_X509_REQ_fp - PKCS#10 certificate request functions.
7
8=head1 SYNOPSIS
9
10 #include <openssl/x509.h>
11
12 X509_REQ *d2i_X509_REQ(X509_REQ **a, unsigned char **pp, long length);
13 int i2d_X509_REQ(X509_REQ *a, unsigned char **pp);
14
15 X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **x);
16 X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **x);
17
18 int i2d_X509_REQ_bio(X509_REQ *x, BIO *bp);
19 int i2d_X509_REQ_fp(X509_REQ *x, FILE *fp);
20
21=head1 DESCRIPTION
22
23These functions decode and encode a PKCS#10 certificate request.
24
25Othewise these behave in a similar way to d2i_X509() and i2d_X509()
26described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
27
28=head1 SEE ALSO
29
30L<d2i_X509(3)|d2i_X509(3)>
31
32=head1 HISTORY
33
34TBA
35
36=cut
diff --git a/src/lib/libcrypto/doc/d2i_X509_SIG.pod b/src/lib/libcrypto/doc/d2i_X509_SIG.pod
new file mode 100644
index 0000000000..e48fd79a51
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_X509_SIG.pod
@@ -0,0 +1,30 @@
1=pod
2
3=head1 NAME
4
5d2i_X509_SIG, i2d_X509_SIG - DigestInfo functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/x509.h>
10
11 X509_SIG *d2i_X509_SIG(X509_SIG **a, unsigned char **pp, long length);
12 int i2d_X509_SIG(X509_SIG *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an X509_SIG structure which is
17equivalent to the B<DigestInfo> structure defined in PKCS#1 and PKCS#7.
18
19Othewise these behave in a similar way to d2i_X509() and i2d_X509()
20described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
21
22=head1 SEE ALSO
23
24L<d2i_X509(3)|d2i_X509(3)>
25
26=head1 HISTORY
27
28TBA
29
30=cut
diff --git a/src/lib/libcrypto/doc/engine.pod b/src/lib/libcrypto/doc/engine.pod
index 61e0264bb7..c77dad5562 100644
--- a/src/lib/libcrypto/doc/engine.pod
+++ b/src/lib/libcrypto/doc/engine.pod
@@ -187,7 +187,7 @@ tell which one you are dealing with at any given point in time (after all
187they are both simply (ENGINE *) pointers, the difference is in the way they 187they are both simply (ENGINE *) pointers, the difference is in the way they
188are used). 188are used).
189 189
190=head3 Structural references 190I<Structural references>
191 191
192This basic type of reference is typically used for creating new ENGINEs 192This basic type of reference is typically used for creating new ENGINEs
193dynamically, iterating across OpenSSL's internal linked-list of loaded 193dynamically, iterating across OpenSSL's internal linked-list of loaded
@@ -224,7 +224,7 @@ To clarify a particular function's handling of references, one should
224always consult that function's documentation "man" page, or failing that 224always consult that function's documentation "man" page, or failing that
225the openssl/engine.h header file includes some hints. 225the openssl/engine.h header file includes some hints.
226 226
227=head3 Functional references 227I<Functional references>
228 228
229As mentioned, functional references exist when the cryptographic 229As mentioned, functional references exist when the cryptographic
230functionality of an ENGINE is required to be available. A functional 230functionality of an ENGINE is required to be available. A functional
@@ -386,7 +386,7 @@ things, so we will simply illustrate the consequences as they apply to a
386couple of simple cases and leave developers to consider these and the 386couple of simple cases and leave developers to consider these and the
387source code to openssl's builtin utilities as guides. 387source code to openssl's builtin utilities as guides.
388 388
389=head3 Using a specific ENGINE implementation 389I<Using a specific ENGINE implementation>
390 390
391Here we'll assume an application has been configured by its user or admin 391Here we'll assume an application has been configured by its user or admin
392to want to use the "ACME" ENGINE if it is available in the version of 392to want to use the "ACME" ENGINE if it is available in the version of
@@ -418,7 +418,7 @@ illustrates how to approach this;
418 /* Release the structural reference from ENGINE_by_id() */ 418 /* Release the structural reference from ENGINE_by_id() */
419 ENGINE_free(e); 419 ENGINE_free(e);
420 420
421=head3 Automatically using builtin ENGINE implementations 421I<Automatically using builtin ENGINE implementations>
422 422
423Here we'll assume we want to load and register all ENGINE implementations 423Here we'll assume we want to load and register all ENGINE implementations
424bundled with OpenSSL, such that for any cryptographic algorithm required by 424bundled with OpenSSL, such that for any cryptographic algorithm required by
@@ -469,7 +469,7 @@ in same cases both. ENGINE implementations should provide indications of
469this in the descriptions attached to builtin control commands and/or in 469this in the descriptions attached to builtin control commands and/or in
470external product documentation. 470external product documentation.
471 471
472=head3 Issuing control commands to an ENGINE 472I<Issuing control commands to an ENGINE>
473 473
474Let's illustrate by example; a function for which the caller supplies the 474Let's illustrate by example; a function for which the caller supplies the
475name of the ENGINE it wishes to use, a table of string-pairs for use before 475name of the ENGINE it wishes to use, a table of string-pairs for use before
@@ -526,7 +526,7 @@ return success without doing anything. In this case we assume the user is
526only supplying commands specific to the given ENGINE so we set this to 526only supplying commands specific to the given ENGINE so we set this to
527FALSE. 527FALSE.
528 528
529=head3 Discovering supported control commands 529I<Discovering supported control commands>
530 530
531It is possible to discover at run-time the names, numerical-ids, descriptions 531It is possible to discover at run-time the names, numerical-ids, descriptions
532and input parameters of the control commands supported from a structural 532and input parameters of the control commands supported from a structural
diff --git a/src/lib/libcrypto/mem_clr.c b/src/lib/libcrypto/mem_clr.c
new file mode 100644
index 0000000000..e4b7f540b0
--- /dev/null
+++ b/src/lib/libcrypto/mem_clr.c
@@ -0,0 +1,75 @@
1/* crypto/mem_clr.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2002.
4 */
5/* ====================================================================
6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <string.h>
60#include <openssl/crypto.h>
61
62unsigned char cleanse_ctr = 0;
63
64void OPENSSL_cleanse(void *ptr, size_t len)
65 {
66 unsigned char *p = ptr;
67 size_t loop = len;
68 while(loop--)
69 {
70 *(p++) = cleanse_ctr;
71 cleanse_ctr += (17 + (unsigned char)((int)p & 0xF));
72 }
73 if(memchr(ptr, cleanse_ctr, len))
74 cleanse_ctr += 63;
75 }