Changeset c5c4e3c


Ignore:
Timestamp:
Jun 2, 2011 1:33:03 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2a5ed93
Parents:
94af6550
Message:
Location:
core/java/src/net/i2p
Files:
2 edited

Legend:

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

    r94af6550 rc5c4e3c  
    9292        SessionKey key = keyManager.consumeTag(st);
    9393        SessionKey foundKey = new SessionKey();
    94         foundKey.setData(null);
    9594        SessionKey usedKey = new SessionKey();
    9695        Set foundTags = new HashSet();
     
    9998        if (key != null) {
    10099            //if (_log.shouldLog(Log.DEBUG)) _log.debug("Key is known for tag " + st);
    101             usedKey.setData(key.getData());
    102100            long id = _context.random().nextLong();
    103101            if (_log.shouldLog(Log.DEBUG))
     
    139137                    _log.debug("Found key: " + foundKey.toBase64() + " tags: " + foundTags + " wasExisting? " + wasExisting);
    140138                keyManager.tagsReceived(foundKey, foundTags);
    141             } else {
     139            } else if (usedKey.getData() != null) {
    142140                if (_log.shouldLog(Log.DEBUG))
    143141                    _log.debug("Used key: " + usedKey.toBase64() + " tags: " + foundTags + " wasExisting? " + wasExisting);
     
    161159     *
    162160     * @param foundTags set which is filled with any sessionTags found during decryption
    163      * @param foundKey  session key which may be filled with a new sessionKey found during decryption
     161     * @param foundKey  out parameter. Data must be unset when called; may be filled with a new sessionKey found during decryption
     162     * @param usedKey out parameter. Data must be unset when called; usedKey.setData() will be called by this method on success.
    164163     *
    165164     * @return null if decryption fails
    166165     */
    167     byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set foundTags, SessionKey usedKey,
     166    private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set foundTags, SessionKey usedKey,
    168167                                    SessionKey foundKey) throws DataFormatException {
    169168        if (data == null) {
     
    232231     *
    233232     * @param foundTags set which is filled with any sessionTags found during decryption
    234      * @param foundKey  session key which may be filled with a new sessionKey found during decryption
     233     * @param foundKey  out parameter. Data must be unset when called; may be filled with a new sessionKey found during decryption
     234     * @param usedKey out parameter. Data must be unset when called; usedKey.setData() will be called by this method on success.
     235     *
    235236     * @return decrypted data or null on failure
    236237     *
    237238     */
    238     byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set foundTags,
     239    private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set foundTags,
    239240                                         SessionKey usedKey, SessionKey foundKey) throws DataFormatException {
    240241        byte preIV[] = new byte[32];
     
    243244        byte iv[] = new byte[16];
    244245        System.arraycopy(ivHash.getData(), 0, iv, 0, 16);
    245        
    246         usedKey.setData(key.getData());
    247246
    248247        //_log.debug("Pre IV for decryptExistingSession: " + DataHelper.toString(preIV, 32));
     
    268267        //    _log.debug("Decrypt with an EXISTING session tag successfull, # tags read: " + foundTags.size(),
    269268        //               new Exception("Decrypted by"));
     269        usedKey.setData(key.getData());
    270270        return decrypted;
    271271    }
     
    288288     *
    289289     * @param foundTags set which is filled with any sessionTags found during decryption
    290      * @param foundKey  session key which may be filled with a new sessionKey found during decryption
     290     * @param foundKey  out parameter. Data must be unset when called; may be filled with a new sessionKey found during decryption
    291291     * @return decrypted data or null on failure
    292292     */
    293     byte[] decryptAESBlock(byte encrypted[], SessionKey key, byte iv[],
     293    private byte[] decryptAESBlock(byte encrypted[], SessionKey key, byte iv[],
    294294                           byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
    295295        return decryptAESBlock(encrypted, 0, encrypted.length, key, iv, sentTag, foundTags, foundKey);
    296296    }
    297     byte[] decryptAESBlock(byte encrypted[], int offset, int encryptedLen, SessionKey key, byte iv[],
     297
     298    private byte[] decryptAESBlock(byte encrypted[], int offset, int encryptedLen, SessionKey key, byte iv[],
    298299                           byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
    299300        //_log.debug("iv for decryption: " + DataHelper.toString(iv, 16));     
     
    449450     *
    450451     */
    451     byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
     452    private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
    452453                                    SessionKey newKey, long paddedSize) {
    453454        //_log.debug("Encrypting to a NEW session");
     
    512513     *
    513514     */
    514     byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
     515    private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
    515516                                         SessionTag currentTag, SessionKey newKey, long paddedSize) {
    516517        //_log.debug("Encrypting to an EXISTING session");
     
    544545     *
    545546     */
    546     final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
     547    private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
    547548                                        long paddedSize) {
    548549        return encryptAESBlock(data, key, iv, tagsForDelivery, newKey, paddedSize, 0);
    549550    }
    550     final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
     551
     552    private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
    551553                                        long paddedSize, int prefixBytes) {
    552554        //_log.debug("iv for encryption: " + DataHelper.toString(iv, 16));
     
    617619        return rv;
    618620    }
     621
    619622    final static int getPaddingSize(int curSize, long minPaddedSize) {
    620623        int diff = 0;
  • core/java/src/net/i2p/data/SessionKey.java

    r94af6550 rc5c4e3c  
    4242    @Override
    4343    public void setData(byte[] data) {
    44         _data = data;
     44        super.setData(data);
    4545        _preparedKey = null;
    4646    }
Note: See TracChangeset for help on using the changeset viewer.