Symmetric encryption
Previous  Next

This library offers four symmetric encryption algorithms each of which works on a block of 8 bytes except for Rijndael which works on a 16 byte block. The key sizes for each algorithm are DES - 64 bits = 8bytes, RC2 - 40 to 128 bits in steps of 8 bits = 5 to 16 bytes, TriplesDES - 128 or 192 bits = 16 or 24 bytes, Rijndael - 128, 192 or 256 bits = 16, 24 or 32 bytes. The algorithms can deal with individual blocks of data of their default size, or by chaining blocks can deal with larger amounts of data.

The Cipher Block Chaining (CBC) mode introduces feedback. Before each plain text block is encrypted, it is combined with the cipher text of the previous block by a bitwise exclusive OR operation. This ensures that even if the plain text contains many identical blocks, they will each encrypt to a different cipher text block. The initialization vector is combined with the first plain text block by a bitwise exclusive OR operation before the block is encrypted. If a single bit of the cipher text block is mangled, the corresponding plain text block will also be mangled. In addition, a bit in the subsequent block, in the same position as the original mangled bit, will be mangled. 

The Electronic Codebook (ECB) mode encrypts each block individually. This means that any blocks of plain text that are identical and are in the same message, or in a different message encrypted with the same key, will be transformed into identical cipher text blocks. If the plain text to be encrypted contains substantial repetition, it is feasible for the cipher text to be broken one block at a time. Also, it is possible for an active adversary to substitute and exchange individual blocks without detection. If a single bit of the cipher text block is mangled, the entire corresponding plain text block will also be mangled.
 
Output Feedback (OFB) mode and Cipher Feedback (CFB) mode are also provided.


The DES object in this library offers the following methods and properties

Methods

DecryptBytes(Byte(8) code, Int32 start): Returns an 8 byte array containing the decrypted version of 8 bytes from the code array starting at start.

DecryptString(Byte() CypherText) : Returns a string containing the decrypted version of  the CyoherText array. The decryption will be chained according to the setting of the Mode property.

EncryptBytes(Byte() plain, Int32 start) : Returns an 8 byte array containing the encrypted version of 8 bytes from the plain array starting at start.
 
EncryptString(String PlainText)  : Returns a byte array, which will be a multiple of 8 bytes containing the encrypted version of PlainText. The enryption will be chained according to the setting of the Mode property.
 
GenerateIV() : Generates a new random intialisation vector for use in block chaining.

GenerateKey() : Generates a new random key which will never be a weak or semi-weak key.

IsSemiWeakKey (Byte(8) Key) : Returns true if key is a semi-weak key otherwise returns false.

IsWeakKey (Byte(8) Key) : Returns true if key is a weak key otherwise returns false.

New1 : Creates a new instance of this object.

Properties

I signifies readable, O signifies settable.


BlockSize: Int32 [I/O] : Sets or gets the the size of the data/code block in bits.

DLLversion : Double [I] : Returns the version of this library.

KeySize: Int32 [I/O] : Sets or gets the the size of the encryption/decryption key in bits.

IV : Byte(8) [I/O] : Sets or gets the initialisation vector used in the chaining mode. The default IV appears to be all zeroes.

Key: Byte(8) [I/O] : Sets or gets the encryption/decryption key.

LegalBlockSizes : Int32(3) [I] : Returns an array describing the legal block sizes in bits  for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between block sizes.

LegalKeySizes : Int32(3) [I] : Returns an array describing the legal key sizes in bits for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between key sizes.

Mode : Int32 [I/O] : Sets  or gets the chaining mode. CBC = 1, ECB = 2, OFB = 3, CFB = 4



The TripleDES object in this library offers the following methods and properties

Methods

DecryptBytes(Byte(8) code, Int32 start): Returns an 8 byte array containing the decrypted version of 8 bytes from the code array starting at start.

DecryptString(Byte() CypherText) : Returns a string containing the decrypted version of  the CypherText array. The decryption will be chained according to the setting of the Mode property.

EncryptBytes(Byte() plain, Int32 start) : Returns an 8 byte array containing the encrypted version of 8 bytes from the plain array starting at start.
 
EncryptString(String PlainText)  : Returns a byte array, which will be a multiple of 8 bytes containing the encrypted version of PlainText. The enryption will be chained according to the setting of the Mode property.
 
GenerateKey() : Generates a new random key which will never be a weak or semi-weak key.

GenerateIV() : Generates a new random intialisation vector for use in block chaining.

IsSemiWeakKey (Byte() Key) : Returns true if key is a semi-weak key otherwise returns false.  Key can be either16 or 24 bytes.

IsWeakKey (Byte() Key) : Returns true if key is a weak key otherwise returns false. Key can be either16 or 24 bytes.

New1 : Creates a new instance of this object.

Properties

I signifies readable, O signifies settable.


BlockSize: Int32 [I/O] : Sets or gets the the size of the data/code block in bits.

DLLversion : Double [I] : Returns the version of this library.

KeySize: Int32 [I/O] : Sets or gets the the size of the encryption/decryption key in bits.

IV : Byte(8) [I/O] : Sets or gets the initialisation vector used in the chaining mode. The default IV appears to be all zeroes.

LegalBlockSizes : Int32(3) [I] : Returns an array describing the legal block sizes in bits  for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between block sizes.

LegalKeySizes : Int32(3) [I] : Returns an array describing the legal key sizes in bits for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between key sizes.

Key: Byte() [I/O] : Sets or gets the encryption/decryption key. Key can be either16 or 24 bytes.

Mode : Int32 [I/O] : Sets  or gets the chaining mode. CBC = 1, ECB = 2, OFB = 3, CFB = 4 .



The RC2 object in this library offers the following methods and properties

Methods

DecryptBytes(Byte(8) code, Int32 start): Returns an 8 byte array containing the decrypted version of 8 bytes from the code array starting at start.

DecryptString(Byte() CypherText) : Returns a string containing the decrypted version of  the CypherText array. The decryption will be chained according to the setting of the Mode property.

EncryptBytes(Byte() plain, Int32 start) : Returns an 8 byte array containing the encrypted version of 8 bytes from the plain array starting at start.
 
EncryptString(String PlainText)  : Returns a byte array, which will be a multiple of 8 bytes containing the encrypted version of PlainText. The encryption will be chained according to the setting of the Mode property.
 
GenerateKey() : Generates a new random key.

GenerateIV() : Generates a new random intialisation vector for use in block chaining.

New1 : Creates a new instance of this object.

Properties

I signifies readable, O signifies settable.


BlockSize: Int32 [I/O] : Sets or gets the the size of the data/code block in bits.

DLLversion : Double [I] : Returns the version of this library.

KeySize: Int32 [I/O] : Sets or gets the the size of the encryption/decryption key in bits.

IV : Byte(8) [I/O] : Sets or gets the initialisation vector used in the chaining mode. The default IV appears to be all zeroes.

Key: Byte(8) [I/O] : Sets or gets the encryption/decryption key.

LegalBlockSizes : Int32(3) [I] : Returns an array describing the legal block sizes in bits  for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between block sizes.

LegalKeySizes : Int32(3) [I] : Returns an array describing the legal key sizes in bits for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between key sizes.

Mode : Int32 [I/O] : Sets  or gets the chaining mode. CBC = 1, ECB = 2, OFB = 3, CFB = 4



The Rijndael object in this library offers the following methods and properties

Methods

DecryptBytes(Byte(16) code, Int32 start): Returns an 16 byte array containing the decrypted version of 16 bytes from the code array starting at start.

DecryptString(Byte() CypherText) : Returns a string containing the decrypted version of  the CypherText array. The decryption will be chained according to the setting of the Mode property.

EncryptBytes(Byte() plain, Int32 start) : Returns an 16 byte array containing the encrypted version of 16 bytes from the plain array starting at start.
 
EncryptString(String PlainText)  : Returns a byte array, which will be a multiple of 16 bytes containing the encrypted version of PlainText. The encryption will be chained according to the setting of the Mode property.
 
GenerateKey() : Generates a new random key.

GenerateIV() : Generates a new random intialisation vector for use in block chaining.

New1 : Creates a new instance of this object.

Properties

I signifies readable, O signifies settable.


BlockSize: Int32 [I/O] : Sets or gets the the size of the data/code block in bits.

DLLversion : Double [I] : Returns the version of this library.

KeySize: Int32 [I/O] : Sets or gets the the size of the encryption/decryption key in bits.

IV : Byte(16) [I/O] : Sets or gets the initialisation vector used in the chaining mode. The default IV appears to be all zeroes.

Key : Byte(32) [I/O] : Sets or gets the encryption/decryption key.

LegalBlockSizes : Int32(3) [I] : Returns an array describing the legal block sizes in bits  for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between block sizes.

LegalKeySizes : Int32(3) [I] : Returns an array describing the legal key sizes in bits for this algorithm. Index 0 is maximum size, index 1 is minimum size, index is the step size between key sizes.

Mode : Int32 [I/O] : Sets  or gets the chaining mode. CBC = 1, ECB = 2, OFB = 3, CFB = 4