openssl-prebuild/linux_amd64/share/doc/openssl/html/man3/BF_encrypt.html
2020-03-02 16:50:34 +00:00

162 lines
7.5 KiB
HTML
Executable File

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BF_encrypt</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#return_values">RETURN VALUES</a></li>
<li><a href="#note">NOTE</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#history">HISTORY</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<hr />
<h1><a name="name">NAME</a></h1>
<p>BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt, BF_cbc_encrypt,
BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options - Blowfish encryption</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
#include &lt;openssl/blowfish.h&gt;</pre>
<p>Deprecated since OpenSSL 3.0, can be hidden entirely by defining
<strong>OPENSSL_API_COMPAT</strong> with a suitable version value, see
<em>openssl_user_macros(7)</em>:</p>
<pre>
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);</pre>
<pre>
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
BF_KEY *key, int enc);
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out,
long length, BF_KEY *schedule,
unsigned char *ivec, int enc);
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
long length, BF_KEY *schedule,
unsigned char *ivec, int *num, int enc);
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
long length, BF_KEY *schedule,
unsigned char *ivec, int *num);
const char *BF_options(void);</pre>
<pre>
void BF_encrypt(BF_LONG *data, const BF_KEY *key);
void BF_decrypt(BF_LONG *data, const BF_KEY *key);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>All of the functions described on this page are deprecated. Applications should
instead use <em>EVP_EncryptInit_ex(3)</em>, <em>EVP_EncryptUpdate(3)</em> and
<em>EVP_EncryptFinal_ex(3)</em> or the equivalently named decrypt functions.</p>
<p>This library implements the Blowfish cipher, which was invented and described
by Counterpane (see <a href="http://www.counterpane.com/blowfish.html">http://www.counterpane.com/blowfish.html</a> ).</p>
<p>Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data.
It uses a variable size key, but typically, 128 bit (16 byte) keys are
considered good for strong encryption. Blowfish can be used in the same
modes as DES (see <em>des_modes(7)</em>). Blowfish is currently one
of the faster block ciphers. It is quite a bit faster than DES, and much
faster than IDEA or RC2.</p>
<p>Blowfish consists of a key setup phase and the actual encryption or decryption
phase.</p>
<p><code>BF_set_key()</code> sets up the <strong>BF_KEY</strong> <strong>key</strong> using the <strong>len</strong> bytes long key
at <strong>data</strong>.</p>
<p><code>BF_ecb_encrypt()</code> is the basic Blowfish encryption and decryption function.
It encrypts or decrypts the first 64 bits of <strong>in</strong> using the key <strong>key</strong>,
putting the result in <strong>out</strong>. <strong>enc</strong> decides if encryption (<strong>BF_ENCRYPT</strong>)
or decryption (<strong>BF_DECRYPT</strong>) shall be performed. The vector pointed at by
<strong>in</strong> and <strong>out</strong> must be 64 bits in length, no less. If they are larger,
everything after the first 64 bits is ignored.</p>
<p>The mode functions <code>BF_cbc_encrypt()</code>, BF_cfb64_encrypt() and BF_ofb64_encrypt()
all operate on variable length data. They all take an initialization vector
<strong>ivec</strong> which needs to be passed along into the next call of the same function
for the same message. <strong>ivec</strong> may be initialized with anything, but the
recipient needs to know what it was initialized with, or it won't be able
to decrypt. Some programs and protocols simplify this, like SSH, where
<strong>ivec</strong> is simply initialized to zero.
<code>BF_cbc_encrypt()</code> operates on data that is a multiple of 8 bytes long, while
BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt an variable
number of bytes (the amount does not have to be an exact multiple of 8). The
purpose of the latter two is to simulate stream ciphers, and therefore, they
need the parameter <strong>num</strong>, which is a pointer to an integer where the current
offset in <strong>ivec</strong> is stored between calls. This integer must be initialized
to zero when <strong>ivec</strong> is initialized.</p>
<p><code>BF_cbc_encrypt()</code> is the Cipher Block Chaining function for Blowfish. It
encrypts or decrypts the 64 bits chunks of <strong>in</strong> using the key <strong>schedule</strong>,
putting the result in <strong>out</strong>. <strong>enc</strong> decides if encryption (BF_ENCRYPT) or
decryption (BF_DECRYPT) shall be performed. <strong>ivec</strong> must point at an 8 byte
long initialization vector.</p>
<p>BF_cfb64_encrypt() is the CFB mode for Blowfish with 64 bit feedback.
It encrypts or decrypts the bytes in <strong>in</strong> using the key <strong>schedule</strong>,
putting the result in <strong>out</strong>. <strong>enc</strong> decides if encryption (<strong>BF_ENCRYPT</strong>)
or decryption (<strong>BF_DECRYPT</strong>) shall be performed. <strong>ivec</strong> must point at an
8 byte long initialization vector. <strong>num</strong> must point at an integer which must
be initially zero.</p>
<p>BF_ofb64_encrypt() is the OFB mode for Blowfish with 64 bit feedback.
It uses the same parameters as BF_cfb64_encrypt(), which must be initialized
the same way.</p>
<p><code>BF_encrypt()</code> and <code>BF_decrypt()</code> are the lowest level functions for Blowfish
encryption. They encrypt/decrypt the first 64 bits of the vector pointed by
<strong>data</strong>, using the key <strong>key</strong>. These functions should not be used unless you
implement 'modes' of Blowfish. The alternative is to use <code>BF_ecb_encrypt()</code>.
If you still want to use these functions, you should be aware that they take
each 32-bit chunk in host-byte order, which is little-endian on little-endian
platforms and big-endian on big-endian ones.</p>
<p>
</p>
<hr />
<h1><a name="return_values">RETURN VALUES</a></h1>
<p>None of the functions presented here return any value.</p>
<p>
</p>
<hr />
<h1><a name="note">NOTE</a></h1>
<p>Applications should use the higher level functions
<em>EVP_EncryptInit(3)</em> etc. instead of calling these
functions directly.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>EVP_EncryptInit(3)</em>,
<em>des_modes(7)</em></p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p>All of these functions were deprecated in OpenSSL 3.0.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.</p>
<p>Licensed under the Apache License 2.0 (the &quot;License&quot;). 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
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
</body>
</html>