1/*
2 * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC
3 *
4 * des_crypt.h, des library routine interface
5 * Copyright (c) 2010, Oracle America, Inc.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials
16 * provided with the distribution.
17 * * Neither the name of the "Oracle America, Inc." nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __DES_CRYPT_H__
36#define __DES_CRYPT_H__ 1
37
38#include <features.h>
39
40__BEGIN_DECLS
41
42#define DES_MAXDATA 8192 /* max bytes encrypted in one call */
43#define DES_DIRMASK (1 << 0)
44#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */
45#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */
46
47
48#define DES_DEVMASK (1 << 1)
49#define DES_HW (0*DES_DEVMASK) /* Use hardware device */
50#define DES_SW (1*DES_DEVMASK) /* Use software device */
51
52
53#define DESERR_NONE 0 /* succeeded */
54#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */
55#define DESERR_HWERROR 2 /* failed, hardware/driver error */
56#define DESERR_BADPARAM 3 /* failed, bad parameter to call */
57
58#define DES_FAILED(err) \
59 ((err) > DESERR_NOHWDEVICE)
60
61/*
62 * cbc_crypt()
63 * ecb_crypt()
64 *
65 * Encrypt (or decrypt) len bytes of a buffer buf.
66 * The length must be a multiple of eight.
67 * The key should have odd parity in the low bit of each byte.
68 * ivec is the input vector, and is updated to the new one (cbc only).
69 * The mode is created by oring together the appropriate parameters.
70 * DESERR_NOHWDEVICE is returned if DES_HW was specified but
71 * there was no hardware to do it on (the data will still be
72 * encrypted though, in software).
73 */
74
75
76/*
77 * Cipher Block Chaining mode
78 */
79extern int cbc_crypt (char *__key, char *__buf, unsigned __len,
80 unsigned __mode, char *__ivec) __THROW;
81
82/*
83 * Electronic Code Book mode
84 */
85extern int ecb_crypt (char *__key, char *__buf, unsigned __len,
86 unsigned __mode) __THROW;
87
88/*
89 * Set des parity for a key.
90 * DES parity is odd and in the low bit of each byte
91 */
92extern void des_setparity (char *__key) __THROW;
93
94__END_DECLS
95
96#endif
97