Changeset f1df496 for core/java


Ignore:
Timestamp:
Aug 4, 2018 1:41:01 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2cc362c
Parents:
c0be83f
Message:

Data: Check sooner for unknown sig type;
minor efficiency improvements in parsing

Location:
core/java/src/net/i2p/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/Certificate.java

    rc0be83f rf1df496  
    9090     */
    9191    public static Certificate create(InputStream in) throws DataFormatException, IOException {
    92         int type = (int) DataHelper.readLong(in, 1);
     92        // EOF will be thrown in next read
     93        int type = in.read();
    9394        int length = (int) DataHelper.readLong(in, 2);
    9495        if (type == 0 && length == 0)
     
    162163        if (_type != 0 || _payload != null)
    163164            throw new IllegalStateException("already set");
    164         _type = (int) DataHelper.readLong(in, 1);
     165        // EOF will be thrown in next read
     166        _type = in.read();
    165167        int length = (int) DataHelper.readLong(in, 2);
    166168        if (length > 0) {
  • core/java/src/net/i2p/data/LeaseSet.java

    rc0be83f rf1df496  
    2020import net.i2p.I2PAppContext;
    2121import net.i2p.crypto.DSAEngine;
     22import net.i2p.crypto.SigType;
    2223import net.i2p.util.Clock;
    2324import net.i2p.util.Log;
     
    328329        _encryptionKey = PublicKey.create(in);
    329330        // revocation signing key must be same type as the destination signing key
    330         _signingKey = new SigningPublicKey(_destination.getSigningPublicKey().getType());
     331        SigType type = _destination.getSigningPublicKey().getType();
     332        // Even if not verifying, we have to construct a Signature object
     333        // below, which will fail for null type.
     334        if (type == null)
     335            throw new DataFormatException("unknown sig type");
     336        _signingKey = new SigningPublicKey(type);
     337        // EOF will be thrown in signature read below
    331338        _signingKey.readBytes(in);
    332         int numLeases = (int) DataHelper.readLong(in, 1);
     339        int numLeases = in.read();
    333340        if (numLeases > MAX_LEASES)
    334341            throw new DataFormatException("Too many leases - max is " + MAX_LEASES);
     
    340347        }
    341348        // signature must be same type as the destination signing key
    342         _signature = new Signature(_destination.getSigningPublicKey().getType());
     349        _signature = new Signature(type);
    343350        _signature.readBytes(in);
    344351    }
Note: See TracChangeset for help on using the changeset viewer.