Changeset f168918 for core/java


Ignore:
Timestamp:
Nov 30, 2018 3:56:27 PM (20 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
922515df
Parents:
2487bca
Message:

Data: Check data length in typed constructors
Check for type match in KeyPair?
Mark placeholder EncTypes? 1-3 as unavailable

Location:
core/java/src/net/i2p
Files:
4 edited

Legend:

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

    r2487bca rf168918  
    114114        if (ELGAMAL_2048 == this)
    115115            return true;
     116        // EC types are placeholders for now
     117        if (base == EncAlgo.EC)
     118            return false;
    116119        try {
    117120            getParams();
  • core/java/src/net/i2p/crypto/KeyPair.java

    r2487bca rf168918  
    1414    private final PrivateKey priv;
    1515
     16    /**
     17     * @param publicKey non-null, same EncType as privateKey
     18     * @param privateKey non-null, same EncType as publicKey
     19     */
    1620    public KeyPair(PublicKey publicKey, PrivateKey privateKey) {
    1721        pub = publicKey;
    1822        priv = privateKey;
     23        if (pub.getType() != priv.getType())
     24            throw new IllegalArgumentException();
    1925    }
    2026
  • core/java/src/net/i2p/data/PrivateKey.java

    r2487bca rf168918  
    5454     */
    5555    public PrivateKey(EncType type, byte data[]) {
    56         super();
    57         _type = type;
     56        this(type);
    5857        if (data == null)
    5958            throw new IllegalArgumentException("Data must be specified");
    60         _data = data;
     59        setData(data);
    6160    }
    6261
  • core/java/src/net/i2p/data/PublicKey.java

    r2487bca rf168918  
    7777     */
    7878    public PublicKey(EncType type, byte data[]) {
    79         super();
    80         _type = type;
     79        this(type);
    8180        if (data == null)
    8281            throw new IllegalArgumentException("Data must be specified");
    83         _data = data;
     82        setData(data);
    8483    }
    8584
Note: See TracChangeset for help on using the changeset viewer.