annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/openssl/des.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
jpayne@69 3 *
jpayne@69 4 * Licensed under the OpenSSL license (the "License"). You may not use
jpayne@69 5 * this file except in compliance with the License. You can obtain a copy
jpayne@69 6 * in the file LICENSE in the source distribution or at
jpayne@69 7 * https://www.openssl.org/source/license.html
jpayne@69 8 */
jpayne@69 9
jpayne@69 10 #ifndef HEADER_DES_H
jpayne@69 11 # define HEADER_DES_H
jpayne@69 12
jpayne@69 13 # include <openssl/opensslconf.h>
jpayne@69 14
jpayne@69 15 # ifndef OPENSSL_NO_DES
jpayne@69 16 # ifdef __cplusplus
jpayne@69 17 extern "C" {
jpayne@69 18 # endif
jpayne@69 19 # include <openssl/e_os2.h>
jpayne@69 20
jpayne@69 21 typedef unsigned int DES_LONG;
jpayne@69 22
jpayne@69 23 # ifdef OPENSSL_BUILD_SHLIBCRYPTO
jpayne@69 24 # undef OPENSSL_EXTERN
jpayne@69 25 # define OPENSSL_EXTERN OPENSSL_EXPORT
jpayne@69 26 # endif
jpayne@69 27
jpayne@69 28 typedef unsigned char DES_cblock[8];
jpayne@69 29 typedef /* const */ unsigned char const_DES_cblock[8];
jpayne@69 30 /*
jpayne@69 31 * With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and
jpayne@69 32 * const_DES_cblock * are incompatible pointer types.
jpayne@69 33 */
jpayne@69 34
jpayne@69 35 typedef struct DES_ks {
jpayne@69 36 union {
jpayne@69 37 DES_cblock cblock;
jpayne@69 38 /*
jpayne@69 39 * make sure things are correct size on machines with 8 byte longs
jpayne@69 40 */
jpayne@69 41 DES_LONG deslong[2];
jpayne@69 42 } ks[16];
jpayne@69 43 } DES_key_schedule;
jpayne@69 44
jpayne@69 45 # define DES_KEY_SZ (sizeof(DES_cblock))
jpayne@69 46 # define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
jpayne@69 47
jpayne@69 48 # define DES_ENCRYPT 1
jpayne@69 49 # define DES_DECRYPT 0
jpayne@69 50
jpayne@69 51 # define DES_CBC_MODE 0
jpayne@69 52 # define DES_PCBC_MODE 1
jpayne@69 53
jpayne@69 54 # define DES_ecb2_encrypt(i,o,k1,k2,e) \
jpayne@69 55 DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
jpayne@69 56
jpayne@69 57 # define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
jpayne@69 58 DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
jpayne@69 59
jpayne@69 60 # define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
jpayne@69 61 DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
jpayne@69 62
jpayne@69 63 # define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
jpayne@69 64 DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
jpayne@69 65
jpayne@69 66 OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */
jpayne@69 67 # define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
jpayne@69 68
jpayne@69 69 const char *DES_options(void);
jpayne@69 70 void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
jpayne@69 71 DES_key_schedule *ks1, DES_key_schedule *ks2,
jpayne@69 72 DES_key_schedule *ks3, int enc);
jpayne@69 73 DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
jpayne@69 74 long length, DES_key_schedule *schedule,
jpayne@69 75 const_DES_cblock *ivec);
jpayne@69 76 /* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
jpayne@69 77 void DES_cbc_encrypt(const unsigned char *input, unsigned char *output,
jpayne@69 78 long length, DES_key_schedule *schedule,
jpayne@69 79 DES_cblock *ivec, int enc);
jpayne@69 80 void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
jpayne@69 81 long length, DES_key_schedule *schedule,
jpayne@69 82 DES_cblock *ivec, int enc);
jpayne@69 83 void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
jpayne@69 84 long length, DES_key_schedule *schedule,
jpayne@69 85 DES_cblock *ivec, const_DES_cblock *inw,
jpayne@69 86 const_DES_cblock *outw, int enc);
jpayne@69 87 void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
jpayne@69 88 long length, DES_key_schedule *schedule,
jpayne@69 89 DES_cblock *ivec, int enc);
jpayne@69 90 void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
jpayne@69 91 DES_key_schedule *ks, int enc);
jpayne@69 92
jpayne@69 93 /*
jpayne@69 94 * This is the DES encryption function that gets called by just about every
jpayne@69 95 * other DES routine in the library. You should not use this function except
jpayne@69 96 * to implement 'modes' of DES. I say this because the functions that call
jpayne@69 97 * this routine do the conversion from 'char *' to long, and this needs to be
jpayne@69 98 * done to make sure 'non-aligned' memory access do not occur. The
jpayne@69 99 * characters are loaded 'little endian'. Data is a pointer to 2 unsigned
jpayne@69 100 * long's and ks is the DES_key_schedule to use. enc, is non zero specifies
jpayne@69 101 * encryption, zero if decryption.
jpayne@69 102 */
jpayne@69 103 void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);
jpayne@69 104
jpayne@69 105 /*
jpayne@69 106 * This functions is the same as DES_encrypt1() except that the DES initial
jpayne@69 107 * permutation (IP) and final permutation (FP) have been left out. As for
jpayne@69 108 * DES_encrypt1(), you should not use this function. It is used by the
jpayne@69 109 * routines in the library that implement triple DES. IP() DES_encrypt2()
jpayne@69 110 * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()
jpayne@69 111 * DES_encrypt1() DES_encrypt1() except faster :-).
jpayne@69 112 */
jpayne@69 113 void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);
jpayne@69 114
jpayne@69 115 void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
jpayne@69 116 DES_key_schedule *ks2, DES_key_schedule *ks3);
jpayne@69 117 void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
jpayne@69 118 DES_key_schedule *ks2, DES_key_schedule *ks3);
jpayne@69 119 void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
jpayne@69 120 long length,
jpayne@69 121 DES_key_schedule *ks1, DES_key_schedule *ks2,
jpayne@69 122 DES_key_schedule *ks3, DES_cblock *ivec, int enc);
jpayne@69 123 void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
jpayne@69 124 long length, DES_key_schedule *ks1,
jpayne@69 125 DES_key_schedule *ks2, DES_key_schedule *ks3,
jpayne@69 126 DES_cblock *ivec, int *num, int enc);
jpayne@69 127 void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,
jpayne@69 128 int numbits, long length, DES_key_schedule *ks1,
jpayne@69 129 DES_key_schedule *ks2, DES_key_schedule *ks3,
jpayne@69 130 DES_cblock *ivec, int enc);
jpayne@69 131 void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
jpayne@69 132 long length, DES_key_schedule *ks1,
jpayne@69 133 DES_key_schedule *ks2, DES_key_schedule *ks3,
jpayne@69 134 DES_cblock *ivec, int *num);
jpayne@69 135 char *DES_fcrypt(const char *buf, const char *salt, char *ret);
jpayne@69 136 char *DES_crypt(const char *buf, const char *salt);
jpayne@69 137 void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
jpayne@69 138 long length, DES_key_schedule *schedule,
jpayne@69 139 DES_cblock *ivec);
jpayne@69 140 void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
jpayne@69 141 long length, DES_key_schedule *schedule,
jpayne@69 142 DES_cblock *ivec, int enc);
jpayne@69 143 DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
jpayne@69 144 long length, int out_count, DES_cblock *seed);
jpayne@69 145 int DES_random_key(DES_cblock *ret);
jpayne@69 146 void DES_set_odd_parity(DES_cblock *key);
jpayne@69 147 int DES_check_key_parity(const_DES_cblock *key);
jpayne@69 148 int DES_is_weak_key(const_DES_cblock *key);
jpayne@69 149 /*
jpayne@69 150 * DES_set_key (= set_key = DES_key_sched = key_sched) calls
jpayne@69 151 * DES_set_key_checked if global variable DES_check_key is set,
jpayne@69 152 * DES_set_key_unchecked otherwise.
jpayne@69 153 */
jpayne@69 154 int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
jpayne@69 155 int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
jpayne@69 156 int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);
jpayne@69 157 void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);
jpayne@69 158 void DES_string_to_key(const char *str, DES_cblock *key);
jpayne@69 159 void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);
jpayne@69 160 void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
jpayne@69 161 long length, DES_key_schedule *schedule,
jpayne@69 162 DES_cblock *ivec, int *num, int enc);
jpayne@69 163 void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
jpayne@69 164 long length, DES_key_schedule *schedule,
jpayne@69 165 DES_cblock *ivec, int *num);
jpayne@69 166
jpayne@69 167 # define DES_fixup_key_parity DES_set_odd_parity
jpayne@69 168
jpayne@69 169 # ifdef __cplusplus
jpayne@69 170 }
jpayne@69 171 # endif
jpayne@69 172 # endif
jpayne@69 173
jpayne@69 174 #endif