Changeset 55d92fc


Ignore:
Timestamp:
Apr 26, 2014 1:03:38 PM (7 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
48b6e06, d867f9f
Parents:
2e2d3c3
Message:

Support "raw" EdDSA signatures (in reality they are double-hashed)

File:
1 edited

Legend:

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

    r2e2d3c3 r55d92fc  
    4343
    4444import net.i2p.I2PAppContext;
     45import net.i2p.crypto.eddsa.EdDSAKey;
    4546import net.i2p.data.Hash;
    4647import net.i2p.data.Signature;
     
    550551
    551552        String algo = getRawAlgo(type);
    552         java.security.Signature jsig = java.security.Signature.getInstance(algo);
     553        java.security.Signature jsig;
     554        if (type.getBaseAlgorithm() == SigAlgo.EdDSA)
     555            jsig = new net.i2p.crypto.eddsa.EdDSAEngine(); // Ignore algo, EdDSAKey includes a hash specification.
     556        else
     557            jsig = java.security.Signature.getInstance(algo);
    553558        jsig.initVerify(pubKey);
    554559        jsig.update(hash.getData());
     
    624629            throw new IllegalArgumentException("type mismatch hash=" + hash.getClass() + " key=" + type);
    625630
    626         java.security.Signature jsig = java.security.Signature.getInstance(algo);
     631        java.security.Signature jsig;
     632        if (type.getBaseAlgorithm() == SigAlgo.EdDSA)
     633            jsig = new net.i2p.crypto.eddsa.EdDSAEngine(); // Ignore algo, EdDSAKey includes a hash specification.
     634        else
     635            jsig = java.security.Signature.getInstance(algo);
    627636        jsig.initSign(privKey, _context.random());
    628637        jsig.update(hash.getData());
     
    651660            case EC:
    652661                return "NONEwithECDSA";
     662            case EdDSA:
     663                return "NONEwithEdDSA";
    653664            case RSA:
    654665                return "NONEwithRSA";
     
    664675        if (key instanceof ECKey)
    665676            return "NONEwithECDSA";
     677        if (key instanceof EdDSAKey)
     678            return "NONEwithEdDSA";
    666679        if (key instanceof RSAKey)
    667680            return "NONEwithRSA";
Note: See TracChangeset for help on using the changeset viewer.