Changeset b37160fa for core


Ignore:
Timestamp:
Feb 21, 2019 2:19:38 PM (14 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
9fafc25
Parents:
7fbe1ce
Message:

Crypto: Keygen for RedDSA, allow RedDSA for unblinded keys (Enc LS2)

Location:
core/java/src/net/i2p
Files:
1 added
6 edited

Legend:

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

    r7fbe1ce rb37160fa  
    4040
    4141    /**
    42      *  Only for SigType EdDSA_SHA512_Ed25519.
     42     *  Only for SigTypes EdDSA_SHA512_Ed25519 and RedDSA_SHA512_Ed25519.
    4343     *
    44      *  @param key must be SigType EdDSA_SHA512_Ed25519
     44     *  @param key must be SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
    4545     *  @param alpha must be SigType RedDSA_SHA512_Ed25519
    4646     *  @return SigType RedDSA_SHA512_Ed25519
     
    4949     */
    5050    public static SigningPublicKey blind(SigningPublicKey key, SigningPrivateKey alpha) {
    51         if (key.getType() != TYPE || alpha.getType() != TYPER)
     51        SigType type = key.getType();
     52        if ((type != TYPE && type != TYPER) ||
     53            alpha.getType() != TYPER)
    5254            throw new UnsupportedOperationException();
    5355        try {
     
    6264
    6365    /**
    64      *  Only for SigType EdDSA_SHA512_Ed25519.
     66     *  Only for SigTypes EdDSA_SHA512_Ed25519 and RedDSA_SHA512_Ed25519.
    6567     *
    66      *  @param key must be SigType EdDSA_SHA512_Ed25519
     68     *  @param key must be SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
    6769     *  @param alpha must be SigType RedDSA_SHA512_Ed25519
    6870     *  @return SigType RedDSA_SHA512_Ed25519
     
    7173     */
    7274    public static SigningPrivateKey blind(SigningPrivateKey key, SigningPrivateKey alpha) {
    73         if (key.getType() != TYPE || alpha.getType() != TYPER)
     75        SigType type = key.getType();
     76        if ((type != TYPE && type != TYPER) ||
     77            alpha.getType() != TYPER)
    7478            throw new UnsupportedOperationException();
    7579        try {
     
    123127    /**
    124128     *  Generate alpha for the given time.
    125      *  Only for SigType EdDSA_SHA512_Ed25519.
     129     *  Only for SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519.
    126130     *
    127      *  @param dest spk must be SigType EdDSA_SHA512_Ed25519
     131     *  @param dest spk must be SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
    128132     *  @param secret may be null or zero-length
    129133     *  @param now for what time?
  • core/java/src/net/i2p/crypto/KeyGenerator.java

    r7fbe1ce rb37160fa  
    3636import net.i2p.crypto.eddsa.EdDSAPrivateKey;
    3737import net.i2p.crypto.eddsa.EdDSAPublicKey;
     38import net.i2p.crypto.eddsa.RedKeyPairGenerator;
    3839import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;
    3940import net.i2p.crypto.provider.I2PProvider;
     
    290291        java.security.KeyPair kp;
    291292        if (type.getBaseAlgorithm() == SigAlgo.EdDSA) {
    292             net.i2p.crypto.eddsa.KeyPairGenerator kpg = new net.i2p.crypto.eddsa.KeyPairGenerator();
     293            net.i2p.crypto.eddsa.KeyPairGenerator kpg;
     294            if (type == SigType.RedDSA_SHA512_Ed25519)
     295                kpg = new RedKeyPairGenerator();
     296            else
     297                kpg = new net.i2p.crypto.eddsa.KeyPairGenerator();
    293298            kpg.initialize(type.getParams(), _context.random());
    294299            kp = kpg.generateKeyPair();
  • core/java/src/net/i2p/crypto/SU3File.java

    r7fbe1ce rb37160fa  
    674674            if (!t.isAvailable())
    675675                continue;
    676             if (t == SigType.EdDSA_SHA512_Ed25519)
     676            if (t == SigType.EdDSA_SHA512_Ed25519 ||
     677                t == SigType.RedDSA_SHA512_Ed25519)
    677678                continue; // not supported by keytool, and does double hashing right now
    678679            buf.append("      ").append(t).append("\t(code: ").append(t.getCode()).append(')');
  • core/java/src/net/i2p/crypto/eddsa/EdDSAPrivateKey.java

    r7fbe1ce rb37160fa  
    7272
    7373    /**
    74      * Returns the public key in its canonical encoding.
     74     * Returns the private key in its canonical encoding.
    7575     *<p>
    7676     * This implements the following specs:
  • core/java/src/net/i2p/crypto/eddsa/KeyPairGenerator.java

    r7fbe1ce rb37160fa  
    2222 *  @since 0.9.15
    2323 */
    24 public final class KeyPairGenerator extends KeyPairGeneratorSpi {
    25     private static final int DEFAULT_KEYSIZE = 256;
    26     private EdDSAParameterSpec edParams;
    27     private SecureRandom random;
    28     private boolean initialized;
     24public class KeyPairGenerator extends KeyPairGeneratorSpi {
     25    protected static final int DEFAULT_KEYSIZE = 256;
     26    protected EdDSAParameterSpec edParams;
     27    protected SecureRandom random;
     28    protected boolean initialized;
    2929
    3030    private static final Hashtable<Integer, AlgorithmParameterSpec> edParameters;
  • core/java/src/net/i2p/data/EncryptedLeaseSet.java

    r7fbe1ce rb37160fa  
    8383     * Overridden to set the blinded key
    8484     *
    85      * @param dest non-null, must be EdDSA_SHA512_Ed25519
     85     * @param dest non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
    8686     * @throws IllegalStateException if already signed
    8787     * @throws IllegalArgumentException if not EdDSA
     
    9191        super.setDestination(dest);
    9292        SigningPublicKey spk = dest.getSigningPublicKey();
    93         if (spk.getType() != SigType.EdDSA_SHA512_Ed25519)
     93        SigType type = spk.getType();
     94        if (type != SigType.EdDSA_SHA512_Ed25519 &&
     95            type != SigType.RedDSA_SHA512_Ed25519)
    9496            throw new IllegalArgumentException();
    9597        SigningPublicKey bpk = blind();
Note: See TracChangeset for help on using the changeset viewer.