Changeset 134cbd4 for core


Ignore:
Timestamp:
Jan 4, 2017 1:00:31 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6843950
Parents:
91007735
Message:

Crypto: Enforce correct seed and hash lengths in EdDSAPrivateKeySpec
From github PR #22
https://github.com/str4d/ed25519-java/commit/747df9f9aa407ba90d34f498c5eab6f304fdd58a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/eddsa/spec/EdDSAPrivateKeySpec.java

    r91007735 r134cbd4  
    2222
    2323    /**
    24      *  @throws IllegalArgumentException if hash algorithm is unsupported
     24     *  @throws IllegalArgumentException if seed length is wrong or hash algorithm is unsupported
    2525     */
    2626    public EdDSAPrivateKeySpec(byte[] seed, EdDSAParameterSpec spec) {
     27        if (seed.length != spec.getCurve().getField().getb()/8)
     28            throw new IllegalArgumentException("seed length is wrong");
     29
    2730        this.spec = spec;
    2831        this.seed = seed;
     
    5760     *
    5861     *  @param h the private key
     62     *  @throws IllegalArgumentException if hash length is wrong
    5963     *  @since 0.9.27 (GitHub issue #17)
    6064     */
    6165    public EdDSAPrivateKeySpec(EdDSAParameterSpec spec, byte[] h) {
     66        if (h.length != spec.getCurve().getField().getb()/4)
     67            throw new IllegalArgumentException("hash length is wrong");
     68
    6269        this.seed = null;
    6370        this.h = h;
     
    7885        this.a = a;
    7986        this.A = A;
    80         this.spec = spec;       
     87        this.spec = spec;
    8188    }
    8289
Note: See TracChangeset for help on using the changeset viewer.