---
name: "libressl-RC2_encrypt"
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-RC2_encrypt"
---

# libressl-RC2\_encrypt(3)

low-level functions for Rivest Cipher 2

## NAME

**RC2\_set\_key**, **RC2\_encrypt**, **RC2\_decrypt**, **RC2\_cbc\_encrypt**, **RC2\_ecb\_encrypt**, **RC2\_cfb64\_encrypt**, **RC2\_ofb64\_encrypt** – low-level functions for Rivest Cipher 2

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*void*\

**RC2\_set\_key**(*RC2\_KEY \*expanded\_key*, *int len*, *const unsigned char \*user\_key*, *int effective\_bits*);

*void*\

**RC2\_encrypt**(*unsigned long \*data*, *RC2\_KEY \*expanded\_key*);

*void*\

**RC2\_decrypt**(*unsigned long \*data*, *RC2\_KEY \*expanded\_key*);

*void*\

**RC2\_cbc\_encrypt**(*const unsigned char \*in*, *unsigned char \*out*, *long length*, *RC2\_KEY \*expanded\_key*, *unsigned char \*iv*, *int encrypt*);

*void*\

**RC2\_ecb\_encrypt**(*const unsigned char \*in*, *unsigned char \*out*, *RC2\_KEY \*expanded\_key*, *int encrypt*);

*void*\

**RC2\_cfb64\_encrypt**(*const unsigned char \*in*, *unsigned char \*out*, *long length*, *RC2\_KEY \*expanded\_key*, *unsigned char \*iv*, *int \*num*, *int encrypt*);

*void*\

**RC2\_ofb64\_encrypt**(*const unsigned char \*in*, *unsigned char \*out*, *long length*, *RC2\_KEY \*expanded\_key*, *unsigned char \*iv*, *int \*num*);

## 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”. The maximum effective key length is 1024 bits.

If using RC2 cannot be avoided, it is recommended that application programs use the EVP\_rc2\_cbc(3) family of functions instead of the functions documented in the present manual page, to ease later migration to less outdated encryption algorithms.

**RC2\_set\_key**() expands the first *len* bytes of *user\_key* into the *RC2\_KEY* structure \**expanded\_key*. The storage for the expanded key has to be provided by the calling code. If the *len* argument exceeds 128, only the first 128 bytes are used.

Optionally, if the *effective\_bits* argument is positive and less than 1024, the effective key length of \**expanded\_key* is reduced to *effective\_bits*. Reducing the effective key length is not cryptographically useful. This option was originally designed to conform to US export regulations valid at the time, which were designed to allow the US government to spy on foreign encrypted communications. Unless interoperability requires otherwise, setting *effective\_bits* to 1024 is recommended.

**RC2\_encrypt**() and **RC2\_decrypt**() interpret *data* as an array of two 32 bit integers and encrypt or decrypt that single block in place, respectively, using the *expanded\_key*.

The remaining functions encode or decode *length* bytes starting at *in* to *length* bytes starting at *out* in various modes of operation using the *expanded\_key*. Both arrays need to be long enough to hold *length* bytes rounded up to the next multiple of 8. The *iv* argument points to an array of 8 bytes used as the initialization vector. If the *encrypt* argument is RC2\_ENCRYPT or another non-zero value, encryption is performed; if it is RC2\_DECRYPT = 0, decryption is performed.

**RC2\_cbc\_encrypt**() operates in cipher block chaining mode.

**RC2\_ecb\_encrypt**() encodes or decodes eight bytes at *in* to eight bytes at *out* in electronic codebook mode.

**RC2\_cfb64\_encrypt**() and **RC2\_ofb64\_encrypt**() operate in cipher feedback mode and output feedback mode, respectively, with 64 bit blocks. The number of bytes used from the last 8 byte block is kept track of in \**num*.

## SEE ALSO

[crypto(3)](/crypto/3.md), EVP\_EncryptInit(3), EVP\_rc2\_cbc(3)

## HISTORY

**RC2\_set\_key**(), **RC2\_encrypt**(), **RC2\_cbc\_encrypt**(), **RC2\_ecb\_encrypt**(), **RC2\_cfb64\_encrypt**(), and **RC2\_ofb64\_encrypt**() first appeared in SSLeay 0.5.2. **RC2\_decrypt**() first appeared in SSLeay 0.9.0. All these functions have been available since OpenBSD 2.4.
