|
Packit |
13e0ca |
/*
|
|
Packit |
13e0ca |
* FreeSec: libcrypt for NetBSD
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* Copyright (c) 1994 David Burren
|
|
Packit |
13e0ca |
* All rights reserved.
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* Adapted for FreeBSD-2.0 by Geoffrey M. Rehmet
|
|
Packit |
13e0ca |
* this file should now *only* export crypt(), in order to make
|
|
Packit |
13e0ca |
* binaries of libcrypt exportable from the USA
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* Adapted for FreeBSD-4.0 by Mark R V Murray
|
|
Packit |
13e0ca |
* this file should now *only* export crypt_des(), in order to make
|
|
Packit |
13e0ca |
* a module that can be optionally included in libcrypt.
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* Adapted for libxcrypt by Zack Weinberg, 2017
|
|
Packit |
13e0ca |
* see notes in des.c
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
13e0ca |
* modification, are permitted provided that the following conditions
|
|
Packit |
13e0ca |
* are met:
|
|
Packit |
13e0ca |
* 1. Redistributions of source code must retain the above copyright
|
|
Packit |
13e0ca |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
13e0ca |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit |
13e0ca |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit |
13e0ca |
* documentation and/or other materials provided with the distribution.
|
|
Packit |
13e0ca |
* 3. Neither the name of the author nor the names of other contributors
|
|
Packit |
13e0ca |
* may be used to endorse or promote products derived from this software
|
|
Packit |
13e0ca |
* without specific prior written permission.
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
Packit |
13e0ca |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
13e0ca |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
13e0ca |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
Packit |
13e0ca |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
13e0ca |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
Packit |
13e0ca |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
Packit |
13e0ca |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
Packit |
13e0ca |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
Packit |
13e0ca |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
Packit |
13e0ca |
* SUCH DAMAGE.
|
|
Packit |
13e0ca |
*
|
|
Packit |
13e0ca |
* This is an original implementation of the DES and the crypt(3) interfaces
|
|
Packit |
13e0ca |
* by David Burren <davidb@werj.com.au>.
|
|
Packit |
13e0ca |
*/
|
|
Packit |
13e0ca |
|
|
Packit |
13e0ca |
#ifndef _CRYPT_ALG_DES_H
|
|
Packit |
13e0ca |
#define _CRYPT_ALG_DES_H 1
|
|
Packit |
13e0ca |
|
|
Packit |
13e0ca |
/* des.c */
|
|
Packit |
13e0ca |
|
|
Packit |
13e0ca |
struct des_ctx
|
|
Packit |
13e0ca |
{
|
|
Packit |
13e0ca |
uint32_t keysl[16];
|
|
Packit |
13e0ca |
uint32_t keysr[16];
|
|
Packit |
13e0ca |
uint32_t saltbits;
|
|
Packit |
13e0ca |
};
|
|
Packit |
13e0ca |
|
|
Packit |
13e0ca |
extern void des_set_key (struct des_ctx *restrict ctx,
|
|
Packit |
13e0ca |
const unsigned char *key);
|
|
Packit |
13e0ca |
extern void des_set_salt (struct des_ctx *restrict ctx,
|
|
Packit |
13e0ca |
uint32_t salt);
|
|
Packit |
13e0ca |
extern void des_crypt_block (struct des_ctx *restrict ctx,
|
|
Packit |
13e0ca |
unsigned char *out, const unsigned char *in,
|
|
Packit |
13e0ca |
unsigned int count, bool decrypt);
|
|
Packit |
13e0ca |
|
|
Packit |
13e0ca |
/* des-tables.c (generated by des-mktables) */
|
|
Packit |
13e0ca |
extern const uint8_t m_sbox[4][4096];
|
|
Packit |
13e0ca |
extern const uint32_t ip_maskl[8][256], ip_maskr[8][256];
|
|
Packit |
13e0ca |
extern const uint32_t fp_maskl[8][256], fp_maskr[8][256];
|
|
Packit |
13e0ca |
extern const uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
|
|
Packit |
13e0ca |
extern const uint32_t comp_maskl[8][128], comp_maskr[8][128];
|
|
Packit |
13e0ca |
extern const uint32_t psbox[4][256];
|
|
Packit |
13e0ca |
|
|
Packit |
13e0ca |
#endif /* alg-des.h */
|