Changeset c48266f


Ignore:
Timestamp:
Feb 24, 2014 1:51:20 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5d6a1c5
Parents:
895d54d
Message:
  • Transports: Use SigUtil?.rectify() in DH
Files:
2 edited

Legend:

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

    r895d54d rc48266f  
    4444 * Utilities for Signing keys and Signatures
    4545 *
    46  * @since 0.9.9
     46 * @since 0.9.9, public since 0.9.12
    4747 */
    48 class SigUtil {
     48public class SigUtil {
    4949
    5050    private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache<SigningPublicKey, ECPublicKey>(64);
  • router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java

    r895d54d rc48266f  
    1313//import java.io.OutputStream;
    1414import java.math.BigInteger;
     15import java.security.InvalidKeyException;
    1516import java.util.concurrent.LinkedBlockingQueue;
    1617
     
    1920import net.i2p.crypto.CryptoConstants;
    2021import net.i2p.crypto.SHA256Generator;
     22import net.i2p.crypto.SigUtil;
    2123import net.i2p.data.ByteArray;
    2224//import net.i2p.data.DataHelper;
     
    184186    }
    185187   
     188    /**
     189     *  @return exactly 256 bytes
     190     *  @throws IllegalArgumentException if requires more than 256 bytes
     191     */
    186192    private static final byte[] toByteArray(BigInteger bi) {
    187         byte data[] = bi.toByteArray();
    188         byte rv[] = new byte[256];
    189         if (data.length == 257) // high byte has the sign bit
    190             System.arraycopy(data, 1, rv, 0, rv.length);
    191         else if (data.length == 256)
    192             System.arraycopy(data, 0, rv, 0, rv.length);
    193         else
    194             System.arraycopy(data, 0, rv, rv.length-data.length, data.length);
    195         return rv;
     193        try {
     194            return SigUtil.rectify(bi, 256);
     195        } catch (InvalidKeyException ike) {
     196            throw new IllegalArgumentException(ike);
     197        }
    196198    }
    197199
Note: See TracChangeset for help on using the changeset viewer.