Function | Package: excl | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version

## blowfish-decrypt

Arguments: encrypted &key key end context (pad t) string in-place (external-format :utf-8) (mode :ecb) iv

Blowfish is an old cipher, designed in 1993. We recommend it not be used, because it is susceptible to various attacks and is no longer considered secure. We maintain support to allow for encrypted material to be decrypted.

This function decrypts encrypted, which should be an (unsigned-byte 8) array returned by a call to blowfish-encrypt.

This function returns one or two values, as the string keyword argument is true or false. If string is true, a string is returned as the only returned value. If string is false, an (unsigned-byte 8) array representing the decryption and an integer specifying how many bytes there are in the decrypted result are returned. The second returned value is the length of the array returned as the first returned value when the in-place keyword argument is false, and is a value less than or equal to the length when in-place is true.

The arguments are:

- encrypted (the single required argument): an (unsigned-byte 8) array as returned by blowfish-encrypt.
- key: a string or (unsigned-byte 8) array. It must be the same key used by blowfish-encrypt to produce the value encrypted. Do not specify a value for this argument and for context.
- end: an integer or `nil`. If an integer, the length of the encrypted portion of encrypted (the same value as the second value returned by blowfish-encrypt). If `nil`, then the whole of encrypted is used. (The in-place argument to both this function and to blowfish-encrypt allows using an existing (unsigned-byte 8) array, which may be larger than necessary to hold the encrypted value. This argument allows you to specify the actual encrypted portion and ignore the remainder of the array.)
- context: an object (again, an (unsigned-byte 8) array) returned by blowfish-init when passed the key used to encrypt encrypted. This argument is typically used when a number of things need to be encrypted or decrypted using the same key. (The first step in encryption and decryption is to convert the key into a context object. Using the context object directly avoids repeating this step for each encryption/decryption.) Do not specify a value for this argument and for key.
- pad (default is `t`): the value should be the same as was passed as the pad argument to blowfish-encrypt. It tells whether the encrypted value was padded out to have an octet length of 8.
- string: if specified true, the (unsigned-byte 8) array raw decryption result is converted to be a string using the `:utf-8` external format, and the resulting string is returned as the single returned value. If `nil`, the raw (unsigned-byte 8) array is returned as the first value and the length of the decrypted portion in the array is returned as the second value.
- in-place: if specified true, the value of encrypted will be modified to hold the decrypted value (if possible). If it is not possible to decrypt in place then this argument will be ignored and a new (unsigned-byte 8) array will be created. If encrypted is used and string is `nil`, the second returned value (the number of bytes in the decryption) may be less than the length of the first returned value.
- external-format: this argument specifies the external format to be used when decrypting the string to be encrypted. Its value should be the same as used when the string was encrypted. The default is `:utf-8` and that is in general a good choice. When `:default` is specified, the value returned by `(find-external-format :default)` is used (see find-external-format). That value is not recommended because the value of the default external format (which depends on the value of `*locale*`) may change between encryption and decryption.
- mode: this argument allows specifying ECB (Electronic Code Book) decryption of CBC (Cipher Block Chaining) decryption. The default is `:ecb`, meaning use ECB. Specify `:cbc` for CBC. The text must be decrypted in the same mode as was used for encryption. If CBC encryption mode is requested, the initialization vector (IV) must be provided by using keyword argument iv. The IV must be an (unsigned-byte 8) array of at least 8 elements. The IV will be modified so that it may be used for subsequent encrypt/decrypt calls.
- iv: ignored unless mode is specified `:cbc`. When mode is `:cbc`, the value, called the initialization vector or IV, must be the same (unsigned-byte 8) array of at least 8 elements as was usedf for encryption. The IV will be modified so that it may be used for subsequent encrypt/decrypt calls.

See also blowfish-encrypt and blowfish-init.

See also the new auxilliary functions hex-string-to-usb8-array and usb8-array-to-hex-string.

See Support for Blowfish encryption in miscellaneous.htm for information on Blowfish encryption and Blowfish encryption support in Allegro CL. There are examples of blowfish encryption and decryption in that section. Support for encryption in the same document discusses encryption support in Allegro CL in general.

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version