Changeset 1eaf376


Ignore:
Timestamp:
Jul 7, 2015 1:46:04 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
817888c
Parents:
6cb3d1d3
Message:

Crypto: Check for error return from sign()

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/impl/PacketLocal.java

    r6cb3d1d3 r1eaf376  
    217217        int size = writePacket(buffer, offset, key.getType().getSigLen());
    218218        _optionSignature = _context.dsa().sign(buffer, offset, size, key);
     219        if (_optionSignature == null)
     220            throw new IllegalStateException("Signature failed");
    219221        //if (false) {
    220222        //    Log l = ctx.logManager().getLog(Packet.class);
  • core/java/src/net/i2p/crypto/DSAEngine.java

    r6cb3d1d3 r1eaf376  
    286286                return altSign(data, offset, length, signingKey);
    287287            } catch (GeneralSecurityException gse) {
    288                 if (_log.shouldLog(Log.WARN))
    289                     _log.warn(type + " Sign Fail", gse);
     288                if (_log.shouldLog(Log.ERROR))
     289                    _log.error(type + " Sign Fail", gse);
    290290                return null;
    291291            }
  • core/java/src/net/i2p/crypto/KeyGenerator.java

    r6cb3d1d3 r1eaf376  
    418418            long start = System.nanoTime();
    419419            Signature sig = DSAEngine.getInstance().sign(src, privkey);
     420            if (sig == null)
     421                throw new GeneralSecurityException("signature generation failed");
    420422            long mid = System.nanoTime();
    421423            boolean ok = DSAEngine.getInstance().verifySignature(sig, src, pubkey);
  • core/java/src/net/i2p/data/DatabaseEntry.java

    r6cb3d1d3 r1eaf376  
    172172        byte[] bytes = getBytes();
    173173        if (bytes == null) throw new DataFormatException("Not enough data to sign");
     174        if (key == null)
     175            throw new DataFormatException("No signing key");
    174176        // now sign with the key
    175177        _signature = DSAEngine.getInstance().sign(bytes, key);
     178        if (_signature == null)
     179            throw new DataFormatException("Signature failed with " + key.getType() + " key");
    176180    }
    177181
  • core/java/src/net/i2p/data/PrivateKeyFile.java

    r6cb3d1d3 r1eaf376  
    406406        System.arraycopy(this.dest.getSigningPublicKey().getData(), 0, data, PublicKey.KEYSIZE_BYTES, SigningPublicKey.KEYSIZE_BYTES);
    407407        byte[] payload = new byte[Hash.HASH_LENGTH + Signature.SIGNATURE_BYTES];
    408         byte[] sig = DSAEngine.getInstance().sign(new ByteArrayInputStream(data), spk2).getData();
     408        Signature sign = DSAEngine.getInstance().sign(new ByteArrayInputStream(data), spk2);
     409        if (sign == null)
     410            return null;
     411        byte[] sig = sign.getData();
    409412        System.arraycopy(sig, 0, payload, 0, Signature.SIGNATURE_BYTES);
    410413        // Add dest2's Hash for reference
  • core/java/src/net/i2p/data/i2cp/SessionConfig.java

    r6cb3d1d3 r1eaf376  
    122122        byte data[] = getBytes();
    123123        if (data == null) throw new DataFormatException("Unable to retrieve bytes for signing");
     124        if (signingKey == null)
     125            throw new DataFormatException("No signing key");
    124126        _signature = DSAEngine.getInstance().sign(data, signingKey);
     127        if (_signature == null)
     128            throw new DataFormatException("Signature failed with " + signingKey.getType() + " key");
    125129    }
    126130
Note: See TracChangeset for help on using the changeset viewer.