Changeset 9377b57 for core


Ignore:
Timestamp:
Nov 13, 2018 5:51:52 PM (19 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ddfc7c0
Parents:
2bfbcf1a
Message:

ElG minor cleanup

File:
1 edited

Legend:

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

    r2bfbcf1a r9377b57  
    100100        SessionKey usedKey = new SessionKey();
    101101        Set<SessionTag> foundTags = new HashSet<SessionTag>();
    102         byte decrypted[] = null;
     102        byte decrypted[];
    103103        boolean wasExisting = false;
     104        final boolean shouldDebug = _log.shouldDebug();
    104105        if (key != null) {
    105106            //if (_log.shouldLog(Log.DEBUG)) _log.debug("Key is known for tag " + st);
    106             if (_log.shouldLog(Log.DEBUG))
     107            if (shouldDebug)
    107108                _log.debug("Decrypting existing session encrypted with tag: " + st.toString() + ": key: " + key.toBase64() + ": " + data.length + " bytes " /* + Base64.encode(data, 0, 64) */ );
    108109           
     
    110111            if (decrypted != null) {
    111112                _context.statManager().updateFrequency("crypto.elGamalAES.decryptExistingSession");
    112                 if ( (!foundTags.isEmpty()) && (_log.shouldLog(Log.DEBUG)) )
     113                if (!foundTags.isEmpty() && shouldDebug)
    113114                    _log.debug("ElG/AES decrypt success with " + st + ": found tags: " + foundTags);
    114115                wasExisting = true;
     
    120121            }
    121122        } else {
    122             if (_log.shouldLog(Log.DEBUG)) _log.debug("Key is NOT known for tag " + st);
     123            if (shouldDebug) _log.debug("Key is NOT known for tag " + st);
    123124            decrypted = decryptNewSession(data, targetPrivateKey, foundTags, usedKey, foundKey);
    124125            if (decrypted != null) {
    125126                _context.statManager().updateFrequency("crypto.elGamalAES.decryptNewSession");
    126                 if ( (!foundTags.isEmpty()) && (_log.shouldLog(Log.DEBUG)) )
     127                if (!foundTags.isEmpty() && shouldDebug)
    127128                    _log.debug("ElG decrypt success: found tags: " + foundTags);
    128129            } else {
     
    133134        }
    134135
    135         if ((key == null) && (decrypted == null)) {
     136        //if ((key == null) && (decrypted == null)) {
    136137            //_log.debug("Unable to decrypt the data starting with tag [" + st + "] - did the tag expire recently?", new Exception("Decrypt failure"));
    137         }
     138        //}
    138139
    139140        if (!foundTags.isEmpty()) {
    140141            if (foundKey.getData() != null) {
    141                 if (_log.shouldLog(Log.DEBUG))
     142                if (shouldDebug)
    142143                    _log.debug("Found key: " + foundKey.toBase64() + " tags: " + foundTags + " wasExisting? " + wasExisting);
    143144                keyManager.tagsReceived(foundKey, foundTags);
    144145            } else if (usedKey.getData() != null) {
    145                 if (_log.shouldLog(Log.DEBUG))
     146                if (shouldDebug)
    146147                    _log.debug("Used key: " + usedKey.toBase64() + " tags: " + foundTags + " wasExisting? " + wasExisting);
    147148                keyManager.tagsReceived(usedKey, foundTags);
Note: See TracChangeset for help on using the changeset viewer.