2016-05-17 18:24:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 10:52:47 +00:00
|
|
|
*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 10:52:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/cryptlib.h"
|
2003-03-20 23:28:16 +00:00
|
|
|
#ifndef OPENSSL_NO_BF
|
2015-01-22 03:40:55 +00:00
|
|
|
# include <openssl/evp.h>
|
2019-09-27 21:57:58 +00:00
|
|
|
# include "crypto/evp.h"
|
2015-01-22 03:40:55 +00:00
|
|
|
# include <openssl/objects.h>
|
|
|
|
# include <openssl/blowfish.h>
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2000-06-03 14:13:58 +00:00
|
|
|
static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
2015-01-22 03:40:55 +00:00
|
|
|
const unsigned char *iv, int enc);
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
typedef struct {
|
|
|
|
BF_KEY ks;
|
|
|
|
} EVP_BF_KEY;
|
2001-07-30 23:57:25 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
# define data(ctx) EVP_C_DATA(EVP_BF_KEY,ctx)
|
2001-07-30 23:57:25 +00:00
|
|
|
|
2002-02-16 12:39:07 +00:00
|
|
|
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
|
2015-01-22 03:40:55 +00:00
|
|
|
EVP_CIPH_VARIABLE_LENGTH, bf_init_key, NULL,
|
|
|
|
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
|
|
|
|
|
2000-06-03 14:13:58 +00:00
|
|
|
static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
2015-01-22 03:40:55 +00:00
|
|
|
const unsigned char *iv, int enc)
|
|
|
|
{
|
|
|
|
BF_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key);
|
|
|
|
return 1;
|
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
|
|
|
#endif
|