---
name: "libressl-EVP_rc2_cbc"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-EVP_rc2_cbc"
---

# libressl-EVP\_rc2\_cbc(3)

Rivest Cipher 2 in the EVP framework

## NAME

**EVP\_rc2\_cbc**, **EVP\_rc2\_ecb**, **EVP\_rc2\_cfb64**, **EVP\_rc2\_cfb**, **EVP\_rc2\_ofb**, **EVP\_rc2\_40\_cbc**, **EVP\_rc2\_64\_cbc** – Rivest Cipher 2 in the EVP framework

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/evp.h\>**

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_cbc**(*void*);

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_ecb**(*void*);

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_cfb64**(*void*);

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_cfb**(*void*);

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_ofb**(*void*);

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_40\_cbc**(*void*);

*const* *EVP\_CIPHER* *\**\

**EVP\_rc2\_64\_cbc**(*void*);

**#include \<openssl/rc2.h\>**

**#define RC2\_BLOCK 8**

**#define RC2\_KEY\_LENGTH 16**

## DESCRIPTION

RC2 is a block cipher operating on blocks of RC2\_BLOCK = 8 bytes, equivalent to 64 bits, using a variable *key* length with an additional parameter called “effective key bits” or “effective key length”.

**EVP\_rc2\_cbc**(), **EVP\_rc2\_ecb**(), **EVP\_rc2\_cfb64**(), and **EVP\_rc2\_ofb**() provide the RC2 encryption algorithm in CBC, ECB, CFB and OFB mode, respectively. **EVP\_rc2\_cfb**() is an alias for **EVP\_rc2\_cfb64**(), implemented as a macro.

By default, these functions set both the key length and the effective key length to RC2\_KEY\_LENGTH = 16 bytes, which is not a very useful value because it is quite short.

Configuring normally requires a multi-step process:

1. Create a new, empty *EVP\_CIPHER\_CTX* object with EVP\_CIPHER\_CTX\_new(3).

2. Select the operation mode by calling EVP\_EncryptInit(3) with the desired *type* argument, passing NULL pointers for the *key* and *iv* arguments.

3. Select the *key* length by passing the desired number of bytes to EVP\_CIPHER\_CTX\_set\_key\_length(3). Doing so overrides the default key length of RC2\_KEY\_LENGTH = 16. Valid values for *keylen* are positive and less than or equal to 128.

4. Select the effective key length by calling EVP\_CIPHER\_CTX\_ctrl(3) with a *type* argument of EVP\_CTRL\_SET\_RC2\_KEY\_BITS, passing the desired number of bits in *arg*. Doing so overrides the default effective key length of 128 bits. Valid values for *arg* are positive and less than or equal to 1024. The *ptr* argument is ignored; passing NULL is recommended.

5. Call EVP\_EncryptInit(3) a second time, this time passing NULL for the type argument. The *key* argument points to an array containing the number of bytes that was passed to EVP\_CIPHER\_CTX\_set\_key\_length(3), and the *iv* argument points to an array of eight bytes.

6. Finally, EVP\_EncryptUpdate(3) and EVP\_EncryptFinal(3) can be used in the normal way.

Once a *ctx* object is fully configured, calling EVP\_CIPHER\_CTX\_ctrl(3) with a *type* argument of EVP\_CTRL\_GET\_RC2\_KEY\_BITS interprets *ptr* as a pointer to *int* and stores the effective key length in bits at that location. In this case, *arg* is ignored and passing 0 is recommended.

In the CFB and OFB modes, the minimum required total length in bytes of the output buffer is equal to the total number of input bytes to be encoded. In the CBC and ECB modes, the minimum required total length of the output buffer has to be rounded up to the next multiple of the block size of eight bytes.

**EVP\_rc2\_40\_cbc**() and **EVP\_rc2\_64\_cbc**() are obsolete functions that provide the RC2 algorithm in CBC mode with a key length and an effective key length of 40 and 64 bits, respectively.

## RETURN VALUES

With the *EVP\_CIPHER* objects documented in the present manual page, **EVP\_CIPHER\_CTX\_ctrl**() returns 1 for success or 0 if an error occurs.

## SEE ALSO

evp(3), EVP\_CIPHER\_CTX\_set\_key\_length(3), EVP\_EncryptInit(3), RC2\_encrypt(3)

## HISTORY

**EVP\_rc2\_cbc**(), **EVP\_rc2\_ecb**(), **EVP\_rc2\_cfb**(), and **EVP\_rc2\_ofb**() first appeared in SSLeay 0.5.2 and have been available since OpenBSD 2.4.

**EVP\_rc2\_40\_cbc**() and **EVP\_rc2\_64\_cbc**() first appeared in SSLeay 0.9.1 and have been available since OpenBSD 2.6.

**EVP\_rc2\_cfb64**() first appeared in OpenSSL 0.9.7e and has been available since OpenBSD 3.8.
