|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.crypto.AESEngine
net.i2p.crypto.CryptixAESEngine
public class CryptixAESEngine
Wrapper for AES cypher operation using Cryptix's Rijndael implementation. Implements CBC with a 16 byte IV. Problems: Only supports data of size mod 16 bytes - no inherent padding.
Field Summary |
---|
Fields inherited from class net.i2p.crypto.AESEngine |
---|
_context, _log |
Constructor Summary | |
---|---|
CryptixAESEngine(I2PAppContext context)
see comments for main() below private static final boolean USE_SYSTEM_AES; static { boolean systemOK = false; try { systemOK = Cipher.getMaxAllowedKeyLength("AES") >= 256; } catch (GeneralSecurityException gse) { // a NoSuchAlgorithmException } catch (NoSuchMethodError nsme) { // JamVM, gij try { Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); SecretKeySpec key = new SecretKeySpec(new byte[32], "AES"); cipher.init(Cipher.ENCRYPT_MODE, key); systemOK = true; } catch (GeneralSecurityException gse) { } } USE_SYSTEM_AES = systemOK; //System.out.println("Using system AES? " + systemOK); } |
Method Summary | |
---|---|
void |
decrypt(byte[] payload,
int payloadIndex,
byte[] out,
int outIndex,
SessionKey sessionKey,
byte[] iv,
int length)
Decrypt the data with the session key |
void |
decrypt(byte[] payload,
int payloadIndex,
byte[] out,
int outIndex,
SessionKey sessionKey,
byte[] iv,
int ivOffset,
int length)
Decrypt the data with the session key. |
void |
decryptBlock(byte[] payload,
int inIndex,
SessionKey sessionKey,
byte[] rv,
int outIndex)
decrypt exactly 16 bytes of data with the session key provided |
void |
encrypt(byte[] payload,
int payloadIndex,
byte[] out,
int outIndex,
SessionKey sessionKey,
byte[] iv,
int length)
Encrypt the payload with the session key |
void |
encrypt(byte[] payload,
int payloadIndex,
byte[] out,
int outIndex,
SessionKey sessionKey,
byte[] iv,
int ivOffset,
int length)
Encrypt the payload with the session key. |
void |
encryptBlock(byte[] payload,
int inIndex,
SessionKey sessionKey,
byte[] out,
int outIndex)
encrypt exactly 16 bytes using the session key |
Methods inherited from class net.i2p.crypto.AESEngine |
---|
safeDecrypt, safeEncrypt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CryptixAESEngine(I2PAppContext context)
Method Detail |
---|
public void encrypt(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int length)
AESEngine
encrypt
in class AESEngine
iv
- must be 16 byteslength
- must be a multiple of 16payload
- data to be encryptedpayloadIndex
- index into the payload to start encryptingout
- where to store the resultoutIndex
- where in out to start writingsessionKey
- private esession key to encrypt topublic void encrypt(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int ivOffset, int length)
AESEngine
encrypt
in class AESEngine
iv
- must be 16 byteslength
- must be a multiple of 16payload
- data to be encryptedpayloadIndex
- index into the payload to start encryptingout
- where to store the resultoutIndex
- where in out to start writingsessionKey
- private esession key to encrypt topublic void decrypt(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int length)
AESEngine
decrypt
in class AESEngine
payload
- data to be decryptedpayloadIndex
- index into the payload to start decryptingout
- where to store the cleartextoutIndex
- where in out to start writingsessionKey
- private session key to decrypt toiv
- IV for CBClength
- how much data to decryptpublic void decrypt(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int ivOffset, int length)
AESEngine
decrypt
in class AESEngine
payload
- data to be decryptedpayloadIndex
- index into the payload to start decryptingout
- where to store the cleartextoutIndex
- where in out to start writingsessionKey
- private session key to decrypt toiv
- IV for CBClength
- how much data to decryptpublic final void encryptBlock(byte[] payload, int inIndex, SessionKey sessionKey, byte[] out, int outIndex)
encryptBlock
in class AESEngine
payload
- plaintext data, 16 bytes starting at inIndexsessionKey
- private session keyout
- out parameter, 16 bytes starting at outIndexpublic final void decryptBlock(byte[] payload, int inIndex, SessionKey sessionKey, byte[] rv, int outIndex)
decryptBlock
in class AESEngine
payload
- encrypted data, 16 bytes starting at inIndexsessionKey
- private session keyrv
- out parameter, 16 bytes starting at outIndex
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |