sam.cipher
Class Loki

java.lang.Object
  |
  +--sam.cipher.Cipher
        |
        +--sam.cipher.Loki

public class Loki
extends Cipher

Implementation of the Loki97 Retrofitted for personal use by Guillaume Lacôte. LOKI97 is a 128-bit symmetric block cipher with a 256-bit key schedule, which may be initialised from 128, 192, or 256-bit keys. It uses 16 rounds of data computation using a balanced feistel network with a complex function f which incorporates two S-P layers. The 256-bit key schedule uses 33 rounds of an unbalanced feistel network using the same complex function f to generate the subkeys.

LOKI97 was written by Lawrie Brown (ADFA), Josef Pieprzyk, and Jennifer Seberry (UOW) in 1997.

Copyright © 1997, 1998 jointly by Lawrie Brown & ITRACE, and Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: $


Nested Class Summary
static class Loki.Key
          Key implementation that is adapted to the Loki cipher.
 
Nested classes inherited from class sam.cipher.Cipher
Cipher.ByteArrayFilter, Cipher.Error
 
Field Summary
 
Fields inherited from class sam.cipher.Cipher
DECRYPT, EMPTY, ENCRYPT, INVERSE, key, REGISTRY
 
Constructor Summary
Loki(sam.cipher.Key key)
           
 
Method Summary
protected  void decrypt(byte[] data, int offset, sam.cipher.Key key)
          Decrypt exactly one block of ciphertext.
protected  void encrypt(byte[] data, int offset, sam.cipher.Key key)
          Encrypt exactly one block of plaintext.
protected  int getPreferredSize(int size)
          Specifiy preferred buffer size.
 
Methods inherited from class sam.cipher.Cipher
cipher, cipher, fill, main, store, store, storeReversed, streamTest, test, unstoreInt, unstoreLong, unstoreReversedLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Loki

public Loki(sam.cipher.Key key)
Method Detail

getPreferredSize

protected int getPreferredSize(int size)
Description copied from class: Cipher
Specifiy preferred buffer size.

May return a fixed value, ignoring suggested size (e.g. return 16;).

By default, this implementation simply returns its argument unchanged.

Overrides:
getPreferredSize in class Cipher
Parameters:
size - proposed buffer size (in bytes)
Returns:
adjusted buffer size (in bytes)

encrypt

protected void encrypt(byte[] data,
                       int offset,
                       sam.cipher.Key key)
Encrypt exactly one block of plaintext.

Specified by:
encrypt in class Cipher
Parameters:
data - The plaintext.
key - The session key to use for encryption.

decrypt

protected void decrypt(byte[] data,
                       int offset,
                       sam.cipher.Key key)
Decrypt exactly one block of ciphertext.

Specified by:
decrypt in class Cipher
Parameters:
data - The plaintext.
key - The session key to use for decryption.