OpenBSD manual page server

Manual Page Search Parameters

RC2_ENCRYPT(3) Library Functions Manual RC2_ENCRYPT(3)

RC2_set_key, RC2_encrypt, RC2_decrypt, RC2_cbc_encrypt, RC2_ecb_encrypt, RC2_cfb64_encrypt, RC2_ofb64_encryptlow-level functions for Rivest Cipher 2

#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);

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 kength 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.

() 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.

() and () 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.

() operates in cipher block chaining mode.

() encodes or decodes eight bytes at in to eight bytes at out in electronic codebook mode.

() and () 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.

crypto(3), EVP_EncryptInit(3), EVP_rc2_cbc(3)

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.

December 7, 2024 OpenBSD-current