des_lib.c revision 296465
155372Smjacob/* crypto/des/ecb_enc.c */
255372Smjacob/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
355372Smjacob * All rights reserved.
455372Smjacob *
555372Smjacob * This package is an SSL implementation written
655372Smjacob * by Eric Young (eay@cryptsoft.com).
755372Smjacob * The implementation was written so as to conform with Netscapes SSL.
855372Smjacob *
955372Smjacob * This library is free for commercial and non-commercial use as long as
1055372Smjacob * the following conditions are aheared to.  The following conditions
1155372Smjacob * apply to all code found in this distribution, be it the RC4, RSA,
1255372Smjacob * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1355372Smjacob * included with this distribution is covered by the same copyright terms
1455372Smjacob * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1555372Smjacob *
1655372Smjacob * Copyright remains Eric Young's, and as such any Copyright notices in
1755372Smjacob * the code are not to be removed.
1855372Smjacob * If this package is used in a product, Eric Young should be given attribution
1955372Smjacob * as the author of the parts of the library used.
2055372Smjacob * This can be in the form of a textual message at program startup or
2155372Smjacob * in documentation (online or textual) provided with the package.
2255372Smjacob *
2355372Smjacob * Redistribution and use in source and binary forms, with or without
2455372Smjacob * modification, are permitted provided that the following conditions
2555372Smjacob * are met:
2655372Smjacob * 1. Redistributions of source code must retain the copyright
2755372Smjacob *    notice, this list of conditions and the following disclaimer.
2855372Smjacob * 2. Redistributions in binary form must reproduce the above copyright
2955372Smjacob *    notice, this list of conditions and the following disclaimer in the
3055372Smjacob *    documentation and/or other materials provided with the distribution.
3155372Smjacob * 3. All advertising materials mentioning features or use of this software
3255372Smjacob *    must display the following acknowledgement:
3355372Smjacob *    "This product includes cryptographic software written by
3455372Smjacob *     Eric Young (eay@cryptsoft.com)"
3555372Smjacob *    The word 'cryptographic' can be left out if the rouines from the library
3655372Smjacob *    being used are not cryptographic related :-).
3755372Smjacob * 4. If you include any Windows specific code (or a derivative thereof) from
3855372Smjacob *    the apps directory (application code) you must include an acknowledgement:
3955372Smjacob *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4055372Smjacob *
4155372Smjacob * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4255372Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4355372Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4455372Smjacob * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4555372Smjacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4655372Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4755372Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4855372Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4955372Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5055372Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5155372Smjacob * SUCH DAMAGE.
5255372Smjacob *
5355372Smjacob * The licence and distribution terms for any publically available version or
5455372Smjacob * derivative of this code cannot be changed.  i.e. this code cannot simply be
5555372Smjacob * copied and put under another distribution licence
5655372Smjacob * [including the GNU Public Licence.]
5755372Smjacob */
5855372Smjacob
5955372Smjacob#include "des_locl.h"
6055372Smjacob#include "des_ver.h"
6155372Smjacob#include <openssl/opensslv.h>
6255372Smjacob#include <openssl/bio.h>
6355372Smjacob
6455372SmjacobOPENSSL_GLOBAL const char libdes_version[] = "libdes" OPENSSL_VERSION_PTEXT;
6555372SmjacobOPENSSL_GLOBAL const char DES_version[] = "DES" OPENSSL_VERSION_PTEXT;
6655372Smjacob
6755372Smjacobconst char *DES_options(void)
6855372Smjacob{
6955372Smjacob    static int init = 1;
7055372Smjacob    static char buf[32];
7155372Smjacob
7255372Smjacob    if (init) {
7355372Smjacob        const char *ptr, *unroll, *risc, *size;
7455372Smjacob
7555372Smjacob#ifdef DES_PTR
7655372Smjacob        ptr = "ptr";
7755372Smjacob#else
7855372Smjacob        ptr = "idx";
7955372Smjacob#endif
8055372Smjacob#if defined(DES_RISC1) || defined(DES_RISC2)
8155372Smjacob# ifdef DES_RISC1
8255372Smjacob        risc = "risc1";
8355372Smjacob# endif
8455372Smjacob# ifdef DES_RISC2
8555372Smjacob        risc = "risc2";
8655372Smjacob# endif
8755372Smjacob#else
8855372Smjacob        risc = "cisc";
8955372Smjacob#endif
9055372Smjacob#ifdef DES_UNROLL
9155372Smjacob        unroll = "16";
9255372Smjacob#else
9355372Smjacob        unroll = "4";
9455372Smjacob#endif
9555372Smjacob        if (sizeof(DES_LONG) != sizeof(long))
9655372Smjacob            size = "int";
9755372Smjacob        else
9855372Smjacob            size = "long";
9955372Smjacob        BIO_snprintf(buf, sizeof buf, "des(%s,%s,%s,%s)", ptr, risc, unroll,
10055372Smjacob                     size);
10155372Smjacob        init = 0;
10255372Smjacob    }
10355372Smjacob    return (buf);
10455372Smjacob}
10555372Smjacob