|
MjSip Stack v1.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.zoolu.tools.MD5OTP
OTP (One Time Pad) encryption algorithm based on MD5 hash function.
It uses a PRG (Pseudo-Random-Generator) function in OFB (Output Feadback)
to genarate a byte-stream (the OTP) that is XORed with the plaintext.
The PRG is based on MD5.
The OTP is calculated starting from a key and an IV, as follows:
h_0=hash(skey|iv)
h_i=hash(skey|h_i-1)
where:
hash(.)==MD5(.)
skey==key
while the ciphertext is calculated as follows:
c_0=iv
c_i=m_i XOR h_i with i=1,2,..
Note that optionally it could modified initializing the skey as follows:
skey==hash(key|iv)
in order to not keep in memory the secret key for long time
| Constructor Summary | |
MD5OTP(byte[] skey)
Creates a new MD5OTP with IV=0 |
|
MD5OTP(byte[] skey,
byte[] iv)
Creates a new MD5OTP |
|
| Method Summary | |
static byte[] |
decrypt(byte[] c,
byte[] key)
Decrypts an array of bytes with the IV at top. |
static byte[] |
encrypt(byte[] m,
byte[] key)
Encrypts an array of bytes. |
static void |
main(java.lang.String[] args)
|
byte[] |
update(byte[] m)
Encrypts a block of bytes |
void |
update(java.io.InputStream in,
java.io.OutputStream out)
Encrypts a byte stream |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MD5OTP(byte[] skey,
byte[] iv)
public MD5OTP(byte[] skey)
| Method Detail |
public byte[] update(byte[] m)
public void update(java.io.InputStream in,
java.io.OutputStream out)
public static byte[] encrypt(byte[] m,
byte[] key)
public static byte[] decrypt(byte[] c,
byte[] key)
public static void main(java.lang.String[] args)
|
MjSip Stack v1.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||