Changeset 535f2da for router


Ignore:
Timestamp:
Nov 23, 2018 1:04:28 PM (19 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d6e3501
Parents:
5c0c69c
Message:

Router: Move ElGamalAESEngine from core to router
Client end-to-end crypto removed 13 years ago
Not used by any client, app, or plugin.

Location:
router/java/src/net/i2p/router
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/RouterContext.java

    r5c0c69c r535f2da  
    1616import net.i2p.internal.InternalClientManager;
    1717import net.i2p.router.client.ClientManagerFacadeImpl;
     18import net.i2p.router.crypto.ElGamalAESEngine;
    1819import net.i2p.router.crypto.TransientSessionKeyManager;
    1920import net.i2p.router.dummy.*;
     
    6970    private RouterKeyGenerator _routingKeyGenerator;
    7071    private GarlicMessageParser _garlicMessageParser;
     72    private ElGamalAESEngine _elGamalAESEngine;
    7173    private final Set<Runnable> _finalShutdownTasks;
    7274    // split up big lock on this to avoid deadlocks
     
    212214            // internal client manager is null
    213215        }
     216        _elGamalAESEngine = new ElGamalAESEngine(this);
    214217        _garlicMessageParser = new GarlicMessageParser(this);
    215218        _clientMessagePool = new ClientMessagePool(this);
     
    668671        return _garlicMessageParser;
    669672    }
     673
     674    /**
     675     * Access the ElGamal/AES+SessionTag engine for this context.  The algorithm
     676     * makes use of the context's sessionKeyManager to coordinate transparent
     677     * access to the sessionKeys and sessionTags, as well as the context's elGamal
     678     * engine (which in turn keeps stats, etc).
     679     *
     680     * @since 0.9.38 moved from superclass (app context)
     681     */
     682    public ElGamalAESEngine elGamalAESEngine() {
     683        return _elGamalAESEngine;
     684    }
    670685}
  • router/java/src/net/i2p/router/crypto/ElGamalAESEngine.java

    r5c0c69c r535f2da  
    1 package net.i2p.crypto;
     1package net.i2p.router.crypto;
    22
    33/*
     
    1717
    1818import net.i2p.I2PAppContext;
     19import net.i2p.crypto.AESEngine;
     20import net.i2p.crypto.SessionKeyManager;
    1921import net.i2p.data.DataFormatException;
    2022import net.i2p.data.DataHelper;
     
    3234 *
    3335 * No, this does not extend AESEngine or CryptixAESEngine.
     36 *
     37 * @since 0.9.38 moved from net.i2p.crypto
    3438 */
    3539public final class ElGamalAESEngine {
     
    650654                 + (newKey == null ? 1 : 1 + SessionKey.KEYSIZE_BYTES)
    651655                 + data.length;
    652         int totalSize = size + getPaddingSize(size, paddedSize);
     656        int totalSize = size + AESEngine.getPaddingSize(size, paddedSize);
    653657
    654658        byte aesData[] = new byte[totalSize + prefixBytes];
     
    684688
    685689        //_log.debug("raw data written: " + len);
    686         byte padding[] = getPadding(_context, size, paddedSize);
     690        byte padding[] = AESEngine.getPadding(_context, size, paddedSize);
    687691        //_log.debug("padding length: " + padding.length);
    688692        System.arraycopy(padding, 0, aesData, cur, padding.length);
     
    697701    }
    698702
    699     /**
    700      * Return random bytes for padding the data to a mod 16 size so that it is
    701      * at least minPaddedSize
    702      *
    703      */
    704     final static byte[] getPadding(I2PAppContext context, int curSize, long minPaddedSize) {
    705         int size = getPaddingSize(curSize, minPaddedSize);
    706         byte rv[] = new byte[size];
    707         context.random().nextBytes(rv);
    708         return rv;
    709     }
    710 
    711     final static int getPaddingSize(int curSize, long minPaddedSize) {
    712         int diff = 0;
    713         if (curSize < minPaddedSize) {
    714             diff = (int) minPaddedSize - curSize;
    715         }
    716 
    717         int numPadding = diff;
    718         if (((curSize + diff) % 16) != 0) numPadding += (16 - ((curSize + diff) % 16));
    719         return numPadding;
    720     }
    721703
    722704/****
  • router/java/src/net/i2p/router/message/GarlicMessageParser.java

    r5c0c69c r535f2da  
    1111import java.util.Date;
    1212
    13 import net.i2p.I2PAppContext;
    1413import net.i2p.crypto.SessionKeyManager;
    1514import net.i2p.data.Certificate;
     
    1918import net.i2p.data.i2np.GarlicClove;
    2019import net.i2p.data.i2np.GarlicMessage;
     20import net.i2p.router.RouterContext;
    2121import net.i2p.util.Log;
    2222
     
    2828public class GarlicMessageParser {
    2929    private final Log _log;
    30     private final I2PAppContext _context;
     30    private final RouterContext _context;
    3131   
    3232    /**
     
    3636    private static final int MAX_CLOVES = 32;
    3737
    38     public GarlicMessageParser(I2PAppContext context) {
     38    public GarlicMessageParser(RouterContext context) {
    3939        _context = context;
    4040        _log = _context.logManager().getLog(GarlicMessageParser.class);
Note: See TracChangeset for help on using the changeset viewer.