~ubuntu-branches/ubuntu/lucid/openssl/lucid-proposed

« back to all changes in this revision

Viewing changes to apps/rand.c

  • Committer: Bazaar Package Importer
  • Author(s): Nicolas Valcárcel Scerpella (Canonical)
  • Date: 2009-12-06 20:16:24 UTC
  • mfrom: (11.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091206201624-u126qjpqm2n2uuhu
Tags: 0.9.8k-7ubuntu1
* Merge from debian unstable, remaining changes (LP: #493392):
  - Link using -Bsymbolic-functions
  - Add support for lpia
  - Disable SSLv2 during compile
  - Ship documentation in openssl-doc, suggested by the package.
  - Use a different priority for libssl0.9.8/restart-services
    depending on whether a desktop, or server dist-upgrade is being
    performed.
  - Display a system restart required notification bubble on libssl0.9.8
    upgrade.
  - Replace duplicate files in the doc directory with symlinks.
  - Move runtime libraries to /lib, for the benefit of wpasupplicant
* Strip the patches out of the source into quilt patches
* Disable CVE-2009-3555.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
 
69
69
/* -out file         - write to file
70
70
 * -rand file:file   - PRNG seed files
71
 
 * -base64           - encode output
 
71
 * -base64           - base64 encode output
 
72
 * -hex              - hex encode output
72
73
 * num               - write 'num' bytes
73
74
 */
74
75
 
84
85
        char *outfile = NULL;
85
86
        char *inrand = NULL;
86
87
        int base64 = 0;
 
88
        int hex = 0;
87
89
        BIO *out = NULL;
88
90
        int num = -1;
89
91
#ifndef OPENSSL_NO_ENGINE
133
135
                        else
134
136
                                badopt = 1;
135
137
                        }
 
138
                else if (strcmp(argv[i], "-hex") == 0)
 
139
                        {
 
140
                        if (!hex)
 
141
                                hex = 1;
 
142
                        else
 
143
                                badopt = 1;
 
144
                        }
136
145
                else if (isdigit((unsigned char)argv[i][0]))
137
146
                        {
138
147
                        if (num < 0)
148
157
                        badopt = 1;
149
158
                }
150
159
 
 
160
        if (hex && base64)
 
161
                badopt = 1;
 
162
 
151
163
        if (num < 0)
152
164
                badopt = 1;
153
165
        
160
172
                BIO_printf(bio_err, "-engine e             - use engine e, possibly a hardware device.\n");
161
173
#endif
162
174
                BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
163
 
                BIO_printf(bio_err, "-base64               - encode output\n");
 
175
                BIO_printf(bio_err, "-base64               - base64 encode output\n");
 
176
                BIO_printf(bio_err, "-hex                  - hex encode output\n");
164
177
                goto err;
165
178
                }
166
179
 
210
223
                r = RAND_bytes(buf, chunk);
211
224
                if (r <= 0)
212
225
                        goto err;
213
 
                BIO_write(out, buf, chunk);
 
226
                if (!hex) 
 
227
                        BIO_write(out, buf, chunk);
 
228
                else
 
229
                        {
 
230
                        for (i = 0; i < chunk; i++)
 
231
                                BIO_printf(out, "%02x", buf[i]);
 
232
                        }
214
233
                num -= chunk;
215
234
                }
 
235
        if (hex)
 
236
                BIO_puts(out, "\n");
216
237
        (void)BIO_flush(out);
217
238
 
218
239
        app_RAND_write_file(NULL, bio_err);