Changeset 32e1c96


Ignore:
Timestamp:
Sep 22, 2016 5:10:50 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4ab727a
Parents:
fb323ce
Message:

EdDSA: throw IllegalStateException? instead of NPE if field not set

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/eddsa/math/bigint/BigIntegerLittleEndianEncoding.java

    rfb323ce r32e1c96  
    3030     *
    3131     *  @return array of length b/8
     32     *  @throws IllegalStateException if field not set
    3233     */
    3334    public byte[] encode(BigInteger x) {
     35        if (f == null)
     36            throw new IllegalStateException("field not set");
    3437        byte[] in = x.toByteArray();
    3538        byte[] out = new byte[f.getb()/8];
     
    4346    }
    4447
     48    /**
     49     *  Decode a FieldElement from its (b-1)-bit encoding.
     50     *  The highest bit is masked out.
     51     *
     52     *  @param in the (b-1)-bit encoding of a FieldElement.
     53     *  @return the FieldElement represented by 'val'.
     54     *  @throws IllegalStateException if field not set
     55     *  @throws IllegalArgumentException if encoding is invalid
     56     */
    4557    public FieldElement decode(byte[] in) {
     58        if (f == null)
     59            throw new IllegalStateException("field not set");
    4660        if (in.length != f.getb()/8)
    4761            throw new IllegalArgumentException("Not a valid encoding");
Note: See TracChangeset for help on using the changeset viewer.