1 /*
2 * FreeSec: libcrypt for NetBSD
3 *
4 * Copyright (c) 1994 David Burren
5 * All rights reserved.
6 *
7 * Adapted for FreeBSD-2.0 by Geoffrey M. Rehmet
8 * this file should now *only* export crypt(), in order to make
9 * binaries of libcrypt exportable from the USA
10 *
11 * Adapted for FreeBSD-4.0 by Mark R V Murray
12 * this file should now *only* export crypt_des(), in order to make
13 * a module that can be optionally included in libcrypt.
14 *
15 * Adapted for libxcrypt by Zack Weinberg, 2017
16 * see notes in des.c
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. Neither the name of the author nor the names of other contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * This is an original implementation of the DES and the crypt(3) interfaces
43 * by David Burren <davidb@werj.com.au>.
44 */
45
46 #ifndef _CRYPT_ALG_DES_H
47 #define _CRYPT_ALG_DES_H 1
48
49 /* des.c */
50
51 struct des_ctx
52 {
53 uint32_t keysl[16];
54 uint32_t keysr[16];
55 uint32_t saltbits;
56 };
57
58 extern void des_set_key (struct des_ctx *restrict ctx,
59 const unsigned char key[MIN_SIZE(8)]);
60 extern void des_set_salt (struct des_ctx *restrict ctx,
61 uint32_t salt);
62 extern void des_crypt_block (struct des_ctx *restrict ctx,
63 unsigned char *out, const unsigned char *in,
64 unsigned int count, bool decrypt);
65
66 /* des-tables.c (generated by des-mktables) */
67 extern const uint8_t m_sbox[4][4096];
68 extern const uint32_t ip_maskl[8][256], ip_maskr[8][256];
69 extern const uint32_t fp_maskl[8][256], fp_maskr[8][256];
70 extern const uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
71 extern const uint32_t comp_maskl[8][128], comp_maskr[8][128];
72 extern const uint32_t psbox[4][256];
73
74 #endif /* alg-des.h */