Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:42

0001 /*
0002  * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #ifndef OPENSSL_DES_H
0011 # define OPENSSL_DES_H
0012 # pragma once
0013 
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 #  define HEADER_DES_H
0017 # endif
0018 
0019 # include <openssl/opensslconf.h>
0020 
0021 # ifndef OPENSSL_NO_DES
0022 #  ifdef  __cplusplus
0023 extern "C" {
0024 #  endif
0025 #  include <openssl/e_os2.h>
0026 
0027 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0028 typedef unsigned int DES_LONG;
0029 
0030 #   ifdef OPENSSL_BUILD_SHLIBCRYPTO
0031 #    undef OPENSSL_EXTERN
0032 #    define OPENSSL_EXTERN OPENSSL_EXPORT
0033 #   endif
0034 
0035 typedef unsigned char DES_cblock[8];
0036 typedef /* const */ unsigned char const_DES_cblock[8];
0037 /*
0038  * With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and
0039  * const_DES_cblock * are incompatible pointer types.
0040  */
0041 
0042 typedef struct DES_ks {
0043     union {
0044         DES_cblock cblock;
0045         /*
0046          * make sure things are correct size on machines with 8 byte longs
0047          */
0048         DES_LONG deslong[2];
0049     } ks[16];
0050 } DES_key_schedule;
0051 
0052 #   define DES_KEY_SZ      (sizeof(DES_cblock))
0053 #   define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
0054 
0055 #   define DES_ENCRYPT     1
0056 #   define DES_DECRYPT     0
0057 
0058 #   define DES_CBC_MODE    0
0059 #   define DES_PCBC_MODE   1
0060 
0061 #   define DES_ecb2_encrypt(i,o,k1,k2,e) \
0062         DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
0063 
0064 #   define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
0065         DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
0066 
0067 #   define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
0068         DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
0069 
0070 #   define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
0071         DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
0072 
0073 #   define DES_fixup_key_parity DES_set_odd_parity
0074 #  endif
0075 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0076 OSSL_DEPRECATEDIN_3_0 const char *DES_options(void);
0077 OSSL_DEPRECATEDIN_3_0
0078 void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
0079                       DES_key_schedule *ks1, DES_key_schedule *ks2,
0080                       DES_key_schedule *ks3, int enc);
0081 OSSL_DEPRECATEDIN_3_0
0082 DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
0083                        long length, DES_key_schedule *schedule,
0084                        const_DES_cblock *ivec);
0085 #  endif
0086 /* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */
0087 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0088 OSSL_DEPRECATEDIN_3_0
0089 void DES_cbc_encrypt(const unsigned char *input, unsigned char *output,
0090                      long length, DES_key_schedule *schedule, DES_cblock *ivec,
0091                      int enc);
0092 OSSL_DEPRECATEDIN_3_0
0093 void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
0094                       long length, DES_key_schedule *schedule, DES_cblock *ivec,
0095                       int enc);
0096 OSSL_DEPRECATEDIN_3_0
0097 void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
0098                       long length, DES_key_schedule *schedule, DES_cblock *ivec,
0099                       const_DES_cblock *inw, const_DES_cblock *outw, int enc);
0100 OSSL_DEPRECATEDIN_3_0
0101 void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
0102                      long length, DES_key_schedule *schedule, DES_cblock *ivec,
0103                      int enc);
0104 OSSL_DEPRECATEDIN_3_0
0105 void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
0106                      DES_key_schedule *ks, int enc);
0107 #  endif
0108 
0109 /*
0110  * This is the DES encryption function that gets called by just about every
0111  * other DES routine in the library.  You should not use this function except
0112  * to implement 'modes' of DES.  I say this because the functions that call
0113  * this routine do the conversion from 'char *' to long, and this needs to be
0114  * done to make sure 'non-aligned' memory access do not occur.  The
0115  * characters are loaded 'little endian'. Data is a pointer to 2 unsigned
0116  * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies
0117  * encryption, zero if decryption.
0118  */
0119 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0120 OSSL_DEPRECATEDIN_3_0
0121 void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);
0122 #  endif
0123 
0124 /*
0125  * This functions is the same as DES_encrypt1() except that the DES initial
0126  * permutation (IP) and final permutation (FP) have been left out.  As for
0127  * DES_encrypt1(), you should not use this function. It is used by the
0128  * routines in the library that implement triple DES. IP() DES_encrypt2()
0129  * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()
0130  * DES_encrypt1() DES_encrypt1() except faster :-).
0131  */
0132 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0133 OSSL_DEPRECATEDIN_3_0
0134 void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);
0135 OSSL_DEPRECATEDIN_3_0
0136 void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2,
0137                   DES_key_schedule *ks3);
0138 OSSL_DEPRECATEDIN_3_0
0139 void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2,
0140                   DES_key_schedule *ks3);
0141 OSSL_DEPRECATEDIN_3_0
0142 void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
0143                           long length, DES_key_schedule *ks1,
0144                           DES_key_schedule *ks2, DES_key_schedule *ks3,
0145                           DES_cblock *ivec, int enc);
0146 OSSL_DEPRECATEDIN_3_0
0147 void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
0148                             long length, DES_key_schedule *ks1,
0149                             DES_key_schedule *ks2, DES_key_schedule *ks3,
0150                             DES_cblock *ivec, int *num, int enc);
0151 OSSL_DEPRECATEDIN_3_0
0152 void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,
0153                           int numbits, long length, DES_key_schedule *ks1,
0154                           DES_key_schedule *ks2, DES_key_schedule *ks3,
0155                           DES_cblock *ivec, int enc);
0156 OSSL_DEPRECATEDIN_3_0
0157 void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
0158                             long length, DES_key_schedule *ks1,
0159                             DES_key_schedule *ks2, DES_key_schedule *ks3,
0160                             DES_cblock *ivec, int *num);
0161 OSSL_DEPRECATEDIN_3_0
0162 char *DES_fcrypt(const char *buf, const char *salt, char *ret);
0163 OSSL_DEPRECATEDIN_3_0
0164 char *DES_crypt(const char *buf, const char *salt);
0165 OSSL_DEPRECATEDIN_3_0
0166 void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
0167                      long length, DES_key_schedule *schedule, DES_cblock *ivec);
0168 OSSL_DEPRECATEDIN_3_0
0169 void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
0170                       long length, DES_key_schedule *schedule,
0171                       DES_cblock *ivec, int enc);
0172 OSSL_DEPRECATEDIN_3_0
0173 DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
0174                         long length, int out_count, DES_cblock *seed);
0175 OSSL_DEPRECATEDIN_3_0 int DES_random_key(DES_cblock *ret);
0176 OSSL_DEPRECATEDIN_3_0 void DES_set_odd_parity(DES_cblock *key);
0177 OSSL_DEPRECATEDIN_3_0 int DES_check_key_parity(const_DES_cblock *key);
0178 OSSL_DEPRECATEDIN_3_0 int DES_is_weak_key(const_DES_cblock *key);
0179 #  endif
0180 /*
0181  * DES_set_key (= set_key = DES_key_sched = key_sched) calls
0182  * DES_set_key_checked
0183  */
0184 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0185 OSSL_DEPRECATEDIN_3_0
0186 int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
0187 OSSL_DEPRECATEDIN_3_0
0188 int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
0189 OSSL_DEPRECATEDIN_3_0
0190 int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);
0191 OSSL_DEPRECATEDIN_3_0
0192 void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);
0193 OSSL_DEPRECATEDIN_3_0 void DES_string_to_key(const char *str, DES_cblock *key);
0194 OSSL_DEPRECATEDIN_3_0
0195 void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);
0196 OSSL_DEPRECATEDIN_3_0
0197 void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
0198                        long length, DES_key_schedule *schedule,
0199                        DES_cblock *ivec, int *num, int enc);
0200 OSSL_DEPRECATEDIN_3_0
0201 void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
0202                        long length, DES_key_schedule *schedule,
0203                        DES_cblock *ivec, int *num);
0204 #  endif
0205 
0206 #  ifdef  __cplusplus
0207 }
0208 #  endif
0209 # endif
0210 
0211 #endif