]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/evp/e_cast.c
Update copyright year
[thirdparty/openssl.git] / crypto / evp / e_cast.c
CommitLineData
62867571 1/*
3c2bdd7d 2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
58964a49 3 *
4a8b0c55 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
62867571
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
58964a49
RE
8 */
9
0ae5d4d6
MC
10/*
11 * CAST low level APIs are deprecated for public use, but still ok for
12 * internal use.
13 */
14#include "internal/deprecated.h"
15
58964a49 16#include <stdio.h>
b39fc560 17#include "internal/cryptlib.h"
fb105909
RL
18
19#ifndef OPENSSL_NO_CAST
0f113f3e
MC
20# include <openssl/evp.h>
21# include <openssl/objects.h>
25f2138b 22# include "crypto/evp.h"
0f113f3e 23# include <openssl/cast.h>
2f5c405a 24# include "evp_local.h"
58964a49 25
1921eaad 26static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
0f113f3e
MC
27 const unsigned char *iv, int enc);
28
29typedef struct {
30 CAST_KEY ks;
31} EVP_CAST_KEY;
58964a49 32
0f113f3e 33# define data(ctx) EVP_C_DATA(EVP_CAST_KEY,ctx)
dbad1690 34
0f113f3e
MC
35IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY,
36 NID_cast5, 8, CAST_KEY_LENGTH, 8, 64,
37 EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL,
38 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
dbad1690 39
1921eaad 40static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
0f113f3e
MC
41 const unsigned char *iv, int enc)
42{
1002bb9f
P
43 int keylen = EVP_CIPHER_CTX_key_length(ctx);
44
45 if (keylen <= 0)
46 return 0;
47 CAST_set_key(&data(ctx)->ks, keylen, key);
0f113f3e
MC
48 return 1;
49}
58964a49 50
58964a49 51#endif