1 // Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef OPENSSL_HEADER_CAST_H 16 #define OPENSSL_HEADER_CAST_H 17 18 #include <openssl/base.h> // IWYU pragma: export 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 25 #define CAST_ENCRYPT 1 26 #define CAST_DECRYPT 0 27 28 #define CAST_BLOCK 8 29 #define CAST_KEY_LENGTH 16 30 31 typedef struct cast_key_st { 32 uint32_t data[32]; 33 int short_key; // Use reduced rounds for short key 34 } CAST_KEY; 35 36 OPENSSL_EXPORT void CAST_set_key(CAST_KEY *key, size_t len, 37 const uint8_t *data); 38 OPENSSL_EXPORT void CAST_ecb_encrypt(const uint8_t *in, uint8_t *out, 39 const CAST_KEY *key, int enc); 40 OPENSSL_EXPORT void CAST_encrypt(uint32_t *data, const CAST_KEY *key); 41 OPENSSL_EXPORT void CAST_decrypt(uint32_t *data, const CAST_KEY *key); 42 OPENSSL_EXPORT void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, 43 size_t length, const CAST_KEY *ks, 44 uint8_t *iv, int enc); 45 46 OPENSSL_EXPORT void CAST_cfb64_encrypt(const uint8_t *in, uint8_t *out, 47 size_t length, const CAST_KEY *schedule, 48 uint8_t *ivec, int *num, int enc); 49 50 #ifdef __cplusplus 51 } 52 #endif 53 54 #endif // OPENSSL_HEADER_CAST_H 55