Changeset 2deee2b1
- Timestamp:
- Dec 15, 2010 4:10:03 PM (10 years ago)
- Branches:
- master
- Children:
- 4c9558c
- Parents:
- 8e709ee
- Location:
- core/java/src/net/i2p/crypto
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/crypto/AESEngine.java
r8e709ee r2deee2b1 23 23 */ 24 24 public class AESEngine { 25 private Log _log; 26 private I2PAppContext _context; 25 protected final Log _log; 26 protected final I2PAppContext _context; 27 27 28 public AESEngine(I2PAppContext ctx) { 28 29 _context = ctx; 29 _log = _context.logManager().getLog( AESEngine.class);30 if (getClass() == AESEngine.class)31 _log. warn("Warning:AES is disabled");30 _log = _context.logManager().getLog(getClass()); 31 if (getClass().equals(AESEngine.class)) 32 _log.logAlways(Log.WARN, "AES is disabled"); 32 33 } 33 34 … … 45 46 } 46 47 47 /** Encrypt the payload with the session key 48 /** 49 * Encrypt the payload with the session key. 50 * This just copies payload to out, see extension for the real thing. 51 * 48 52 * @param payload data to be encrypted 49 53 * @param payloadIndex index into the payload to start encrypting … … 56 60 public void encrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int ivOffset, int length) { 57 61 System.arraycopy(payload, payloadIndex, out, outIndex, length); 58 _log. warn("Warning:AES is disabled");62 _log.logAlways(Log.WARN, "AES is disabled"); 59 63 } 60 64 … … 119 123 } 120 124 121 122 125 /** Decrypt the data with the session key 123 126 * @param payload data to be decrypted … … 133 136 } 134 137 135 /** Decrypt the data with the session key 138 /** 139 * Decrypt the data with the session key. 140 * This just copies payload to out, see extension for the real thing. 141 * 136 142 * @param payload data to be decrypted 137 143 * @param payloadIndex index into the payload to start decrypting … … 144 150 public void decrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int ivOffset, int length) { 145 151 System.arraycopy(payload, payloadIndex, out, outIndex, length); 146 _log. warn("Warning:AES is disabled");152 _log.logAlways(Log.WARN, "AES is disabled"); 147 153 } 148 154 149 155 /** 150 * Just copies payload to out156 * This just copies payload to out, see extension for the real thing. 151 157 * @param sessionKey unused 152 158 */ … … 155 161 } 156 162 157 /** decrypt the data with the session key provided 163 /** 164 * This just copies payload to rv, see extension for the real thing. 165 * 158 166 * @param payload encrypted data 159 167 * @param sessionKey private session key -
core/java/src/net/i2p/crypto/CryptixAESEngine.java
r8e709ee r2deee2b1 28 28 */ 29 29 public class CryptixAESEngine extends AESEngine { 30 private Log _log;31 30 private final static CryptixRijndael_Algorithm _algo = new CryptixRijndael_Algorithm(); 32 31 private final static boolean USE_FAKE_CRYPTO = false; 33 private final static byte FAKE_KEY = 0x2A;34 private CryptixAESKeyCache _cache;32 // keys are now cached in the SessionKey objects 33 //private CryptixAESKeyCache _cache; 35 34 36 35 private static final ByteCache _prevCache = ByteCache.getInstance(16, 16); … … 38 37 public CryptixAESEngine(I2PAppContext context) { 39 38 super(context); 40 _log = context.logManager().getLog(CryptixAESEngine.class); 41 _cache = new CryptixAESKeyCache(); 39 //_cache = new CryptixAESKeyCache(); 42 40 } 43 41 -
core/java/src/net/i2p/crypto/CryptixAESKeyCache.java
r8e709ee r2deee2b1 9 9 * of code) 10 10 * 11 * Unused as a class, as the keys are cached in the SessionKey objects, 12 * but the static methods are used in FortunaStandalone. 11 13 */ 12 14 public final class CryptixAESKeyCache { … … 21 23 private static final int MAX_KEYS = 64; 22 24 25 /* 26 * @deprecated unused, keys are now cached in the SessionKey objects 27 */ 23 28 public CryptixAESKeyCache() { 24 29 _availableKeys = new LinkedBlockingQueue(MAX_KEYS); … … 28 33 * Get the next available structure, either from the cache or a brand new one 29 34 * 35 * @deprecated unused, keys are now cached in the SessionKey objects 30 36 */ 31 37 public final KeyCacheEntry acquireKey() { … … 39 45 * Put this structure back onto the available cache for reuse 40 46 * 47 * @deprecated unused, keys are now cached in the SessionKey objects 41 48 */ 42 49 public final void releaseKey(KeyCacheEntry key) { -
core/java/src/net/i2p/crypto/ElGamalAESEngine.java
r8e709ee r2deee2b1 30 30 * Handles the actual ElGamal+AES encryption and decryption scenarios using the 31 31 * supplied keys and data. 32 * 33 * No, this does not extend AESEngine or CryptixAESEngine. 32 34 */ 33 35 public class ElGamalAESEngine { 34 private final static Log _log = new Log(ElGamalAESEngine.class);36 private final Log _log; 35 37 private final static int MIN_ENCRYPTED_SIZE = 80; // smallest possible resulting size 36 private I2PAppContext _context; 37 38 private ElGamalAESEngine() { // nop 39 } 38 private final I2PAppContext _context; 40 39 41 40 public ElGamalAESEngine(I2PAppContext ctx) { 42 41 _context = ctx; 42 _log = _context.logManager().getLog(ElGamalAESEngine.class); 43 43 44 44 _context.statManager().createFrequencyStat("crypto.elGamalAES.encryptNewSession", … … 628 628 } 629 629 630 /**** 630 631 public static void main(String args[]) { 631 632 I2PAppContext ctx = new I2PAppContext(); … … 657 658 } 658 659 } 660 ****/ 659 661 }
Note: See TracChangeset
for help on using the changeset viewer.