This file is indexed.

/usr/share/php/Horde/Crypt/Blowfish.php is in php-horde-crypt-blowfish 1.1.1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
 * Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
 * Copyright 2012-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @category  Horde
 * @copyright 2005-2008 Matthew Fonda
 * @copyright 2012-2016 Horde LLC
 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package   Crypt_Blowfish
 */

/**
 * Provides blowfish encryption/decryption, with or without a secret key,
 * for PHP strings.
 *
 * @author    Matthew Fonda <mfonda@php.net>
 * @author    Michael Slusarz <slusarz@horde.org>
 * @category  Horde
 * @copyright 2005-2008 Matthew Fonda
 * @copyright 2012-2016 Horde LLC
 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package   Crypt_Blowfish
 *
 * @property string $cipher  The cipher block mode ('ecb' or 'cbc').
 * @property string $key  The encryption key in use.
 * @property mixed $iv  The initialization vector (false if using 'ecb').
 */
class Horde_Crypt_Blowfish
{
    // Constants for 'ignore' parameter of constructor.
    const IGNORE_OPENSSL = 1;
    const IGNORE_MCRYPT = 2;

    // Block size for Blowfish
    const BLOCKSIZE = 8;

    // Maximum key size for Blowfish
    const MAXKEYSIZE = 56;

    // IV Length for CBC
    const IV_LENGTH = 8;

    /**
     * Blowfish crypt driver.
     *
     * @var Horde_Crypt_Blowfish_Base
     */
    protected $_crypt;

    /**
     * Constructor.
     *
     * @param string $key  Encryption key.
     * @param array $opts  Additional options:
     *   - cipher: (string) Either 'ecb' or 'cbc'.
     *   - ignore: (integer) A mask of drivers to ignore (IGNORE_* constants).
     *   - iv: (string) IV to use.
     */
    public function __construct($key, array $opts = array())
    {
        $opts = array_merge(array(
            'cipher' => 'ecb',
            'ignore' => 0,
            'iv' => null
        ), $opts);

        if (!($opts['ignore'] & self::IGNORE_OPENSSL) &&
            Horde_Crypt_Blowfish_Openssl::supported()) {
            $this->_crypt = new Horde_Crypt_Blowfish_Openssl($opts['cipher']);
        } elseif (!($opts['ignore'] & self::IGNORE_MCRYPT) &&
                  Horde_Crypt_Blowfish_Mcrypt::supported()) {
            $this->_crypt = new Horde_Crypt_Blowfish_Mcrypt($opts['cipher']);
        } else {
            $this->_crypt = new Horde_Crypt_Blowfish_Php($opts['cipher']);
        }

        $this->setKey($key, $opts['iv']);
    }

    /**
     */
    public function __get($name)
    {
        switch ($name) {
        case 'cipher':
        case 'key':
        case 'iv':
            return $this->_crypt->$name;
        }
    }

    /**
     * Encrypts a string.
     *
     * @param string $text  The string to encrypt.
     *
     * @return string  The ciphertext.
     * @throws Horde_Crypt_Blowfish_Exception
     */
    public function encrypt($text)
    {
        if (!is_string($text)) {
            throw new Horde_Crypt_Blowfish_Exception('Data to encrypt must be a string.');
        }

        return $this->_crypt->encrypt($text);
    }

    /**
     * Decrypts a string.
     *
     * @param string $text  The string to decrypt.
     *
     * @return string  The plaintext.
     * @throws Horde_Crypt_Blowfish_Exception
     */
    public function decrypt($text)
    {
        if (!is_string($text)) {
            throw new Horde_Crypt_Blowfish_Exception('Data to decrypt must be a string.');
        }

        return $this->_crypt->decrypt($text);
    }

    /**
     * Sets the secret key.
     *
     * The key must be non-zero, and less than or equal to MAXKEYSIZE
     * characters (bytes) in length.
     *
     * @param string $key  Key must be non-empty and less than MAXKEYSIZE
     *                     bytes in length.
     * @param string $iv   The initialization vector to use. Only needed for
     *                     'cbc' cipher. If null, an IV is automatically
     *                     generated.
     *
     * @throws Horde_Crypt_Blowfish_Exception
     */
    public function setKey($key, $iv = null)
    {
        if (!is_string($key)) {
            throw new Horde_Crypt_Blowfish_Exception('Encryption key must be a string.');
        }

        $len = strlen($key);
        if (($len > self::MAXKEYSIZE) || ($len == 0)) {
            throw new Horde_Crypt_Blowfish_Exception(sprintf('Encryption key must be less than %d characters (bytes) and non-zero. Supplied key length: %d', self::MAXKEYSIZE, $len));
        }

        $this->_crypt->key = $key;

        switch ($this->_crypt->cipher) {
        case 'cbc':
            if (is_null($iv)) {
                if (is_null($this->iv)) {
                    $this->_crypt->setIv();
                }
            } else {
                $iv = substr($iv, 0, self::IV_LENGTH);
                if (($len = strlen($iv)) < self::IV_LENGTH) {
                    $iv .= str_repeat(chr(0), self::IV_LENGTH - $len);
                }
                $this->_crypt->setIv($iv);
            }
            break;

        case 'ecb':
            $this->iv = false;
            break;
        }
    }

}