]>
Commit | Line | Data |
---|---|---|
44bdb056 RL |
1 | /* ==================================================================== |
2 | * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * | |
8 | * 1. Redistributions of source code must retain the above copyright | |
0f113f3e | 9 | * notice, this list of conditions and the following disclaimer. |
44bdb056 RL |
10 | * |
11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in | |
13 | * the documentation and/or other materials provided with the | |
14 | * distribution. | |
15 | * | |
16 | * 3. All advertising materials mentioning features or use of this | |
17 | * software must display the following acknowledgment: | |
18 | * "This product includes software developed by the OpenSSL Project | |
19 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | |
20 | * | |
21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | |
22 | * endorse or promote products derived from this software without | |
23 | * prior written permission. For written permission, please contact | |
24 | * openssl-core@openssl.org. | |
25 | * | |
26 | * 5. Products derived from this software may not be called "OpenSSL" | |
27 | * nor may "OpenSSL" appear in their names without prior written | |
28 | * permission of the OpenSSL Project. | |
29 | * | |
30 | * 6. Redistributions of any form whatsoever must retain the following | |
31 | * acknowledgment: | |
32 | * "This product includes software developed by the OpenSSL Project | |
33 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | |
34 | * | |
35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | |
36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | |
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
46 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
47 | * ==================================================================== | |
48 | * | |
49 | * This product includes cryptographic software written by Eric Young | |
50 | * (eay@cryptsoft.com). This product includes software written by Tim | |
51 | * Hudson (tjh@cryptsoft.com). | |
52 | * | |
53 | */ | |
58964a49 | 54 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
d02b48c6 RE |
55 | * All rights reserved. |
56 | * | |
57 | * This package is an SSL implementation written | |
58 | * by Eric Young (eay@cryptsoft.com). | |
59 | * The implementation was written so as to conform with Netscapes SSL. | |
0f113f3e | 60 | * |
d02b48c6 RE |
61 | * This library is free for commercial and non-commercial use as long as |
62 | * the following conditions are aheared to. The following conditions | |
63 | * apply to all code found in this distribution, be it the RC4, RSA, | |
64 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | |
65 | * included with this distribution is covered by the same copyright terms | |
66 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | |
0f113f3e | 67 | * |
d02b48c6 RE |
68 | * Copyright remains Eric Young's, and as such any Copyright notices in |
69 | * the code are not to be removed. | |
70 | * If this package is used in a product, Eric Young should be given attribution | |
71 | * as the author of the parts of the library used. | |
72 | * This can be in the form of a textual message at program startup or | |
73 | * in documentation (online or textual) provided with the package. | |
0f113f3e | 74 | * |
d02b48c6 RE |
75 | * Redistribution and use in source and binary forms, with or without |
76 | * modification, are permitted provided that the following conditions | |
77 | * are met: | |
78 | * 1. Redistributions of source code must retain the copyright | |
79 | * notice, this list of conditions and the following disclaimer. | |
80 | * 2. Redistributions in binary form must reproduce the above copyright | |
81 | * notice, this list of conditions and the following disclaimer in the | |
82 | * documentation and/or other materials provided with the distribution. | |
83 | * 3. All advertising materials mentioning features or use of this software | |
84 | * must display the following acknowledgement: | |
85 | * "This product includes cryptographic software written by | |
86 | * Eric Young (eay@cryptsoft.com)" | |
87 | * The word 'cryptographic' can be left out if the rouines from the library | |
88 | * being used are not cryptographic related :-). | |
0f113f3e | 89 | * 4. If you include any Windows specific code (or a derivative thereof) from |
d02b48c6 RE |
90 | * the apps directory (application code) you must include an acknowledgement: |
91 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | |
0f113f3e | 92 | * |
d02b48c6 RE |
93 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
94 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
95 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
96 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
97 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
98 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
99 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
101 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
102 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
103 | * SUCH DAMAGE. | |
0f113f3e | 104 | * |
d02b48c6 RE |
105 | * The licence and distribution terms for any publically available version or |
106 | * derivative of this code cannot be changed. i.e. this code cannot simply be | |
107 | * copied and put under another distribution licence | |
108 | * [including the GNU Public Licence.] | |
109 | */ | |
110 | ||
cc1489d2 | 111 | #include <string.h> |
44bdb056 | 112 | #include <openssl/des.h> |
c2e4f17c | 113 | #include <openssl/ui.h> |
298a2f9e | 114 | #include <openssl/crypto.h> |
d02b48c6 | 115 | |
b9bd7b06 DW |
116 | #ifndef OPENSSL_NO_UI |
117 | ||
984d6c60 DW |
118 | #ifndef BUFSIZ |
119 | #define BUFSIZ 256 | |
120 | #endif | |
121 | ||
44bdb056 | 122 | int DES_read_password(DES_cblock *key, const char *prompt, int verify) |
0f113f3e MC |
123 | { |
124 | int ok; | |
125 | char buf[BUFSIZ], buff[BUFSIZ]; | |
d02b48c6 | 126 | |
0f113f3e MC |
127 | if ((ok = UI_UTIL_read_pw(buf, buff, BUFSIZ, prompt, verify)) == 0) |
128 | DES_string_to_key(buf, key); | |
129 | OPENSSL_cleanse(buf, BUFSIZ); | |
130 | OPENSSL_cleanse(buff, BUFSIZ); | |
131 | return (ok); | |
132 | } | |
d02b48c6 | 133 | |
0f113f3e MC |
134 | int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, |
135 | const char *prompt, int verify) | |
136 | { | |
137 | int ok; | |
138 | char buf[BUFSIZ], buff[BUFSIZ]; | |
d02b48c6 | 139 | |
0f113f3e MC |
140 | if ((ok = UI_UTIL_read_pw(buf, buff, BUFSIZ, prompt, verify)) == 0) |
141 | DES_string_to_2keys(buf, key1, key2); | |
142 | OPENSSL_cleanse(buf, BUFSIZ); | |
143 | OPENSSL_cleanse(buff, BUFSIZ); | |
144 | return (ok); | |
145 | } | |
b9bd7b06 | 146 | #endif |