diff options
author | markus <> | 2003-05-11 21:36:58 +0000 |
---|---|---|
committer | markus <> | 2003-05-11 21:36:58 +0000 |
commit | 5e3b0c7b72d8aaff81be19f7eb4d18887c9b628e (patch) | |
tree | 856136ff65a464744cae1b12c4aa538694a479c6 /src | |
parent | 122b1fe1ae368cb84ac4ef26348c8944757cb720 (diff) | |
parent | 1c98a87f0daac81245653c227eb2f2508a22a965 (diff) | |
download | openbsd-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')
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 | |||
75 | BN_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 | |||
99 | BN_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 | |||
122 | void 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 | |||
142 | BN_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 | |||
153 | BN_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 | ||
176 | BN_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 | ||
200 | BN_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 | |||
319 | void 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 | |||
424 | void 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 | |||
465 | void 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 | |||
542 | void 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 | |||
5 | EVP_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 | |||
17 | The EVP_PKEY_new() function allocates an empty B<EVP_PKEY> | ||
18 | structure which is used by OpenSSL to store private keys. | ||
19 | |||
20 | EVP_PKEY_free() frees up the private key B<key>. | ||
21 | |||
22 | =head1 NOTES | ||
23 | |||
24 | The B<EVP_PKEY> structure is used by various OpenSSL functions | ||
25 | which require a general private key without reference to any | ||
26 | particular algorithm. | ||
27 | |||
28 | The structure returned by EVP_PKEY_new() is empty. To add a | ||
29 | private key to this empty structure the functions described in | ||
30 | L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)> should be used. | ||
31 | |||
32 | =head1 RETURN VALUES | ||
33 | |||
34 | EVP_PKEY_new() returns either the newly allocated B<EVP_PKEY> | ||
35 | structure of B<NULL> if an error occurred. | ||
36 | |||
37 | EVP_PKEY_free() does not return a value. | ||
38 | |||
39 | =head1 SEE ALSO | ||
40 | |||
41 | L<EVP_PKEY_set1_RSA(3)|EVP_PKEY_set1_RSA(3)> | ||
42 | |||
43 | =head1 HISTORY | ||
44 | |||
45 | TBA | ||
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 | |||
5 | EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH, EVP_PKEY_set1_EC_KEY, | ||
6 | EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA, EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY, | ||
7 | EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH, EVP_PKEY_assign_EC_KEY, | ||
8 | EVP_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 | |||
33 | EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and | ||
34 | EVP_PKEY_set1_EC_KEY() set the key referenced by B<pkey> to B<key>. | ||
35 | |||
36 | EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and | ||
37 | EVP_PKEY_get1_EC_KEY() return the referenced key in B<pkey> or | ||
38 | B<NULL> if the key is not of the correct type. | ||
39 | |||
40 | EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() | ||
41 | and EVP_PKEY_assign_EC_KEY() also set the referenced key to B<key> | ||
42 | however these use the supplied B<key> internally and so B<key> | ||
43 | will be freed when the parent B<pkey> is freed. | ||
44 | |||
45 | EVP_PKEY_type() returns the type of key corresponding to the value | ||
46 | B<type>. The type of a key can be obtained with | ||
47 | EVP_PKEY_type(pkey->type). The return value will be EVP_PKEY_RSA, | ||
48 | EVP_PKEY_DSA, EVP_PKEY_DH or EVP_PKEY_EC for the corresponding | ||
49 | key types or NID_undef if the key type is unassigned. | ||
50 | |||
51 | =head1 NOTES | ||
52 | |||
53 | In accordance with the OpenSSL naming convention the key obtained | ||
54 | from or assigned to the B<pkey> using the B<1> functions must be | ||
55 | freed as well as B<pkey>. | ||
56 | |||
57 | EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() | ||
58 | EVP_PKEY_assign_EC_KEY() are implemented as macros. | ||
59 | |||
60 | =head1 RETURN VALUES | ||
61 | |||
62 | EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and | ||
63 | EVP_PKEY_set1_EC_KEY() return 1 for success or 0 for failure. | ||
64 | |||
65 | EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and | ||
66 | EVP_PKEY_get1_EC_KEY() return the referenced key or B<NULL> if | ||
67 | an error occurred. | ||
68 | |||
69 | EVP_PKEY_assign_RSA() EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() | ||
70 | and EVP_PKEY_assign_EC_KEY() return 1 for success and 0 for failure. | ||
71 | |||
72 | =head1 SEE ALSO | ||
73 | |||
74 | L<EVP_PKEY_new(3)|EVP_PKEY_new(3)> | ||
75 | |||
76 | =head1 HISTORY | ||
77 | |||
78 | TBA | ||
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 | |||
5 | OBJ_nid2obj, OBJ_nid2ln, OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid, OBJ_ln2nid, OBJ_sn2nid, | ||
6 | OBJ_cmp, OBJ_dup, OBJ_txt2obj, OBJ_obj2txt, OBJ_create, OBJ_cleanup - ASN1 object utility | ||
7 | functions | ||
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 | |||
32 | The ASN1 object utility functions process ASN1_OBJECT structures which are | ||
33 | a representation of the ASN1 OBJECT IDENTIFIER (OID) type. | ||
34 | |||
35 | OBJ_nid2obj(), OBJ_nid2ln() and OBJ_nid2sn() convert the NID B<n> to | ||
36 | an ASN1_OBJECT structure, its long name and its short name respectively, | ||
37 | or B<NULL> is an error occurred. | ||
38 | |||
39 | OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() return the corresponding NID | ||
40 | for the object B<o>, the long name <ln> or the short name <sn> respectively | ||
41 | or NID_undef if an error occurred. | ||
42 | |||
43 | OBJ_txt2nid() returns NID corresponding to text string <s>. B<s> can be | ||
44 | a long name, a short name or the numerical respresentation of an object. | ||
45 | |||
46 | OBJ_txt2obj() converts the text string B<s> into an ASN1_OBJECT structure. | ||
47 | If B<no_name> is 0 then long names and short names will be interpreted | ||
48 | as well as numerical forms. If B<no_name> is 1 only the numerical form | ||
49 | is acceptable. | ||
50 | |||
51 | OBJ_obj2txt() converts the B<ASN1_OBJECT> B<a> into a textual representation. | ||
52 | The representation is written as a null terminated string to B<buf> | ||
53 | at most B<buf_len> bytes are written, truncating the result if necessary. | ||
54 | The total amount of space required is returned. If B<no_name> is 0 then | ||
55 | if the object has a long or short name then that will be used, otherwise | ||
56 | the numerical form will be used. If B<no_name> is 1 then the numerical | ||
57 | form will always be used. | ||
58 | |||
59 | OBJ_cmp() compares B<a> to B<b>. If the two are identical 0 is returned. | ||
60 | |||
61 | OBJ_dup() returns a copy of B<o>. | ||
62 | |||
63 | OBJ_create() adds a new object to the internal table. B<oid> is the | ||
64 | numerical form of the object, B<sn> the short name and B<ln> the | ||
65 | long name. A new NID is returned for the created object. | ||
66 | |||
67 | OBJ_cleanup() cleans up OpenSSLs internal object table: this should | ||
68 | be called before an application exits if any new objects were added | ||
69 | using OBJ_create(). | ||
70 | |||
71 | =head1 NOTES | ||
72 | |||
73 | Objects in OpenSSL can have a short name, a long name and a numerical | ||
74 | identifier (NID) associated with them. A standard set of objects is | ||
75 | represented in an internal table. The appropriate values are defined | ||
76 | in the header file B<objects.h>. | ||
77 | |||
78 | For 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 | |||
84 | New objects can be added by calling OBJ_create(). | ||
85 | |||
86 | Table objects have certain advantages over other objects: for example | ||
87 | their NIDs can be used in a C language switch statement. They are | ||
88 | also static constant structures which are shared: that is there | ||
89 | is only a single constant structure for each table object. | ||
90 | |||
91 | Objects which are not in the table have the NID value NID_undef. | ||
92 | |||
93 | Objects do not need to be in the internal tables to be processed, | ||
94 | the functions OBJ_txt2obj() and OBJ_obj2txt() can process the numerical | ||
95 | form of an OID. | ||
96 | |||
97 | =head1 EXAMPLES | ||
98 | |||
99 | Create an object for B<commonName>: | ||
100 | |||
101 | ASN1_OBJECT *o; | ||
102 | o = OBJ_nid2obj(NID_commonName); | ||
103 | |||
104 | Check if an object is B<commonName> | ||
105 | |||
106 | if (OBJ_obj2nid(obj) == NID_commonName) | ||
107 | /* Do something */ | ||
108 | |||
109 | Create 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 | |||
117 | Create a new object directly: | ||
118 | |||
119 | obj = OBJ_txt2obj("1.2.3.4", 1); | ||
120 | |||
121 | =head1 BUGS | ||
122 | |||
123 | OBJ_obj2txt() is awkward and messy to use: it doesn't follow the | ||
124 | convention of other OpenSSL functions where the buffer can be set | ||
125 | to B<NULL> to determine the amount of data that should be written. | ||
126 | Instead B<buf> must point to a valid buffer and B<buf_len> should | ||
127 | be set to a positive value. A buffer length of 80 should be more | ||
128 | than enough to handle any OID encountered in practice. | ||
129 | |||
130 | =head1 RETURN VALUES | ||
131 | |||
132 | OBJ_nid2obj() returns an B<ASN1_OBJECT> structure or B<NULL> is an | ||
133 | error occurred. | ||
134 | |||
135 | OBJ_nid2ln() and OBJ_nid2sn() returns a valid string or B<NULL> | ||
136 | on error. | ||
137 | |||
138 | OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() and OBJ_txt2nid() return | ||
139 | a NID or B<NID_undef> on error. | ||
140 | |||
141 | =head1 SEE ALSO | ||
142 | |||
143 | L<ERR_get_error(3)|ERR_get_error(3)> | ||
144 | |||
145 | =head1 HISTORY | ||
146 | |||
147 | TBA | ||
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 | |||
5 | PKCS12_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 | |||
16 | PKCS12_create() creates a PKCS#12 structure. | ||
17 | |||
18 | B<pass> is the passphrase to use. B<name> is the B<friendlyName> to use for | ||
19 | the supplied certifictate and key. B<pkey> is the private key to include in | ||
20 | the structure and B<cert> its corresponding certificates. B<ca>, if not B<NULL> | ||
21 | is an optional set of certificates to also include in the structure. | ||
22 | |||
23 | B<nid_key> and B<nid_cert> are the encryption algorithms that should be used | ||
24 | for the key and certificate respectively. B<iter> is the encryption algorithm | ||
25 | iteration count to use and B<mac_iter> is the MAC iteration count to use. | ||
26 | B<keytype> is the type of key. | ||
27 | |||
28 | =head1 NOTES | ||
29 | |||
30 | The parameters B<nid_key>, B<nid_cert>, B<iter>, B<mac_iter> and B<keytype> | ||
31 | can all be set to zero and sensible defaults will be used. | ||
32 | |||
33 | These defaults are: 40 bit RC2 encryption for certificates, triple DES | ||
34 | encryption for private keys, a key iteration count of PKCS12_DEFAULT_ITER | ||
35 | (currently 2048) and a MAC iteration count of 1. | ||
36 | |||
37 | The default MAC iteration count is 1 in order to retain compatibility with | ||
38 | old software which did not interpret MAC iteration counts. If such compatibility | ||
39 | is not required then B<mac_iter> should be set to PKCS12_DEFAULT_ITER. | ||
40 | |||
41 | B<keytype> adds a flag to the store private key. This is a non standard extension | ||
42 | that is only currently interpreted by MSIE. If set to zero the flag is omitted, | ||
43 | if set to B<KEY_SIG> the key can be used for signing only, if set to B<KEY_EX> | ||
44 | it can be used for signing and encryption. This option was useful for old | ||
45 | export grade software which could use signing only keys of arbitrary size but | ||
46 | had restrictions on the permissible sizes of keys which could be used for | ||
47 | encryption. | ||
48 | |||
49 | =head1 SEE ALSO | ||
50 | |||
51 | L<d2i_PKCS12(3)|d2i_PKCS12(3)> | ||
52 | |||
53 | =head1 HISTORY | ||
54 | |||
55 | PKCS12_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 | |||
5 | PKCS12_parse - parse a PKCS#12 structure | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | #include <openssl/pkcs12.h> | ||
10 | |||
11 | int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca); | ||
12 | |||
13 | =head1 DESCRIPTION | ||
14 | |||
15 | PKCS12_parse() parses a PKCS12 structure. | ||
16 | |||
17 | B<p12> is the B<PKCS12> structure to parse. B<pass> is the passphrase to use. | ||
18 | If successful the private key will be written to B<*pkey>, the corresponding | ||
19 | certificate to B<*cert> and any additional certificates to B<*ca>. | ||
20 | |||
21 | =head1 NOTES | ||
22 | |||
23 | The parameters B<pkey> and B<cert> cannot be B<NULL>. B<ca> can be <NULL> | ||
24 | in which case additional certificates will be discarded. B<*ca> can also | ||
25 | be a valid STACK in which case additional certificates are appended to | ||
26 | B<*ca>. If B<*ca> is B<NULL> a new STACK will be allocated. | ||
27 | |||
28 | The B<friendlyName> and B<localKeyID> attributes (if present) on each certificate | ||
29 | will be stored in the B<alias> and B<keyid> attributes of the B<X509> structure. | ||
30 | |||
31 | =head1 BUGS | ||
32 | |||
33 | Only a single private key and corresponding certificate is returned by this function. | ||
34 | More complex PKCS#12 files with multiple private keys will only return the first | ||
35 | match. | ||
36 | |||
37 | Only B<friendlyName> and B<localKeyID> attributes are currently stored in certificates. | ||
38 | Other attributes are discarded. | ||
39 | |||
40 | Attributes currently cannot be store in the private key B<EVP_PKEY> structure. | ||
41 | |||
42 | =head1 SEE ALSO | ||
43 | |||
44 | L<d2i_PKCS12(3)|d2i_PKCS12(3)> | ||
45 | |||
46 | =head1 HISTORY | ||
47 | |||
48 | PKCS12_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 | |||
5 | PKCS7_decrypt - decrypt content from a PKCS#7 envelopedData structure | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); | ||
10 | |||
11 | =head1 DESCRIPTION | ||
12 | |||
13 | PKCS7_decrypt() extracts and decrypts the content from a PKCS#7 envelopedData | ||
14 | structure. B<pkey> is the private key of the recipient, B<cert> is the | ||
15 | recipients certificate, B<data> is a BIO to write the content to and | ||
16 | B<flags> is an optional set of flags. | ||
17 | |||
18 | =head1 NOTES | ||
19 | |||
20 | OpenSSL_add_all_algorithms() (or equivalent) should be called before using this | ||
21 | function or errors about unknown algorithms will occur. | ||
22 | |||
23 | Although the recipients certificate is not needed to decrypt the data it is needed | ||
24 | to locate the appropriate (of possible several) recipients in the PKCS#7 structure. | ||
25 | |||
26 | The following flags can be passed in the B<flags> parameter. | ||
27 | |||
28 | If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are deleted | ||
29 | from the content. If the content is not of type B<text/plain> then an error is | ||
30 | returned. | ||
31 | |||
32 | =head1 RETURN VALUES | ||
33 | |||
34 | PKCS7_decrypt() returns either 1 for success or 0 for failure. | ||
35 | The error can be obtained from ERR_get_error(3) | ||
36 | |||
37 | =head1 BUGS | ||
38 | |||
39 | PKCS7_decrypt() must be passed the correct recipient key and certificate. It would | ||
40 | be better if it could look up the correct key and certificate from a database. | ||
41 | |||
42 | The lack of single pass processing and need to hold all data in memory as | ||
43 | mentioned in PKCS7_sign() also applies to PKCS7_verify(). | ||
44 | |||
45 | =head1 SEE ALSO | ||
46 | |||
47 | L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)> | ||
48 | |||
49 | =head1 HISTORY | ||
50 | |||
51 | PKCS7_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 | |||
5 | PKCS7_encrypt - create a PKCS#7 envelopedData structure | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags); | ||
10 | |||
11 | =head1 DESCRIPTION | ||
12 | |||
13 | PKCS7_encrypt() creates and returns a PKCS#7 envelopedData structure. B<certs> | ||
14 | is a list of recipient certificates. B<in> is the content to be encrypted. | ||
15 | B<cipher> is the symmetric cipher to use. B<flags> is an optional set of flags. | ||
16 | |||
17 | =head1 NOTES | ||
18 | |||
19 | Only RSA keys are supported in PKCS#7 and envelopedData so the recipient certificates | ||
20 | supplied to this function must all contain RSA public keys, though they do not have to | ||
21 | be signed using the RSA algorithm. | ||
22 | |||
23 | EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME use because | ||
24 | most clients will support it. | ||
25 | |||
26 | Some old "export grade" clients may only support weak encryption using 40 or 64 bit | ||
27 | RC2. These can be used by passing EVP_rc2_40_cbc() and EVP_rc2_64_cbc() respectively. | ||
28 | |||
29 | The algorithm passed in the B<cipher> parameter must support ASN1 encoding of its | ||
30 | parameters. | ||
31 | |||
32 | Many browsers implement a "sign and encrypt" option which is simply an S/MIME | ||
33 | envelopedData containing an S/MIME signed message. This can be readily produced | ||
34 | by storing the S/MIME signed message in a memory BIO and passing it to | ||
35 | PKCS7_encrypt(). | ||
36 | |||
37 | The following flags can be passed in the B<flags> parameter. | ||
38 | |||
39 | If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended | ||
40 | to the data. | ||
41 | |||
42 | Normally the supplied content is translated into MIME canonical format (as required | ||
43 | by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation occurs. This | ||
44 | option should be used if the supplied data is in binary format otherwise the translation | ||
45 | will corrupt it. If B<PKCS7_BINARY> is set then B<PKCS7_TEXT> is ignored. | ||
46 | |||
47 | =head1 RETURN VALUES | ||
48 | |||
49 | PKCS7_encrypt() returns either a valid PKCS7 structure or NULL if an error occurred. | ||
50 | The error can be obtained from ERR_get_error(3). | ||
51 | |||
52 | =head1 BUGS | ||
53 | |||
54 | The lack of single pass processing and need to hold all data in memory as | ||
55 | mentioned in PKCS7_sign() also applies to PKCS7_verify(). | ||
56 | |||
57 | =head1 SEE ALSO | ||
58 | |||
59 | L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_decrypt(3)|PKCS7_decrypt(3)> | ||
60 | |||
61 | =head1 HISTORY | ||
62 | |||
63 | PKCS7_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 | |||
5 | PKCS7_sign - create a PKCS#7 signedData structure | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, int flags); | ||
10 | |||
11 | =head1 DESCRIPTION | ||
12 | |||
13 | PKCS7_sign() creates and returns a PKCS#7 signedData structure. B<signcert> | ||
14 | is the certificate to sign with, B<pkey> is the corresponsding private key. | ||
15 | B<certs> is an optional additional set of certificates to include in the | ||
16 | PKCS#7 structure (for example any intermediate CAs in the chain). | ||
17 | |||
18 | The data to be signed is read from BIO B<data>. | ||
19 | |||
20 | B<flags> is an optional set of flags. | ||
21 | |||
22 | =head1 NOTES | ||
23 | |||
24 | Any of the following flags (ored together) can be passed in the B<flags> parameter. | ||
25 | |||
26 | Many S/MIME clients expect the signed content to include valid MIME headers. If | ||
27 | the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended | ||
28 | to the data. | ||
29 | |||
30 | If B<PKCS7_NOCERTS> is set the signer's certificate will not be included in the | ||
31 | PKCS7 structure, the signer's certificate must still be supplied in the B<signcert> | ||
32 | parameter though. This can reduce the size of the signature if the signers certificate | ||
33 | can be obtained by other means: for example a previously signed message. | ||
34 | |||
35 | The data being signed is included in the PKCS7 structure, unless B<PKCS7_DETACHED> | ||
36 | is set in which case it is omitted. This is used for PKCS7 detached signatures | ||
37 | which are used in S/MIME plaintext signed messages for example. | ||
38 | |||
39 | Normally the supplied content is translated into MIME canonical format (as required | ||
40 | by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation occurs. This | ||
41 | option should be used if the supplied data is in binary format otherwise the translation | ||
42 | will corrupt it. | ||
43 | |||
44 | The signedData structure includes several PKCS#7 autenticatedAttributes including | ||
45 | the signing time, the PKCS#7 content type and the supported list of ciphers in | ||
46 | an SMIMECapabilities attribute. If B<PKCS7_NOATTR> is set then no authenticatedAttributes | ||
47 | will be used. If B<PKCS7_NOSMIMECAP> is set then just the SMIMECapabilities are | ||
48 | omitted. | ||
49 | |||
50 | If present the SMIMECapabilities attribute indicates support for the following | ||
51 | algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any | ||
52 | of these algorithms is disabled then it will not be included. | ||
53 | |||
54 | =head1 BUGS | ||
55 | |||
56 | PKCS7_sign() is somewhat limited. It does not support multiple signers, some | ||
57 | advanced attributes such as counter signatures are not supported. | ||
58 | |||
59 | The SHA1 digest algorithm is currently always used. | ||
60 | |||
61 | When the signed data is not detached it will be stored in memory within the | ||
62 | B<PKCS7> structure. This effectively limits the size of messages which can be | ||
63 | signed due to memory restraints. There should be a way to sign data without | ||
64 | having to hold it all in memory, this would however require fairly major | ||
65 | revisions of the OpenSSL ASN1 code. | ||
66 | |||
67 | Clear text signing does not store the content in memory but the way PKCS7_sign() | ||
68 | operates means that two passes of the data must typically be made: one to compute | ||
69 | the signatures and a second to output the data along with the signature. There | ||
70 | should be a way to process the data with only a single pass. | ||
71 | |||
72 | =head1 RETURN VALUES | ||
73 | |||
74 | PKCS7_sign() returns either a valid PKCS7 structure or NULL if an error occurred. | ||
75 | The error can be obtained from ERR_get_error(3). | ||
76 | |||
77 | =head1 SEE ALSO | ||
78 | |||
79 | L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_verify(3)|PKCS7_verify(3)> | ||
80 | |||
81 | =head1 HISTORY | ||
82 | |||
83 | PKCS7_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 | |||
5 | PKCS7_verify - verify a PKCS#7 signedData structure | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, int flags); | ||
10 | |||
11 | int PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); | ||
12 | |||
13 | =head1 DESCRIPTION | ||
14 | |||
15 | PKCS7_verify() verifies a PKCS#7 signedData structure. B<p7> is the PKCS7 | ||
16 | structure to verify. B<certs> is a set of certificates in which to search for | ||
17 | the signer's certificate. B<store> is a trusted certficate store (used for | ||
18 | chain verification). B<indata> is the signed data if the content is not | ||
19 | present in B<p7> (that is it is detached). The content is written to B<out> | ||
20 | if it is not NULL. | ||
21 | |||
22 | B<flags> is an optional set of flags, which can be used to modify the verify | ||
23 | operation. | ||
24 | |||
25 | PKCS7_get0_signers() retrieves the signer's certificates from B<p7>, it does | ||
26 | B<not> check their validity or whether any signatures are valid. The B<certs> | ||
27 | and B<flags> parameters have the same meanings as in PKCS7_verify(). | ||
28 | |||
29 | =head1 VERIFY PROCESS | ||
30 | |||
31 | Normally the verify process proceeds as follows. | ||
32 | |||
33 | Initially some sanity checks are performed on B<p7>. The type of B<p7> must | ||
34 | be signedData. There must be at least one signature on the data and if | ||
35 | the content is detached B<indata> cannot be B<NULL>. | ||
36 | |||
37 | An attempt is made to locate all the signer's certificates, first looking in | ||
38 | the B<certs> parameter (if it is not B<NULL>) and then looking in any certificates | ||
39 | contained in the B<p7> structure itself. If any signer's certificates cannot be | ||
40 | located the operation fails. | ||
41 | |||
42 | Each signer's certificate is chain verified using the B<smimesign> purpose and | ||
43 | the supplied trusted certificate store. Any internal certificates in the message | ||
44 | are used as untrusted CAs. If any chain verify fails an error code is returned. | ||
45 | |||
46 | Finally the signed content is read (and written to B<out> is it is not NULL) and | ||
47 | the signature's checked. | ||
48 | |||
49 | If all signature's verify correctly then the function is successful. | ||
50 | |||
51 | Any of the following flags (ored together) can be passed in the B<flags> parameter | ||
52 | to change the default verify behaviour. Only the flag B<PKCS7_NOINTERN> is | ||
53 | meaningful to PKCS7_get0_signers(). | ||
54 | |||
55 | If B<PKCS7_NOINTERN> is set the certificates in the message itself are not | ||
56 | searched when locating the signer's certificate. This means that all the signers | ||
57 | certificates must be in the B<certs> parameter. | ||
58 | |||
59 | If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are deleted | ||
60 | from the content. If the content is not of type B<text/plain> then an error is | ||
61 | returned. | ||
62 | |||
63 | If B<PKCS7_NOVERIFY> is set the signer's certificates are not chain verified. | ||
64 | |||
65 | If B<PKCS7_NOCHAIN> is set then the certificates contained in the message are | ||
66 | not used as untrusted CAs. This means that the whole verify chain (apart from | ||
67 | the signer's certificate) must be contained in the trusted store. | ||
68 | |||
69 | If B<PKCS7_NOSIGS> is set then the signatures on the data are not checked. | ||
70 | |||
71 | =head1 NOTES | ||
72 | |||
73 | One application of B<PKCS7_NOINTERN> is to only accept messages signed by | ||
74 | a small number of certificates. The acceptable certificates would be passed | ||
75 | in the B<certs> parameter. In this case if the signer is not one of the | ||
76 | certificates supplied in B<certs> then the verify will fail because the | ||
77 | signer cannot be found. | ||
78 | |||
79 | Care should be taken when modifying the default verify behaviour, for example | ||
80 | setting B<PKCS7_NOVERIFY|PKCS7_NOSIGS> will totally disable all verification | ||
81 | and any signed message will be considered valid. This combination is however | ||
82 | useful if one merely wishes to write the content to B<out> and its validity | ||
83 | is not considered important. | ||
84 | |||
85 | Chain verification should arguably be performed using the signing time rather | ||
86 | than the current time. However since the signing time is supplied by the | ||
87 | signer it cannot be trusted without additional evidence (such as a trusted | ||
88 | timestamp). | ||
89 | |||
90 | =head1 RETURN VALUES | ||
91 | |||
92 | PKCS7_verify() returns 1 for a successful verification and zero or a negative | ||
93 | value if an error occurs. | ||
94 | |||
95 | PKCS7_get0_signers() returns all signers or B<NULL> if an error occurred. | ||
96 | |||
97 | The error can be obtained from L<ERR_get_error(3)|ERR_get_error(3)> | ||
98 | |||
99 | =head1 BUGS | ||
100 | |||
101 | The trusted certificate store is not searched for the signers certificate, | ||
102 | this is primarily due to the inadequacies of the current B<X509_STORE> | ||
103 | functionality. | ||
104 | |||
105 | The lack of single pass processing and need to hold all data in memory as | ||
106 | mentioned in PKCS7_sign() also applies to PKCS7_verify(). | ||
107 | |||
108 | =head1 SEE ALSO | ||
109 | |||
110 | L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)> | ||
111 | |||
112 | =head1 HISTORY | ||
113 | |||
114 | PKCS7_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 | |||
5 | SMIME_read_PKCS7 - parse S/MIME message. | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont); | ||
10 | |||
11 | =head1 DESCRIPTION | ||
12 | |||
13 | SMIME_read_PKCS7() parses a message in S/MIME format. | ||
14 | |||
15 | B<in> is a BIO to read the message from. | ||
16 | |||
17 | If cleartext signing is used then the content is saved in | ||
18 | a memory bio which is written to B<*bcont>, otherwise | ||
19 | B<*bcont> is set to B<NULL>. | ||
20 | |||
21 | The parsed PKCS#7 structure is returned or B<NULL> if an | ||
22 | error occurred. | ||
23 | |||
24 | =head1 NOTES | ||
25 | |||
26 | If B<*bcont> is not B<NULL> then the message is clear text | ||
27 | signed. B<*bcont> can then be passed to PKCS7_verify() with | ||
28 | the B<PKCS7_DETACHED> flag set. | ||
29 | |||
30 | Otherwise the type of the returned structure can be determined | ||
31 | using PKCS7_type(). | ||
32 | |||
33 | To support future functionality if B<bcont> is not B<NULL> | ||
34 | B<*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 | |||
43 | The MIME parser used by SMIME_read_PKCS7() is somewhat primitive. | ||
44 | While it will handle most S/MIME messages more complex compound | ||
45 | formats may not work. | ||
46 | |||
47 | The parser assumes that the PKCS7 structure is always base64 | ||
48 | encoded and will not handle the case where it is in binary format | ||
49 | or uses quoted printable format. | ||
50 | |||
51 | The use of a memory BIO to hold the signed content limits the size | ||
52 | of message which can be processed due to memory restraints: a | ||
53 | streaming single pass option should be available. | ||
54 | |||
55 | =head1 RETURN VALUES | ||
56 | |||
57 | SMIME_read_PKCS7() returns a valid B<PKCS7> structure or B<NULL> | ||
58 | is an error occurred. The error can be obtained from ERR_get_error(3). | ||
59 | |||
60 | =head1 SEE ALSO | ||
61 | |||
62 | L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_type(3)|PKCS7_type(3)> | ||
63 | L<SMIME_read_PKCS7(3)|SMIME_read_PKCS7(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>, | ||
64 | L<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)> | ||
65 | L<PKCS7_decrypt(3)|PKCS7_decrypt(3)> | ||
66 | |||
67 | =head1 HISTORY | ||
68 | |||
69 | SMIME_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 | |||
5 | SMIME_write_PKCS7 - convert PKCS#7 structure to S/MIME format. | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | int SMIME_write_PKCS7(BIO *out, PKCS7 *p7, BIO *data, int flags); | ||
10 | |||
11 | =head1 DESCRIPTION | ||
12 | |||
13 | SMIME_write_PKCS7() adds the appropriate MIME headers to a PKCS#7 | ||
14 | structure to produce an S/MIME message. | ||
15 | |||
16 | B<out> is the BIO to write the data to. B<p7> is the appropriate | ||
17 | B<PKCS7> structure. If cleartext signing (B<multipart/signed>) is | ||
18 | being used then the signed data must be supplied in the B<data> | ||
19 | argument. B<flags> is an optional set of flags. | ||
20 | |||
21 | =head1 NOTES | ||
22 | |||
23 | The following flags can be passed in the B<flags> parameter. | ||
24 | |||
25 | If B<PKCS7_DETACHED> is set then cleartext signing will be used, | ||
26 | this option only makes sense for signedData where B<PKCS7_DETACHED> | ||
27 | is also set when PKCS7_sign() is also called. | ||
28 | |||
29 | If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> | ||
30 | are added to the content, this only makes sense if B<PKCS7_DETACHED> | ||
31 | is also set. | ||
32 | |||
33 | If cleartext signing is being used then the data must be read twice: | ||
34 | once to compute the signature in PKCS7_sign() and once to output the | ||
35 | S/MIME message. | ||
36 | |||
37 | =head1 BUGS | ||
38 | |||
39 | SMIME_write_PKCS7() always base64 encodes PKCS#7 structures, there | ||
40 | should be an option to disable this. | ||
41 | |||
42 | There should really be a way to produce cleartext signing using only | ||
43 | a single pass of the data. | ||
44 | |||
45 | =head1 RETURN VALUES | ||
46 | |||
47 | SMIME_write_PKCS7() returns 1 for success or 0 for failure. | ||
48 | |||
49 | =head1 SEE ALSO | ||
50 | |||
51 | L<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>, | ||
52 | L<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)> | ||
53 | L<PKCS7_decrypt(3)|PKCS7_decrypt(3)> | ||
54 | |||
55 | =head1 HISTORY | ||
56 | |||
57 | SMIME_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 | |||
5 | X509_NAME_ENTRY_get_object, X509_NAME_ENTRY_get_data, | ||
6 | X509_NAME_ENTRY_set_object, X509_NAME_ENTRY_set_data, | ||
7 | X509_NAME_ENTRY_create_by_txt, X509_NAME_ENTRY_create_by_NID, | ||
8 | X509_NAME_ENTRY_create_by_OBJ - X509_NAME_ENTRY utility functions | ||
9 | |||
10 | =head1 SYNOPSIS | ||
11 | |||
12 | ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); | ||
13 | ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); | ||
14 | |||
15 | int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj); | ||
16 | int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, unsigned char *bytes, int len); | ||
17 | |||
18 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, unsigned char *bytes, int len); | ||
19 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type,unsigned char *bytes, int len); | ||
20 | X509_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 | |||
24 | X509_NAME_ENTRY_get_object() retrieves the field name of B<ne> in | ||
25 | and B<ASN1_OBJECT> structure. | ||
26 | |||
27 | X509_NAME_ENTRY_get_data() retrieves the field value of B<ne> in | ||
28 | and B<ASN1_STRING> structure. | ||
29 | |||
30 | X509_NAME_ENTRY_set_object() sets the field name of B<ne> to B<obj>. | ||
31 | |||
32 | X509_NAME_ENTRY_set_data() sets the field value of B<ne> to string type | ||
33 | B<type> and value determined by B<bytes> and B<len>. | ||
34 | |||
35 | X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_NID() | ||
36 | and X509_NAME_ENTRY_create_by_OBJ() create and return an | ||
37 | B<X509_NAME_ENTRY> structure. | ||
38 | |||
39 | =head1 NOTES | ||
40 | |||
41 | X509_NAME_ENTRY_get_object() and X509_NAME_ENTRY_get_data() can be | ||
42 | used to examine an B<X509_NAME_ENTRY> function as returned by | ||
43 | X509_NAME_get_entry() for example. | ||
44 | |||
45 | X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_NID(), | ||
46 | and X509_NAME_ENTRY_create_by_OBJ() create and return an | ||
47 | |||
48 | X509_NAME_ENTRY_create_by_txt(), X509_NAME_ENTRY_create_by_OBJ(), | ||
49 | X509_NAME_ENTRY_create_by_NID() and X509_NAME_ENTRY_set_data() | ||
50 | are seldom used in practice because B<X509_NAME_ENTRY> structures | ||
51 | are almost always part of B<X509_NAME> structures and the | ||
52 | corresponding B<X509_NAME> functions are typically used to | ||
53 | create and add new entries in a single operation. | ||
54 | |||
55 | The arguments of these functions support similar options to the similarly | ||
56 | named ones of the corresponding B<X509_NAME> functions such as | ||
57 | X509_NAME_add_entry_by_txt(). So for example B<type> can be set to | ||
58 | B<MBSTRING_ASC> but in the case of X509_set_data() the field name must be | ||
59 | set first so the relevant field information can be looked up internally. | ||
60 | |||
61 | =head1 RETURN VALUES | ||
62 | |||
63 | =head1 SEE ALSO | ||
64 | |||
65 | L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)>, | ||
66 | L<OBJ_nid2obj(3),OBJ_nid2obj(3)> | ||
67 | |||
68 | =head1 HISTORY | ||
69 | |||
70 | TBA | ||
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 | |||
5 | X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID, | ||
6 | X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions | ||
7 | |||
8 | =head1 SYNOPSIS | ||
9 | |||
10 | int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type, unsigned char *bytes, int len, int loc, int set); | ||
11 | int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set); | ||
12 | int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set); | ||
13 | int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc, int set); | ||
14 | X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); | ||
15 | |||
16 | =head1 DESCRIPTION | ||
17 | |||
18 | X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and | ||
19 | X509_NAME_add_entry_by_NID() add a field whose name is defined | ||
20 | by a string B<field>, an object B<obj> or a NID B<nid> respectively. | ||
21 | The field value to be added is in B<bytes> of length B<len>. If | ||
22 | B<len> is -1 then the field length is calculated internally using | ||
23 | strlen(bytes). | ||
24 | |||
25 | The type of field is determined by B<type> which can either be a | ||
26 | definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a | ||
27 | standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is | ||
28 | added to a position determined by B<loc> and B<set>. | ||
29 | |||
30 | X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne> | ||
31 | to B<name>. The new entry is added to a position determined by B<loc> | ||
32 | and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after | ||
33 | the call. | ||
34 | |||
35 | X509_NAME_delete_entry() deletes an entry from B<name> at position | ||
36 | B<loc>. The deleted entry is returned and must be freed up. | ||
37 | |||
38 | =head1 NOTES | ||
39 | |||
40 | The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8> | ||
41 | is strongly recommened for the B<type> parameter. This allows the | ||
42 | internal code to correctly determine the type of the field and to | ||
43 | apply length checks according to the relevant standards. This is | ||
44 | done using ASN1_STRING_set_by_NID(). | ||
45 | |||
46 | If instead an ASN1 type is used no checks are performed and the | ||
47 | supplied data in B<bytes> is used directly. | ||
48 | |||
49 | In X509_NAME_add_entry_by_txt() the B<field> string represents | ||
50 | the field name using OBJ_txt2obj(field, 0). | ||
51 | |||
52 | The B<loc> and B<set> parameters determine where a new entry should | ||
53 | be added. For almost all applications B<loc> can be set to -1 and B<set> | ||
54 | to 0. This adds a new entry to the end of B<name> as a single valued | ||
55 | RelativeDistinguishedName (RDN). | ||
56 | |||
57 | B<loc> actually determines the index where the new entry is inserted: | ||
58 | if it is -1 it is appended. | ||
59 | |||
60 | B<set> determines how the new type is added. If it is zero a | ||
61 | new RDN is created. | ||
62 | |||
63 | If B<set> is -1 or 1 it is added to the previous or next RDN | ||
64 | structure respectively. This will then be a multivalued RDN: | ||
65 | since multivalues RDNs are very seldom used B<set> is almost | ||
66 | always set to zero. | ||
67 | |||
68 | =head1 EXAMPLES | ||
69 | |||
70 | Create 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 | |||
90 | X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(), | ||
91 | X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for | ||
92 | success of 0 if an error occurred. | ||
93 | |||
94 | X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY> | ||
95 | structure of B<NULL> if an error occurred. | ||
96 | |||
97 | =head1 BUGS | ||
98 | |||
99 | B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a | ||
100 | different algorithm to determine field types. Since this form does | ||
101 | not understand multicharacter types, performs no length checks and | ||
102 | can result in invalid field types its use is strongly discouraged. | ||
103 | |||
104 | =head1 SEE ALSO | ||
105 | |||
106 | L<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 | |||
5 | X509_NAME_get_index_by_NID, X509_NAME_get_index_by_OBJ, X509_NAME_get_entry, | ||
6 | X509_NAME_entry_count, X509_NAME_get_text_by_NID, X509_NAME_get_text_by_OBJ - | ||
7 | X509_NAME lookup and enumeration functions | ||
8 | |||
9 | =head1 SYNOPSIS | ||
10 | |||
11 | int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); | ||
12 | int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, int lastpos); | ||
13 | |||
14 | int X509_NAME_entry_count(X509_NAME *name); | ||
15 | X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); | ||
16 | |||
17 | int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf,int len); | ||
18 | int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf,int len); | ||
19 | |||
20 | =head1 DESCRIPTION | ||
21 | |||
22 | These functions allow an B<X509_NAME> structure to be examined. The | ||
23 | B<X509_NAME> structure is the same as the B<Name> type defined in | ||
24 | RFC2459 (and elsewhere) and used for example in certificate subject | ||
25 | and issuer names. | ||
26 | |||
27 | X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ() retrieve | ||
28 | the next index matching B<nid> or B<obj> after B<lastpos>. B<lastpos> | ||
29 | should initially be set to -1. If there are no more entries -1 is returned. | ||
30 | |||
31 | X509_NAME_entry_count() returns the total number of entries in B<name>. | ||
32 | |||
33 | X509_NAME_get_entry() retrieves the B<X509_NAME_ENTRY> from B<name> | ||
34 | corresponding to index B<loc>. Acceptable values for B<loc> run from | ||
35 | 0 to (X509_NAME_entry_count(name) - 1). The value returned is an | ||
36 | internal pointer which must not be freed. | ||
37 | |||
38 | X509_NAME_get_text_by_NID(), X509_NAME_get_text_by_OBJ() retrieve | ||
39 | the "text" from the first entry in B<name> which matches B<nid> or | ||
40 | B<obj>, if no such entry exists -1 is returned. At most B<len> bytes | ||
41 | will be written and the text written to B<buf> will be null | ||
42 | terminated. The length of the output string written is returned | ||
43 | excluding the terminating null. If B<buf> is <NULL> then the amount | ||
44 | of space needed in B<buf> (excluding the final null) is returned. | ||
45 | |||
46 | =head1 NOTES | ||
47 | |||
48 | X509_NAME_get_text_by_NID() and X509_NAME_get_text_by_OBJ() are | ||
49 | legacy functions which have various limitations which make them | ||
50 | of minimal use in practice. They can only find the first matching | ||
51 | entry and will copy the contents of the field verbatim: this can | ||
52 | be highly confusing if the target is a muticharacter string type | ||
53 | like a BMPString or a UTF8String. | ||
54 | |||
55 | For a more general solution X509_NAME_get_index_by_NID() or | ||
56 | X509_NAME_get_index_by_OBJ() should be used followed by | ||
57 | X509_NAME_get_entry() on any matching indices and then the | ||
58 | various B<X509_NAME_ENTRY> utility functions on the result. | ||
59 | |||
60 | =head1 EXAMPLES | ||
61 | |||
62 | Process 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 | |||
73 | Process 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 | |||
90 | X509_NAME_get_index_by_NID() and X509_NAME_get_index_by_OBJ() | ||
91 | return the index of the next matching entry or -1 if not found. | ||
92 | |||
93 | X509_NAME_entry_count() returns the total number of entries. | ||
94 | |||
95 | X509_NAME_get_entry() returns an B<X509_NAME> pointer to the | ||
96 | requested entry or B<NULL> if the index is invalid. | ||
97 | |||
98 | =head1 SEE ALSO | ||
99 | |||
100 | L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509_NAME(3)|d2i_X509_NAME(3)> | ||
101 | |||
102 | =head1 HISTORY | ||
103 | |||
104 | TBA | ||
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 | |||
5 | X509_NAME_print_ex, X509_NAME_print_ex_fp, X509_NAME_print, | ||
6 | X509_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 | |||
19 | X509_NAME_print_ex() prints a human readable version of B<nm> to BIO B<out>. Each | ||
20 | line (for multiline formats) is indented by B<indent> spaces. The output format | ||
21 | can be extensively customised by use of the B<flags> parameter. | ||
22 | |||
23 | X509_NAME_print_ex_fp() is identical to X509_NAME_print_ex() except the output is | ||
24 | written to FILE pointer B<fp>. | ||
25 | |||
26 | X509_NAME_oneline() prints an ASCII version of B<a> to B<buf>. At most B<size> | ||
27 | bytes will be written. If B<buf> is B<NULL> then a buffer is dynamically allocated | ||
28 | and returned, otherwise B<buf> is returned. | ||
29 | |||
30 | X509_NAME_print() prints out B<name> to B<bp> indenting each line by B<obase> | ||
31 | characters. Multiple lines are used if the output (including indent) exceeds | ||
32 | 80 characters. | ||
33 | |||
34 | =head1 NOTES | ||
35 | |||
36 | The functions X509_NAME_oneline() and X509_NAME_print() are legacy functions which | ||
37 | produce a non standard output form, they don't handle multi character fields and | ||
38 | have various quirks and inconsistencies. Their use is strongly discouraged in new | ||
39 | applications. | ||
40 | |||
41 | Although there are a large number of possible flags for most purposes | ||
42 | B<XN_FLAG_ONELINE>, B<XN_FLAG_MULTILINE> or B<XN_FLAG_RFC2253> will suffice. | ||
43 | As noted on the L<ASN1_STRING_print_ex(3)|ASN1_STRING_print_ex(3)> manual page | ||
44 | for UTF8 terminals the B<ASN1_STRFLAGS_ESC_MSB> should be unset: so for example | ||
45 | B<XN_FLAG_ONELINE & ~ASN1_STRFLAGS_ESC_MSB> would be used. | ||
46 | |||
47 | The complete set of the flags supported by X509_NAME_print_ex() is listed below. | ||
48 | |||
49 | Several options can be ored together. | ||
50 | |||
51 | The options B<XN_FLAG_SEP_COMMA_PLUS>, B<XN_FLAG_SEP_CPLUS_SPC>, | ||
52 | B<XN_FLAG_SEP_SPLUS_SPC> and B<XN_FLAG_SEP_MULTILINE> determine the field separators | ||
53 | to use. Two distinct separators are used between distinct RelativeDistinguishedName | ||
54 | components and separate values in the same RDN for a multi-valued RDN. Multi-valued | ||
55 | RDNs are currently very rare so the second separator will hardly ever be used. | ||
56 | |||
57 | B<XN_FLAG_SEP_COMMA_PLUS> uses comma and plus as separators. B<XN_FLAG_SEP_CPLUS_SPC> | ||
58 | uses comma and plus with spaces: this is more readable that plain comma and plus. | ||
59 | B<XN_FLAG_SEP_SPLUS_SPC> uses spaced semicolon and plus. B<XN_FLAG_SEP_MULTILINE> uses | ||
60 | spaced newline and plus respectively. | ||
61 | |||
62 | If B<XN_FLAG_DN_REV> is set the whole DN is printed in reversed order. | ||
63 | |||
64 | The fields B<XN_FLAG_FN_SN>, B<XN_FLAG_FN_LN>, B<XN_FLAG_FN_OID>, | ||
65 | B<XN_FLAG_FN_NONE> determine how a field name is displayed. It will | ||
66 | use the short name (e.g. CN) the long name (e.g. commonName) always | ||
67 | use OID numerical form (normally OIDs are only used if the field name is not | ||
68 | recognised) and no field name respectively. | ||
69 | |||
70 | If B<XN_FLAG_SPC_EQ> is set then spaces will be placed around the '=' character | ||
71 | separating field names and values. | ||
72 | |||
73 | If B<XN_FLAG_DUMP_UNKNOWN_FIELDS> is set then the encoding of unknown fields is | ||
74 | printed instead of the values. | ||
75 | |||
76 | If B<XN_FLAG_FN_ALIGN> is set then field names are padded to 20 characters: this | ||
77 | is only of use for multiline format. | ||
78 | |||
79 | Additionally all the options supported by ASN1_STRING_print_ex() can be used to | ||
80 | control how each field value is displayed. | ||
81 | |||
82 | In addition a number options can be set for commonly used formats. | ||
83 | |||
84 | B<XN_FLAG_RFC2253> sets options which produce an output compatible with RFC2253 it | ||
85 | is 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 | |||
89 | B<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 | |||
92 | B<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 | |||
95 | B<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 | |||
99 | L<ASN1_STRING_print_ex(3)|ASN1_STRING_print_ex(3)> | ||
100 | |||
101 | =head1 HISTORY | ||
102 | |||
103 | TBA | ||
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 | |||
5 | X509_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 | |||
14 | The X509 ASN1 allocation routines, allocate and free an | ||
15 | X509 structure, which represents an X509 certificate. | ||
16 | |||
17 | X509_new() allocates and initializes a X509 structure. | ||
18 | |||
19 | X509_free() frees up the B<X509> structure B<a>. | ||
20 | |||
21 | =head1 RETURN VALUES | ||
22 | |||
23 | If the allocation fails, X509_new() returns B<NULL> and sets an error | ||
24 | code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. | ||
25 | Otherwise it returns a pointer to the newly allocated structure. | ||
26 | |||
27 | X509_free() returns no value. | ||
28 | |||
29 | =head1 SEE ALSO | ||
30 | |||
31 | L<ERR_get_error(3)|ERR_get_error(3)>, L<d2i_X509(3)|d2i_X509(3)> | ||
32 | |||
33 | =head1 HISTORY | ||
34 | |||
35 | X509_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 | |||
5 | d2i_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 | |||
16 | These functions decode and encode an ASN1 OBJECT IDENTIFIER. | ||
17 | |||
18 | Othewise these behave in a similar way to d2i_X509() and i2d_X509() | ||
19 | described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
20 | |||
21 | =head1 SEE ALSO | ||
22 | |||
23 | L<d2i_X509(3)|d2i_X509(3)> | ||
24 | |||
25 | =head1 HISTORY | ||
26 | |||
27 | TBA | ||
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 | |||
5 | d2i_DSAPublicKey, i2d_DSAPublicKey, d2i_DSAPrivateKey, i2d_DSAPrivateKey, | ||
6 | d2i_DSA_PUBKEY, i2d_DSA_PUBKEY, d2i_DSA_SIG, i2d_DSA_SIG - DSA key encoding | ||
7 | and 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 | |||
35 | d2i_DSAPublicKey() and i2d_DSAPublicKey() decode and encode the DSA public key | ||
36 | components structure. | ||
37 | |||
38 | d2i_DSA_PUKEY() and i2d_DSA_PUKEY() decode and encode an DSA public key using a | ||
39 | SubjectPublicKeyInfo (certificate public key) structure. | ||
40 | |||
41 | d2i_DSAPrivateKey(), i2d_DSAPrivateKey() decode and encode the DSA private key | ||
42 | components. | ||
43 | |||
44 | d2i_DSAparams(), i2d_DSAparams() decode and encode the DSA parameters using | ||
45 | a B<Dss-Parms> structure as defined in RFC2459. | ||
46 | |||
47 | d2i_DSA_SIG(), i2d_DSA_SIG() decode and encode a DSA signature using a | ||
48 | B<Dss-Sig-Value> structure as defined in RFC2459. | ||
49 | |||
50 | The usage of all of these functions is similar to the d2i_X509() and | ||
51 | i2d_X509() described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
52 | |||
53 | =head1 NOTES | ||
54 | |||
55 | The B<DSA> structure passed to the private key encoding functions should have | ||
56 | all the private key components present. | ||
57 | |||
58 | The data encoded by the private key functions is unencrypted and therefore | ||
59 | offers no private key security. | ||
60 | |||
61 | The B<DSA_PUBKEY> functions should be used in preference to the B<DSAPublicKey> | ||
62 | functions when encoding public keys because they use a standard format. | ||
63 | |||
64 | The B<DSAPublicKey> functions use an non standard format the actual data encoded | ||
65 | depends on the value of the B<write_params> field of the B<a> key parameter. | ||
66 | If B<write_params> is zero then only the B<pub_key> field is encoded as an | ||
67 | B<INTEGER>. If B<write_params> is 1 then a B<SEQUENCE> consisting of the | ||
68 | B<p>, B<q>, B<g> and B<pub_key> respectively fields are encoded. | ||
69 | |||
70 | The B<DSAPrivateKey> functions also use a non standard structure consiting | ||
71 | consisting of a SEQUENCE containing the B<p>, B<q>, B<g> and B<pub_key> and | ||
72 | B<priv_key> fields respectively. | ||
73 | |||
74 | =head1 SEE ALSO | ||
75 | |||
76 | L<d2i_X509(3)|d2i_X509(3)> | ||
77 | |||
78 | =head1 HISTORY | ||
79 | |||
80 | TBA | ||
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 | |||
5 | d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio, | ||
6 | i2d_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 | |||
23 | The X509 encode and decode routines encode and parse an | ||
24 | B<X509> structure, which represents an X509 certificate. | ||
25 | |||
26 | d2i_X509() attempts to decode B<len> bytes at B<*out>. If | ||
27 | successful a pointer to the B<X509> structure is returned. If an error | ||
28 | occurred then B<NULL> is returned. If B<px> is not B<NULL> then the | ||
29 | returned structure is written to B<*px>. If B<*px> is not B<NULL> | ||
30 | then it is assumed that B<*px> contains a valid B<X509> | ||
31 | structure and an attempt is made to reuse it. If the call is | ||
32 | successful B<*out> is incremented to the byte following the | ||
33 | parsed data. | ||
34 | |||
35 | i2d_X509() encodes the structure pointed to by B<x> into DER format. | ||
36 | If B<out> is not B<NULL> is writes the DER encoded data to the buffer | ||
37 | at B<*out>, and increments it to point after the data just written. | ||
38 | If the return value is negative an error occurred, otherwise it | ||
39 | returns the length of the encoded data. | ||
40 | |||
41 | For OpenSSL 0.9.7 and later if B<*out> is B<NULL> memory will be | ||
42 | allocated for a buffer and the encoded data written to it. In this | ||
43 | case B<*out> is not incremented and it points to the start of the | ||
44 | data just written. | ||
45 | |||
46 | d2i_X509_bio() is similar to d2i_X509() except it attempts | ||
47 | to parse data from BIO B<bp>. | ||
48 | |||
49 | d2i_X509_fp() is similar to d2i_X509() except it attempts | ||
50 | to parse data from FILE pointer B<fp>. | ||
51 | |||
52 | i2d_X509_bio() is similar to i2d_X509() except it writes | ||
53 | the encoding of the structure B<x> to BIO B<bp> and it | ||
54 | returns 1 for success and 0 for failure. | ||
55 | |||
56 | i2d_X509_fp() is similar to i2d_X509() except it writes | ||
57 | the encoding of the structure B<x> to BIO B<bp> and it | ||
58 | returns 1 for success and 0 for failure. | ||
59 | |||
60 | =head1 NOTES | ||
61 | |||
62 | The 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 | ||
64 | B<i2d_X509> converts from internal to DER. | ||
65 | |||
66 | The functions can also understand B<BER> forms. | ||
67 | |||
68 | The actual X509 structure passed to i2d_X509() must be a valid | ||
69 | populated B<X509> structure it can B<not> simply be fed with an | ||
70 | empty structure such as that returned by X509_new(). | ||
71 | |||
72 | The encoded data is in binary form and may contain embedded zeroes. | ||
73 | Therefore any FILE pointers or BIOs should be opened in binary mode. | ||
74 | Functions such as B<strlen()> will B<not> return the correct length | ||
75 | of the encoded structure. | ||
76 | |||
77 | The ways that B<*in> and B<*out> are incremented after the operation | ||
78 | can trap the unwary. See the B<WARNINGS> section for some common | ||
79 | errors. | ||
80 | |||
81 | The reason for the auto increment behaviour is to reflect a typical | ||
82 | usage of ASN1 functions: after one structure is encoded or decoded | ||
83 | another will processed after it. | ||
84 | |||
85 | =head1 EXAMPLES | ||
86 | |||
87 | Allocate 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 | |||
103 | If you are using OpenSSL 0.9.7 or later then this can be | ||
104 | simplified 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 | |||
117 | Attempt 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 | |||
134 | Alternative 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 | |||
154 | The use of temporary variable is mandatory. A common | ||
155 | mistake 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 | |||
173 | This code will result in B<buf> apparently containing garbage because | ||
174 | it was incremented after the call to point after the data just written. | ||
175 | Also B<buf> will no longer contain the pointer allocated by B<OPENSSL_malloc()> | ||
176 | and the subsequent call to B<OPENSSL_free()> may well crash. | ||
177 | |||
178 | The auto allocation feature (setting buf to NULL) only works on OpenSSL | ||
179 | 0.9.7 and later. Attempts to use it on earlier versions will typically | ||
180 | cause a segmentation violation. | ||
181 | |||
182 | Another 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 | |||
189 | This will probably crash somewhere in B<d2i_X509()>. The reason for this | ||
190 | is that the variable B<x> is uninitialized and an attempt will be made to | ||
191 | interpret its (invalid) value as an B<X509> structure, typically causing | ||
192 | a segmentation violation. If B<x> is set to NULL first then this will not | ||
193 | happen. | ||
194 | |||
195 | =head1 BUGS | ||
196 | |||
197 | In some versions of OpenSSL the "reuse" behaviour of d2i_X509() when | ||
198 | B<*px> is valid is broken and some parts of the reused structure may | ||
199 | persist if they are not present in the new one. As a result the use | ||
200 | of this "reuse" behaviour is strongly discouraged. | ||
201 | |||
202 | i2d_X509() will not return an error in many versions of OpenSSL, | ||
203 | if mandatory fields are not initialized due to a programming error | ||
204 | then the encoded structure may contain invalid data or omit the | ||
205 | fields entirely and will not be parsed by d2i_X509(). This may be | ||
206 | fixed in future so code should not assume that i2d_X509() will | ||
207 | always succeed. | ||
208 | |||
209 | =head1 RETURN VALUES | ||
210 | |||
211 | d2i_X509(), d2i_X509_bio() and d2i_X509_fp() return a valid B<X509> structure | ||
212 | or B<NULL> if an error occurs. The error code that can be obtained by | ||
213 | L<ERR_get_error(3)|ERR_get_error(3)>. | ||
214 | |||
215 | i2d_X509(), i2d_X509_bio() and i2d_X509_fp() return a the number of bytes | ||
216 | successfully encoded or a negative value if an error occurs. The error code | ||
217 | can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. | ||
218 | |||
219 | i2d_X509_bio() and i2d_X509_fp() returns 1 for success and 0 if an error | ||
220 | occurs The error code can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. | ||
221 | |||
222 | =head1 SEE ALSO | ||
223 | |||
224 | L<ERR_get_error(3)|ERR_get_error(3)> | ||
225 | |||
226 | =head1 HISTORY | ||
227 | |||
228 | d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio and i2d_X509_fp | ||
229 | are 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 | |||
5 | d2i_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 | |||
16 | These functions decode and encode an B<X509_ALGOR> structure which is | ||
17 | equivalent to the B<AlgorithmIdentifier> structure. | ||
18 | |||
19 | Othewise these behave in a similar way to d2i_X509() and i2d_X509() | ||
20 | described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
21 | |||
22 | =head1 SEE ALSO | ||
23 | |||
24 | L<d2i_X509(3)|d2i_X509(3)> | ||
25 | |||
26 | =head1 HISTORY | ||
27 | |||
28 | TBA | ||
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 | |||
5 | d2i_X509_CRL, i2d_X509_CRL, d2i_X509_CRL_bio, d2i_509_CRL_fp, | ||
6 | i2d_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 | |||
23 | These functions decode and encode an X509 CRL (certificate revocation | ||
24 | list). | ||
25 | |||
26 | Othewise the functions behave in a similar way to d2i_X509() and i2d_X509() | ||
27 | described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
28 | |||
29 | =head1 SEE ALSO | ||
30 | |||
31 | L<d2i_X509(3)|d2i_X509(3)> | ||
32 | |||
33 | =head1 HISTORY | ||
34 | |||
35 | TBA | ||
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 | |||
5 | d2i_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 | |||
16 | These functions decode and encode an B<X509_NAME> structure which is the | ||
17 | the same as the B<Name> type defined in RFC2459 (and elsewhere) and used | ||
18 | for example in certificate subject and issuer names. | ||
19 | |||
20 | Othewise the functions behave in a similar way to d2i_X509() and i2d_X509() | ||
21 | described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
22 | |||
23 | =head1 SEE ALSO | ||
24 | |||
25 | L<d2i_X509(3)|d2i_X509(3)> | ||
26 | |||
27 | =head1 HISTORY | ||
28 | |||
29 | TBA | ||
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 | |||
5 | d2i_X509_REQ, i2d_X509_REQ, d2i_X509_REQ_bio, d2i_X509_REQ_fp, | ||
6 | i2d_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 | |||
23 | These functions decode and encode a PKCS#10 certificate request. | ||
24 | |||
25 | Othewise these behave in a similar way to d2i_X509() and i2d_X509() | ||
26 | described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
27 | |||
28 | =head1 SEE ALSO | ||
29 | |||
30 | L<d2i_X509(3)|d2i_X509(3)> | ||
31 | |||
32 | =head1 HISTORY | ||
33 | |||
34 | TBA | ||
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 | |||
5 | d2i_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 | |||
16 | These functions decode and encode an X509_SIG structure which is | ||
17 | equivalent to the B<DigestInfo> structure defined in PKCS#1 and PKCS#7. | ||
18 | |||
19 | Othewise these behave in a similar way to d2i_X509() and i2d_X509() | ||
20 | described in the L<d2i_X509(3)|d2i_X509(3)> manual page. | ||
21 | |||
22 | =head1 SEE ALSO | ||
23 | |||
24 | L<d2i_X509(3)|d2i_X509(3)> | ||
25 | |||
26 | =head1 HISTORY | ||
27 | |||
28 | TBA | ||
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 | |||
187 | they are both simply (ENGINE *) pointers, the difference is in the way they | 187 | they are both simply (ENGINE *) pointers, the difference is in the way they |
188 | are used). | 188 | are used). |
189 | 189 | ||
190 | =head3 Structural references | 190 | I<Structural references> |
191 | 191 | ||
192 | This basic type of reference is typically used for creating new ENGINEs | 192 | This basic type of reference is typically used for creating new ENGINEs |
193 | dynamically, iterating across OpenSSL's internal linked-list of loaded | 193 | dynamically, iterating across OpenSSL's internal linked-list of loaded |
@@ -224,7 +224,7 @@ To clarify a particular function's handling of references, one should | |||
224 | always consult that function's documentation "man" page, or failing that | 224 | always consult that function's documentation "man" page, or failing that |
225 | the openssl/engine.h header file includes some hints. | 225 | the openssl/engine.h header file includes some hints. |
226 | 226 | ||
227 | =head3 Functional references | 227 | I<Functional references> |
228 | 228 | ||
229 | As mentioned, functional references exist when the cryptographic | 229 | As mentioned, functional references exist when the cryptographic |
230 | functionality of an ENGINE is required to be available. A functional | 230 | functionality 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 | |||
386 | couple of simple cases and leave developers to consider these and the | 386 | couple of simple cases and leave developers to consider these and the |
387 | source code to openssl's builtin utilities as guides. | 387 | source code to openssl's builtin utilities as guides. |
388 | 388 | ||
389 | =head3 Using a specific ENGINE implementation | 389 | I<Using a specific ENGINE implementation> |
390 | 390 | ||
391 | Here we'll assume an application has been configured by its user or admin | 391 | Here we'll assume an application has been configured by its user or admin |
392 | to want to use the "ACME" ENGINE if it is available in the version of | 392 | to 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 | 421 | I<Automatically using builtin ENGINE implementations> |
422 | 422 | ||
423 | Here we'll assume we want to load and register all ENGINE implementations | 423 | Here we'll assume we want to load and register all ENGINE implementations |
424 | bundled with OpenSSL, such that for any cryptographic algorithm required by | 424 | bundled with OpenSSL, such that for any cryptographic algorithm required by |
@@ -469,7 +469,7 @@ in same cases both. ENGINE implementations should provide indications of | |||
469 | this in the descriptions attached to builtin control commands and/or in | 469 | this in the descriptions attached to builtin control commands and/or in |
470 | external product documentation. | 470 | external product documentation. |
471 | 471 | ||
472 | =head3 Issuing control commands to an ENGINE | 472 | I<Issuing control commands to an ENGINE> |
473 | 473 | ||
474 | Let's illustrate by example; a function for which the caller supplies the | 474 | Let's illustrate by example; a function for which the caller supplies the |
475 | name of the ENGINE it wishes to use, a table of string-pairs for use before | 475 | name 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 | |||
526 | only supplying commands specific to the given ENGINE so we set this to | 526 | only supplying commands specific to the given ENGINE so we set this to |
527 | FALSE. | 527 | FALSE. |
528 | 528 | ||
529 | =head3 Discovering supported control commands | 529 | I<Discovering supported control commands> |
530 | 530 | ||
531 | It is possible to discover at run-time the names, numerical-ids, descriptions | 531 | It is possible to discover at run-time the names, numerical-ids, descriptions |
532 | and input parameters of the control commands supported from a structural | 532 | and 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 | |||
62 | unsigned char cleanse_ctr = 0; | ||
63 | |||
64 | void 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 | } | ||