API Reference

Common Defintions

  

Symmetric_Key

This object class represents a block cipher, or more precisely, a block cipher with the key fixed to a particular value.

Two methods are provided, Encrypt and Decrypt, which encrypt and decrypt data using the key (whose value is contained within the object)

The size of the blocks of data to be encrpted or decrypted is fixed at 128 bits (16 octets), as this is only block size supported by the Advanced Encryption Standard.

procedure Encrypt , procedure Decrypt

   procedure Encrypt (Key    : Symmetric_Key;   
                      Input  : in Cipher_Block;  
                      Output : out Cipher_Block) is abstract;  
  
   procedure Decrypt (Key    : Symmetric_Key;  
                      Input  : in Cipher_Block;  
                      Output : out Cipher_Block) is abstract;  
  

Symmetric_Key_128

This object class extends Symmetric_Key by adding the method New_Key, which permits the value of the encryption key to be changed. The '128' in the name of the class refers to the size of the encryption key: all members of this class have 128-bit keys (16 octets).

Support for other key sizes is provided by defining other extensions of the base class. These also have a method called New_Key, but it takes a different size key as parameter.

As Ada supports variable-length array parameters, you may wonder why things are done this way, rather than with a single class whose New_Key method takes a variable-length key. The reason is that for some block ciphers the implementation of the Encrypt and Decrypt methods change significantly when the key size changes. This approach allows the Encrypt and Decrypt methods to be overridden with an implementation that is optimized for a particular key length.

In addition, some protocols require the cryptographic algorithm to to have a particular block size - for example, some require the key size to equal the block size so that a key can be encrypted in one block. An implementation of such a protocol can refer to this class rather than the base class Symmetric_Key to indicate the fact that it will only work with algorithms of one particular key size.

procedure New_Key

     procedure New_Key (Key_Schedule : out Symmetric_Key_128;   
                        Key_Bits : in Key_Block) is abstract;  
  

Symmetric_Key_192

This object class is used for block ciphers with 192-bit keys. Apart from the key length, it is similar to Symmetric_Key_128.

The key sizes of 128, 192 and 256 bits have been selected because the Advanced Encryption Standard requires support for these three sizes.

procedure New_Key

   procedure New_Key (Key_Schedule : out Symmetric_Key_192;   
                      Key_Bits : in Key_Block) is abstract;  
  

Symmetric_Key_256

This object class is used for block ciphers with 256-bit keys. Apart from the key length, it is similar to Symmetric_Key_128.

The key sizes of 128, 192 and 256 bits have been selected because the Advanced Encryption Standard requires support for these three sizes.

procedure New_Key

   procedure New_Key (Key_Schedule : out Symmetric_Key_256;   
                      Key_Bits : in Key_Block) is abstract;  
  

Symmetric_Key_Variable_Length

This object class is used for block ciphers with variable length keys; That is, block ciphers where exactly the same encrypt and decrypt procedure can be used with different key lengths

procedure New_Key

   procedure New_Key (Key_Schedule : out Symmetric_Key_Variable_Length;   
                      Key_Bits : in Key_Block_Variable_Length) is abstract;  
  

function To_String (K : Cipher_Block) return String; function To_String (K : Key_Block) return String; function To_String (K : Key_Block_Variable_Length) return String;

function To_Key (S : String) return Key_Block; function To_Key (S : String) return Key_Block_192; function To_Key (S : String) return Key_Block_256; function To_Key (S : String) return Key_Block_Variable_Length;