RC2 Struct Reference

#include <rc2.h>

Inheritance diagram for RC2:

Inheritance graph
Collaboration diagram for RC2:

Collaboration graph

Detailed Description

Implementation of the RC2 symmetric block cipher.

RC2 is an 8-byte block cipher with a variable length key. It became popular in the late 90's principally due to its adaptability to past government export regulations: one can easily limit the effective keysize to 40 bits. Today it is primarily used to decode old PKCS#12 files and for other legacy purposes.

Usage flow:
  RC2()     // instantiate a new RC2 object
  init()    // specify direction, key, mode, and effective keysize
  crypt()   // perform the encrypt or decrypt operation

Bugs:
  the code does not properly handle 1-byte keys

Recommendations for strict FIPS 140-1 compliance:
  RC2 is not a FIPS approved algorithm, so the RC2 class should
  *NOT* be used.

Sample code illustrating the use of this class appears in the Cookbook section Using the Symmetric Ciphers.

References

RC2 is specified in RFC 2268, and in RFC 3217.


Public Types

 ENCRYPT
 crypt() call performs encryption
 DECRYPT
 crypt() call performs decryption
enum  dirs {
  ENCRYPT,
  DECRYPT
}
 Direction flags. More...

Public Member Functions

 RC2 ()
 Constructor used to create an empty RC2 object.
 ~RC2 ()
 Destructor. Calls clear().
int init (enum dirs dir, int length, const char *key, const char *iv=0, int ekb=1024)
 Initialize the RC2 object.
int crypt (int n, const char *in, char *out)
 Encrypt or decrypt a specified buffer.
void clear ()
 Clear this object.


Member Enumeration Documentation

enum dirs

Direction flags.

Enumerator:
ENCRYPT  crypt() call performs encryption
DECRYPT  crypt() call performs decryption


Member Function Documentation

void clear (  ) 

Clear this object.

Remarks:
All key components are zeroized.

int crypt ( int  n,
const char *  in,
char *  out 
)

Encrypt or decrypt a specified buffer.

Parameters:
n the number of bytes in the input and output buffers
in a pointer to the input buffer
out a pointer to the output buffer
Returns:
0 (success)
CDK_ERROR_STATE
CDK_INVALID_PTR

int init ( enum dirs  dir,
int  length,
const char *  key,
const char *  iv = 0,
int  ekb = 1024 
)

Initialize the RC2 object.

Parameters:
dir a direction indicator: ENCRYPT or DECRYPT
length the length of key in bytes; usually 40 or 128
key a pointer to a buffer containing the key
iv either 0 (for ECB mode) or an 8-byte initialization vector (for CBC mode)
ekb the number of effective key bits
Returns:
0 (success)
CDK_ERROR_STATE
CDK_INVALID_PTR
Remarks:
If the expanded RC2 key has an effective key length greater than ekb, then it is reduced to an effective length of ekb bits).


The documentation for this struct was generated from the following file:
ISC Cryptographic Development Kit - User's Guide
ISC website
Questions? E-mail ISC technical support
Copyright© 2002-2006 Information Security Corp. All rights reserved.