diff options
author | schwarze <> | 2015-02-14 14:09:01 +0000 |
---|---|---|
committer | schwarze <> | 2015-02-14 14:09:01 +0000 |
commit | 88853a20be023939d14cfde9e86a81bfcc75ef7b (patch) | |
tree | 14e96de4625e6c5d8612c27a513ebf5ed519b352 /src/lib/libcrypto/man/BIO_f_md.3 | |
parent | 948b14a55ded39aea589e34e23c19085fd99cac5 (diff) | |
download | openbsd-88853a20be023939d14cfde9e86a81bfcc75ef7b.tar.gz openbsd-88853a20be023939d14cfde9e86a81bfcc75ef7b.tar.bz2 openbsd-88853a20be023939d14cfde9e86a81bfcc75ef7b.zip |
second batch of perlpod(1) to mdoc(7) conversion
Diffstat (limited to 'src/lib/libcrypto/man/BIO_f_md.3')
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_md.3 | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BIO_f_md.3 b/src/lib/libcrypto/man/BIO_f_md.3 new file mode 100644 index 0000000000..de21722608 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_f_md.3 | |||
@@ -0,0 +1,209 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_F_MD 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_f_md , | ||
6 | .Nm BIO_set_md , | ||
7 | .Nm BIO_get_md , | ||
8 | .Nm BIO_get_md_ctx | ||
9 | .Nd message digest BIO filter | ||
10 | .Sh SYNOPSIS | ||
11 | .In openssl/bio.h | ||
12 | .In openssl/evp.h | ||
13 | .Ft BIO_METHOD * | ||
14 | .Fo BIO_f_md | ||
15 | .Fa void | ||
16 | .Fc | ||
17 | .Ft int | ||
18 | .Fo BIO_set_md | ||
19 | .Fa "BIO *b" | ||
20 | .Fa "EVP_MD *md" | ||
21 | .Fc | ||
22 | .Ft int | ||
23 | .Fo BIO_get_md | ||
24 | .Fa "BIO *b" | ||
25 | .Fa "EVP_MD **mdp" | ||
26 | .Fc | ||
27 | .Ft int | ||
28 | .Fo BIO_get_md_ctx | ||
29 | .Fa "BIO *b" | ||
30 | .Fa "EVP_MD_CTX **mdcp" | ||
31 | .Fc | ||
32 | .Sh DESCRIPTION | ||
33 | .Fn BIO_f_md | ||
34 | returns the message digest BIO method. | ||
35 | This is a filter BIO that digests any data passed through it. | ||
36 | It is a BIO wrapper for the digest routines | ||
37 | .Fn EVP_DigestInit , | ||
38 | .Fn EVP_DigestUpdate , | ||
39 | and | ||
40 | .Fn EVP_DigestFinal . | ||
41 | .Pp | ||
42 | Any data written or read through a digest BIO using | ||
43 | .Xr BIO_read 3 | ||
44 | and | ||
45 | .Xr BIO_write 3 | ||
46 | is digested. | ||
47 | .Pp | ||
48 | .Xr BIO_gets 3 , | ||
49 | if its | ||
50 | .Sy size | ||
51 | parameter is large enough, | ||
52 | finishes the digest calculation and returns the digest value. | ||
53 | .Xr BIO_puts 3 | ||
54 | is | ||
55 | not supported. | ||
56 | .Pp | ||
57 | .Xr BIO_reset 3 | ||
58 | reinitialises a digest BIO. | ||
59 | .Pp | ||
60 | .Fn BIO_set_md | ||
61 | sets the message digest of BIO | ||
62 | .Fa b | ||
63 | to | ||
64 | .Fa md : | ||
65 | this must be called to initialize a digest BIO | ||
66 | before any data is passed through it. | ||
67 | It is a | ||
68 | .Xr BIO_ctrl 3 | ||
69 | macro. | ||
70 | .Pp | ||
71 | .Fn BIO_get_md | ||
72 | places the a pointer to the digest BIOs digest method in | ||
73 | .Fa mdp . | ||
74 | It is a | ||
75 | .Xr BIO_ctrl 3 | ||
76 | macro. | ||
77 | .Pp | ||
78 | .Fn BIO_get_md_ctx | ||
79 | returns the digest BIOs context in | ||
80 | .Fa mdcp . | ||
81 | .Sh NOTES | ||
82 | The context returned by | ||
83 | .Fn BIO_get_md_ctx | ||
84 | can be used in calls to | ||
85 | .Xr EVP_DigestFinal 3 | ||
86 | and also in the signature routines | ||
87 | .Xr EVP_SignFinal 3 | ||
88 | and | ||
89 | .Xr EVP_VerifyFinal 3 . | ||
90 | .Pp | ||
91 | The context returned by | ||
92 | .Fn BIO_get_md_ctx | ||
93 | is an internal context structure. | ||
94 | Changes made to this context will affect the digest BIO itself, and | ||
95 | the context pointer will become invalid when the digest BIO is freed. | ||
96 | .Pp | ||
97 | After the digest has been retrieved from a digest BIO, | ||
98 | it must be reinitialized by calling | ||
99 | .Xr BIO_reset 3 | ||
100 | or | ||
101 | .Fn BIO_set_md | ||
102 | before any more data is passed through it. | ||
103 | .Pp | ||
104 | If an application needs to call | ||
105 | .Xr BIO_gets 3 | ||
106 | or | ||
107 | .Xr BIO_puts 3 | ||
108 | through a chain containing digest BIOs, | ||
109 | then this can be done by prepending a buffering BIO. | ||
110 | .Pp | ||
111 | Before OpenSSL 1.0.0 the call to | ||
112 | .Fn BIO_get_md_ctx | ||
113 | would only work if the BIO had been initialized for example by calling | ||
114 | .Fn BIO_set_md . | ||
115 | In OpenSSL 1.0.0 and later the context is always returned | ||
116 | and the BIO is state is set to initialized. | ||
117 | This allows applications to initialize the context externally | ||
118 | if the standard calls such as | ||
119 | .Fn BIO_set_md | ||
120 | are not sufficiently flexible. | ||
121 | .Sh RETURN VALUES | ||
122 | .Fn BIO_f_md | ||
123 | returns the digest BIO method. | ||
124 | .Pp | ||
125 | .Fn BIO_set_md , | ||
126 | .Fn BIO_get_md , | ||
127 | and | ||
128 | .Fn BIO_get_md_ctx | ||
129 | return 1 for success and 0 for failure. | ||
130 | .Sh EXAMPLES | ||
131 | The following example creates a BIO chain containing an SHA1 and MD5 | ||
132 | digest BIO and passes the string "Hello World" through it. | ||
133 | Error checking has been omitted for clarity. | ||
134 | .Bd -literal -offset 2n | ||
135 | BIO *bio, *mdtmp; | ||
136 | const char message[] = "Hello World"; | ||
137 | bio = BIO_new(BIO_s_null()); | ||
138 | mdtmp = BIO_new(BIO_f_md()); | ||
139 | BIO_set_md(mdtmp, EVP_sha1()); | ||
140 | /* | ||
141 | * For BIO_push() we want to append the sink BIO | ||
142 | * and keep a note of the start of the chain. | ||
143 | */ | ||
144 | bio = BIO_push(mdtmp, bio); | ||
145 | mdtmp = BIO_new(BIO_f_md()); | ||
146 | BIO_set_md(mdtmp, EVP_md5()); | ||
147 | bio = BIO_push(mdtmp, bio); | ||
148 | /* Note: mdtmp can now be discarded */ | ||
149 | BIO_write(bio, message, strlen(message)); | ||
150 | .Ed | ||
151 | .Pp | ||
152 | The next example digests data by reading through a chain instead: | ||
153 | .Bd -literal -offset 2n | ||
154 | BIO *bio, *mdtmp; | ||
155 | char buf[1024]; | ||
156 | int rdlen; | ||
157 | |||
158 | bio = BIO_new_file(file, "rb"); | ||
159 | mdtmp = BIO_new(BIO_f_md()); | ||
160 | BIO_set_md(mdtmp, EVP_sha1()); | ||
161 | bio = BIO_push(mdtmp, bio); | ||
162 | mdtmp = BIO_new(BIO_f_md()); | ||
163 | BIO_set_md(mdtmp, EVP_md5()); | ||
164 | bio = BIO_push(mdtmp, bio); | ||
165 | do { | ||
166 | rdlen = BIO_read(bio, buf, sizeof(buf)); | ||
167 | /* Might want to do something with the data here */ | ||
168 | } while (rdlen > 0); | ||
169 | .Ed | ||
170 | .Pp | ||
171 | This next example retrieves the message digests from a BIO chain | ||
172 | and outputs them. | ||
173 | This could be used with the examples above. | ||
174 | .Bd -literal -offset 2n | ||
175 | BIO *mdtmp; | ||
176 | unsigned char mdbuf[EVP_MAX_MD_SIZE]; | ||
177 | int mdlen; | ||
178 | int i; | ||
179 | |||
180 | mdtmp = bio; /* Assume bio has previously been set up */ | ||
181 | do { | ||
182 | EVP_MD *md; | ||
183 | mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD); | ||
184 | if (!mdtmp) | ||
185 | break; | ||
186 | BIO_get_md(mdtmp, &md); | ||
187 | printf("%s digest", OBJ_nid2sn(EVP_MD_type(md))); | ||
188 | mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE); | ||
189 | for(i = 0; i < mdlen; i++) | ||
190 | printf(":%02X", mdbuf[i]); | ||
191 | printf("\en"); | ||
192 | mdtmp = BIO_next(mdtmp); | ||
193 | } while(mdtmp); | ||
194 | BIO_free_all(bio); | ||
195 | .Ed | ||
196 | .Sh BUGS | ||
197 | The lack of support for | ||
198 | .Xr BIO_puts 3 | ||
199 | and the non standard behaviour of | ||
200 | .Xr BIO_gets 3 | ||
201 | could be regarded as anomalous. | ||
202 | It could be argued that | ||
203 | .Xr BIO_gets 3 | ||
204 | and | ||
205 | .Xr BIO_puts 3 | ||
206 | should be passed to the next BIO in the chain and digest the data | ||
207 | passed through and that digests should be retrieved using a separate | ||
208 | .Xr BIO_ctrl 3 | ||
209 | call. | ||