|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--is.logi.crypto.Crypto | +--is.logi.crypto.keys.K | +--is.logi.crypto.keys.ElGamalKey
This object holds one ElGamal key.
CDS for an ElGamal key is ElGamalKey(x,g,m,pub)
for a public key or elGamalKey(x,g,m,pri)
for a private
key. In both cases x
,g
and m
are
hexadecimal numbers.
Fields inherited from class is.logi.crypto.Crypto |
BIT,
cdsPath,
keySource,
NIBBLE,
primeCertainty,
random |
Constructor Summary | |
ElGamalKey(java.math.BigInteger x,
java.math.BigInteger g,
java.math.BigInteger m,
boolean pri)
Create a new ElGamal key object. |
|
ElGamalKey(int n)
Create a random private ElGamalKey with an n
bit modulus. |
Method Summary | |
int |
cipherBlockSize()
Returns the size of the blocks that can be decrypted in one call to decrypt(). |
static KeyPair |
createKeys(int n)
Create a pair of public/private keys in a group with an n bit modulo. |
void |
decrypt(byte[] source,
int i,
byte[] dest,
int j)
Decrypt one block of data. |
void |
encrypt(byte[] source,
int i,
byte[] dest,
int j)
Encrypt one block of data. |
boolean |
equals(java.lang.Object o)
Return true iff the two keys are equivalent. |
java.lang.String |
getAlgorithm()
The name of the algorithm is "ElGamal". |
java.math.BigInteger |
getG()
Return the generator for this key. |
java.math.BigInteger |
getKey()
Return the BigInteger representing this key. |
java.math.BigInteger |
getM()
Return the modulus for this key. |
ElGamalKey |
getPublic()
Return the public key from the pair. |
int |
getSize()
Return the "size" of the key. |
boolean |
isPrivate()
Returns true iff this is a private key. |
boolean |
matches(Key key)
Check if a key mathces this. |
static ElGamalKey |
parseCDS(java.lang.String key)
If "ElGamalKey( key )" is a valid CDS for a ElGamalKey, then ElGamalKey.parseCDS(key) will return the described ElGamalKey object. |
int |
plainBlockSize()
Returns the size of the blocks that can be encrypted in one call to encrypt(). |
Signature |
sign(Fingerprint fp)
Create a signature for a Fingerprint fith a private key. |
int |
signatureSize()
Returns the length of a signature in bytes. |
int |
signBlockSize()
Returns the maximum size in bytes of the fingerprints that can be signed. |
java.lang.String |
toString()
Return a CDS for this key. |
boolean |
verify(Signature s,
Fingerprint fp)
Verify a Signature on a Fingerprint with a public key. |
Methods inherited from class is.logi.crypto.keys.K |
getFingerprint,
hashCode,
matchFingerprint |
Methods inherited from class is.logi.crypto.Crypto |
binString,
binString,
equal,
equalRelaxed,
equalSub,
fromHexNibble,
fromHexString,
fromString,
fromString,
hexString,
hexString,
hexString,
hexString,
makeClass,
makeInt,
makeLong,
makeSessionKey,
pastSpace,
pickBits,
pickBits,
readInt,
writeBytes,
writeBytes,
writeInt |
Methods inherited from class java.lang.Object |
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ElGamalKey(java.math.BigInteger x, java.math.BigInteger g, java.math.BigInteger m, boolean pri)
x
in the group modulo m
with generator g
. It is
a private key iff pri is true
.
public ElGamalKey(int n)
n
bit modulus.
Pre-calcualted modula exist for bit lengths 256, 512, 1024 and 2048. Using these values saves a lot of time and does not weaken the keys.
Method Detail |
public static ElGamalKey parseCDS(java.lang.String key) throws InvalidCDSException
A valid CDS can be created by calling the ElGamalKey.toString() method.
Crypto.fromString(String)
public static KeyPair createKeys(int n)
n
bit modulo.
Pre-calcualted modula exist for bit lengths 256, 512, 1024 and 2048. Using these values saves a lot of time and does not weaken the keys.
public int getSize()
public java.lang.String getAlgorithm()
public boolean isPrivate()
public ElGamalKey getPublic()
public java.math.BigInteger getKey()
public java.math.BigInteger getM()
public java.math.BigInteger getG()
public final boolean equals(java.lang.Object o)
public boolean matches(Key key)
public java.lang.String toString()
public int plainBlockSize()
public int cipherBlockSize()
public void encrypt(byte[] source, int i, byte[] dest, int j)
source
starting at offset i
and
ciphertext is written to dest
, starting at
offset j
.
The amount of data read and written will match the values returned
by plainBlockSize()
and cipherBlockSize()
.
public void decrypt(byte[] source, int i, byte[] dest, int j)
source
starting at offset i
and
plaintext is written to dest
, starting at
offset j
.
The amount of data read and written will match the values returned
by cipherBlockSize()
and plainBlockSize()
.
public int signBlockSize()
public int signatureSize()
public Signature sign(Fingerprint fp) throws KeyException
public boolean verify(Signature s, Fingerprint fp) throws KeyException
The method returns true iff s
is a signature for
fp
created with the mathcin private key.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |