CryptoSys API  6.22.1
Public Types | Static Public Member Functions | List of all members
crsysapi::CipherStream Class Reference

Stream cipher functions. More...

Public Types

enum class  Alg
 Stream cipher algorithm. More...
 

Static Public Member Functions

static crsysapi::bvec_t Bytes (const bvec_t &data, const bvec_t &key, const bvec_t &iv, Alg alg, int counter=0)
 Enciphers data in array of bytes using specified stream cipher. More...
 
static int File (const std::string &fileOut, const std::string &fileIn, const bvec_t &key, const bvec_t &iv, Alg alg, int counter=0)
 Enciphers data in a file using specified stream cipher. More...
 

Detailed Description

Stream cipher functions.

Member Enumeration Documentation

◆ Alg

Stream cipher algorithm.

Enumerator
Arcfour 

ARCFOUR (RC4) algorithm

Salsa20 

Salsa20 algorithm

Chacha20 

Chacha20 algorithm

Member Function Documentation

◆ Bytes()

static crsysapi::bvec_t crsysapi::CipherStream::Bytes ( const bvec_t data,
const bvec_t key,
const bvec_t iv,
Alg  alg,
int  counter = 0 
)
static

Enciphers data in array of bytes using specified stream cipher.

Parameters
dataInput data to be encrypted
keyKey (length restrictions apply, see Remarks)
ivInitialization Vector (IV, nonce) or an empty vector bvec_t() for Arcfour
algStream cipher algorithm
counterCounter value for ChaCha20 only, otherwise ignored.
Returns
Ciphertext in byte array, or empty array on error.
Exceptions
std::runtime_errorException with error code.
Remarks
Arcfour: any length key; use an empty array for IV.
Salsa20: key must be exactly 16 or 32 bytes and IV exactly 8 bytes long.
ChaCha20: key must be exactly 16 or 32 bytes and IV exactly 8, 12, or 16 bytes long. Counter is ignored if IV is 16 bytes.

◆ File()

static int crsysapi::CipherStream::File ( const std::string &  fileOut,
const std::string &  fileIn,
const bvec_t key,
const bvec_t iv,
Alg  alg,
int  counter = 0 
)
static

Enciphers data in a file using specified stream cipher.

Parameters
fileOutName of output file to be created or overwritten
fileInName of input file
keyKey (length restrictions apply, see Remarks)
ivInitialization Vector (IV, nonce) or an empty vector bvec_t() for Arcfour
algStream cipher algorithm
counterCounter value for ChaCha20 only, otherwise ignored.
Returns
0 if successful or nonzero error code.
Exceptions
std::runtime_errorException with error code.
Remarks
fileOut and fileIn must not be the same.
Arcfour: any length key; use an empty array for IV.
Salsa20: key must be exactly 16 or 32 bytes and IV exactly 8 bytes long.
ChaCha20: key must be exactly 16 or 32 bytes and IV exactly 8, 12, or 16 bytes long. Counter is ignored if IV is 16 bytes.
Copyright © 2001-24 D.I. Management Services Pty Limited ABN 78 083 210 584 Australia. All rights reserved. <www.di-mgt.com.au> <www.cryptosys.net>. Generated on Sat Jan 6 2024 18:00:07 by Doxygen 1.9.1.