10Sstevel@tonic-gate /* crypto/des/read2pwd.c */
20Sstevel@tonic-gate /* ====================================================================
30Sstevel@tonic-gate * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.
40Sstevel@tonic-gate *
50Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
60Sstevel@tonic-gate * modification, are permitted provided that the following conditions
70Sstevel@tonic-gate * are met:
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
100Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
110Sstevel@tonic-gate *
120Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
130Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in
140Sstevel@tonic-gate * the documentation and/or other materials provided with the
150Sstevel@tonic-gate * distribution.
160Sstevel@tonic-gate *
170Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this
180Sstevel@tonic-gate * software must display the following acknowledgment:
190Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
200Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
210Sstevel@tonic-gate *
220Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
230Sstevel@tonic-gate * endorse or promote products derived from this software without
240Sstevel@tonic-gate * prior written permission. For written permission, please contact
250Sstevel@tonic-gate * openssl-core@openssl.org.
260Sstevel@tonic-gate *
270Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL"
280Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written
290Sstevel@tonic-gate * permission of the OpenSSL Project.
300Sstevel@tonic-gate *
310Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following
320Sstevel@tonic-gate * acknowledgment:
330Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
340Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
350Sstevel@tonic-gate *
360Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
370Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
380Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
390Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
400Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
410Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
420Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
430Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
440Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
450Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
460Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
470Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE.
480Sstevel@tonic-gate * ====================================================================
490Sstevel@tonic-gate *
500Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young
510Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim
520Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com).
530Sstevel@tonic-gate *
540Sstevel@tonic-gate */
550Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
560Sstevel@tonic-gate * All rights reserved.
570Sstevel@tonic-gate *
580Sstevel@tonic-gate * This package is an SSL implementation written
590Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com).
600Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL.
610Sstevel@tonic-gate *
620Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as
630Sstevel@tonic-gate * the following conditions are aheared to. The following conditions
640Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA,
650Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation
660Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms
670Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com).
680Sstevel@tonic-gate *
690Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in
700Sstevel@tonic-gate * the code are not to be removed.
710Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution
720Sstevel@tonic-gate * as the author of the parts of the library used.
730Sstevel@tonic-gate * This can be in the form of a textual message at program startup or
740Sstevel@tonic-gate * in documentation (online or textual) provided with the package.
750Sstevel@tonic-gate *
760Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
770Sstevel@tonic-gate * modification, are permitted provided that the following conditions
780Sstevel@tonic-gate * are met:
790Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright
800Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
810Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
820Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
830Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
840Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software
850Sstevel@tonic-gate * must display the following acknowledgement:
860Sstevel@tonic-gate * "This product includes cryptographic software written by
870Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)"
880Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library
890Sstevel@tonic-gate * being used are not cryptographic related :-).
900Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from
910Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement:
920Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
930Sstevel@tonic-gate *
940Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
950Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
960Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
970Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
980Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
990Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1000Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1010Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1020Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1030Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1040Sstevel@tonic-gate * SUCH DAMAGE.
1050Sstevel@tonic-gate *
1060Sstevel@tonic-gate * The licence and distribution terms for any publically available version or
1070Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be
1080Sstevel@tonic-gate * copied and put under another distribution licence
1090Sstevel@tonic-gate * [including the GNU Public Licence.]
1100Sstevel@tonic-gate */
1110Sstevel@tonic-gate
1120Sstevel@tonic-gate #include <string.h>
1130Sstevel@tonic-gate #include <openssl/des.h>
1140Sstevel@tonic-gate #include <openssl/ui.h>
115*2139Sjp161948 #include <openssl/crypto.h>
1160Sstevel@tonic-gate
DES_read_password(DES_cblock * key,const char * prompt,int verify)1170Sstevel@tonic-gate int DES_read_password(DES_cblock *key, const char *prompt, int verify)
1180Sstevel@tonic-gate {
1190Sstevel@tonic-gate int ok;
1200Sstevel@tonic-gate char buf[BUFSIZ],buff[BUFSIZ];
1210Sstevel@tonic-gate
1220Sstevel@tonic-gate if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
1230Sstevel@tonic-gate DES_string_to_key(buf,key);
1240Sstevel@tonic-gate OPENSSL_cleanse(buf,BUFSIZ);
1250Sstevel@tonic-gate OPENSSL_cleanse(buff,BUFSIZ);
1260Sstevel@tonic-gate return(ok);
1270Sstevel@tonic-gate }
1280Sstevel@tonic-gate
DES_read_2passwords(DES_cblock * key1,DES_cblock * key2,const char * prompt,int verify)1290Sstevel@tonic-gate int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
1300Sstevel@tonic-gate int verify)
1310Sstevel@tonic-gate {
1320Sstevel@tonic-gate int ok;
1330Sstevel@tonic-gate char buf[BUFSIZ],buff[BUFSIZ];
1340Sstevel@tonic-gate
1350Sstevel@tonic-gate if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
1360Sstevel@tonic-gate DES_string_to_2keys(buf,key1,key2);
1370Sstevel@tonic-gate OPENSSL_cleanse(buf,BUFSIZ);
1380Sstevel@tonic-gate OPENSSL_cleanse(buff,BUFSIZ);
1390Sstevel@tonic-gate return(ok);
1400Sstevel@tonic-gate }
141