Changeset 2deee2b1


Ignore:
Timestamp:
Dec 15, 2010 4:10:03 PM (10 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4c9558c
Parents:
8e709ee
Message:

AES cleanups and javadoc

Location:
core/java/src/net/i2p/crypto
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/AESEngine.java

    r8e709ee r2deee2b1  
    2323 */
    2424public class AESEngine {
    25     private Log _log;
    26     private I2PAppContext _context;
     25    protected final Log _log;
     26    protected final I2PAppContext _context;
     27
    2728    public AESEngine(I2PAppContext ctx) {
    2829        _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");
    3233    }
    3334   
     
    4546    }
    4647   
    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     *
    4852     * @param payload data to be encrypted
    4953     * @param payloadIndex index into the payload to start encrypting
     
    5660    public void encrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int ivOffset, int length) {
    5761        System.arraycopy(payload, payloadIndex, out, outIndex, length);
    58         _log.warn("Warning: AES is disabled");
     62        _log.logAlways(Log.WARN, "AES is disabled");
    5963    }
    6064
     
    119123    }
    120124
    121 
    122125    /** Decrypt the data with the session key
    123126     * @param payload data to be decrypted
     
    133136    }
    134137   
    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     *
    136142     * @param payload data to be decrypted
    137143     * @param payloadIndex index into the payload to start decrypting
     
    144150    public void decrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int ivOffset, int length) {
    145151        System.arraycopy(payload, payloadIndex, out, outIndex, length);
    146         _log.warn("Warning: AES is disabled");
     152        _log.logAlways(Log.WARN, "AES is disabled");
    147153    }
    148154
    149155    /**
    150      *   Just copies payload to out
     156     * This just copies payload to out, see extension for the real thing.
    151157     *   @param sessionKey unused
    152158     */
     
    155161    }
    156162
    157     /** decrypt the data with the session key provided
     163    /**
     164     * This just copies payload to rv, see extension for the real thing.
     165     *
    158166     * @param payload encrypted data
    159167     * @param sessionKey private session key
  • core/java/src/net/i2p/crypto/CryptixAESEngine.java

    r8e709ee r2deee2b1  
    2828 */
    2929public class CryptixAESEngine extends AESEngine {
    30     private Log _log;
    3130    private final static CryptixRijndael_Algorithm _algo = new CryptixRijndael_Algorithm();
    3231    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;
    3534   
    3635    private static final ByteCache _prevCache = ByteCache.getInstance(16, 16);
     
    3837    public CryptixAESEngine(I2PAppContext context) {
    3938        super(context);
    40         _log = context.logManager().getLog(CryptixAESEngine.class);
    41         _cache = new CryptixAESKeyCache();
     39        //_cache = new CryptixAESKeyCache();
    4240    }
    4341   
  • core/java/src/net/i2p/crypto/CryptixAESKeyCache.java

    r8e709ee r2deee2b1  
    99 * of code)
    1010 *
     11 * Unused as a class, as the keys are cached in the SessionKey objects,
     12 * but the static methods are used in FortunaStandalone.
    1113 */
    1214public final class CryptixAESKeyCache {
     
    2123    private static final int MAX_KEYS = 64;
    2224   
     25    /*
     26     * @deprecated unused, keys are now cached in the SessionKey objects
     27     */
    2328    public CryptixAESKeyCache() {
    2429        _availableKeys = new LinkedBlockingQueue(MAX_KEYS);
     
    2833     * Get the next available structure, either from the cache or a brand new one
    2934     *
     35     * @deprecated unused, keys are now cached in the SessionKey objects
    3036     */
    3137    public final KeyCacheEntry acquireKey() {
     
    3945     * Put this structure back onto the available cache for reuse
    4046     *
     47     * @deprecated unused, keys are now cached in the SessionKey objects
    4148     */
    4249    public final void releaseKey(KeyCacheEntry key) {
  • core/java/src/net/i2p/crypto/ElGamalAESEngine.java

    r8e709ee r2deee2b1  
    3030 * Handles the actual ElGamal+AES encryption and decryption scenarios using the
    3131 * supplied keys and data.
     32 *
     33 * No, this does not extend AESEngine or CryptixAESEngine.
    3234 */
    3335public class ElGamalAESEngine {
    34     private final static Log _log = new Log(ElGamalAESEngine.class);
     36    private final Log _log;
    3537    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;
    4039
    4140    public ElGamalAESEngine(I2PAppContext ctx) {
    4241        _context = ctx;
     42        _log = _context.logManager().getLog(ElGamalAESEngine.class);
    4343       
    4444        _context.statManager().createFrequencyStat("crypto.elGamalAES.encryptNewSession",
     
    628628    }
    629629
     630/****
    630631    public static void main(String args[]) {
    631632        I2PAppContext ctx = new I2PAppContext();
     
    657658        }
    658659    }
     660****/
    659661}
Note: See TracChangeset for help on using the changeset viewer.