|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sam.cipher.Factory
General-purpose Cipher
factory.
This is an abstraction for instantiating various ciphering algorithm and parsing keys.
Field Summary | |
java.lang.String |
description
A human-readable description of this cipher. |
java.lang.String |
name
The code name of this cipher |
Constructor Summary | |
protected |
Factory(java.lang.String name,
java.lang.String description)
Builds a new Cipher factory |
Method Summary | |
protected int |
getPreferredKeySize(int suggestedKeySize)
Specifies preferred key size, in bits. |
protected static int |
highestIn(int suggested,
int[] authorized)
Gets the highest integer less than or equal to suggested from exhaustive list of
valid values,
or minimum of those if such a number does not exist. |
protected static int |
highestMultiple(int number,
int root)
Gets the highest integer less than or equal to number that is a multiple
of root ,
and that is higher than root . |
protected abstract sam.cipher.Cipher |
make(long[] key,
boolean mode)
Instantiates a new Cipher implementation. |
protected static int |
ranged(int suggested,
int min,
int max)
Ensures a size fits in specified range. |
protected static boolean[] |
resizeKey(boolean[] key,
int keySize)
Resizes key to specified length. |
protected boolean[] |
resizeKeyToPreferredSize(boolean[] key)
Resizes key to its desired length. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final java.lang.String name
public final java.lang.String description
Constructor Detail |
protected Factory(java.lang.String name, java.lang.String description)
Cipher
factory
name
- the code name of this cipherdescription
- a human-readable description of this cipher.Method Detail |
protected abstract sam.cipher.Cipher make(long[] key, boolean mode) throws java.lang.Error
Cipher
implementation.
key
- the key as full long
s, its length having been retrofitted by the
getPreferredKeySize
method.mode
- true
if encrypting, false
otherwise (decrypting).
java.lang.Error
- in case of impossible instantiationCipher.ENCRYPT
,
Cipher.DECRYPT
protected int getPreferredKeySize(int suggestedKeySize)
suggestedKeySize
- the suggested key size as computed from the password length
Key
,
highestMultiple(int, int)
protected static int highestMultiple(int number, int root)
number
that is a multiple
of root
,
and that is higher than root
. Simply root
if no such integer.
protected static int highestIn(int suggested, int[] authorized) throws java.lang.Error
suggested
from exhaustive list of
valid values,
or minimum of those if such a number does not exist.
java.lang.Error
protected static int ranged(int suggested, int min, int max) throws java.lang.Error
suggested
if it fits in specified interval, or bound otherwise.
java.lang.Error
- if max
is less than min
.protected boolean[] resizeKeyToPreferredSize(boolean[] key) throws java.lang.Error
key
to its desired length.
java.lang.Error
getPreferredKeySize(int)
protected static boolean[] resizeKey(boolean[] key, int keySize) throws java.lang.Error
key
to specified length.
If the current size is larger, the key is truncated.
If it is smaller, the key is concatenated to itself until it is large enough.
keySize
- the desired new key size
java.lang.Error
- if this key is empty and expected size is not
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |