Ordo  0.3.4
Symmetric Cryptography Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
rc4.h File Reference

Primitive. More...

#include "ordo/primitives/stream_ciphers.h"
Include dependency graph for rc4.h:

Go to the source code of this file.

Functions

ORDO_PUBLIC int rc4_init (struct RC4_STATE *state, const void *key, size_t key_len, const struct RC4_PARAMS *params)
 
ORDO_PUBLIC void rc4_update (struct RC4_STATE *state, void *buffer, size_t len)
 
ORDO_PUBLIC void rc4_final (struct RC4_STATE *state)
 
ORDO_PUBLIC size_t rc4_query (int query, size_t value)
 
ORDO_PUBLIC size_t rc4_bsize (void)
 

Detailed Description

Primitive.

RC4 is a stream cipher, which accepts keys between 40 and 2048 bits (in multiples of 8 bits only). It accepts a parameter consisting of the number of initial keystream bytes to drop immediately after key schedule, effectively implementing RC4-drop[n]. If no drop parameter is passed, the implementation drops 2048 bytes by default.

Be aware that even with a drop, it isn't secure to encrypt more than a few hundred megabytes of data with the same key (due to a distinguisher attack that can distinguish between an RC4 keystream and a random stream). If you are concerned, use a different algorithm or rekey at generous intervals.

Function Documentation

ORDO_PUBLIC int rc4_init ( struct RC4_STATE *  state,
const void *  key,
size_t  key_len,
const struct RC4_PARAMS params 
)
See Also
stream_init()
Return values
ORDO_KEY_LENif the key length was less than 40 bits (5 bytes) or more than 2048 bits (256 bytes).
Remarks
The amount of keystream bytes to drop can be set via the params argument, see RC4_PARAMS. By default, 2048 bytes are dropped.
ORDO_PUBLIC void rc4_update ( struct RC4_STATE *  state,
void *  buffer,
size_t  len 
)
See Also
stream_update()
ORDO_PUBLIC void rc4_final ( struct RC4_STATE *  state)
See Also
stream_final()
ORDO_PUBLIC size_t rc4_query ( int  query,
size_t  value 
)
See Also
stream_query()
ORDO_PUBLIC size_t rc4_bsize ( void  )

Gets the size in bytes of an RC4_STATE.

Returns
The size in bytes of the structure.
Remarks
Binary compatibility layer.