Changeset 2487bca for router


Ignore:
Timestamp:
Nov 30, 2018 3:15:31 PM (20 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f168918
Parents:
cc4da1b
Message:

Crypto: Change X25519 key classes from Java keys to I2P keys,
in prep for new crypto (Proposal 144)
Add EncType?
Fix PrivateKey? constructor w/ EncType?
Add support to KeyGenerator?

Location:
router/java/src
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/com/southernstorm/noise/protocol/Curve25519DHState.java

    rcc4da1b r2487bca  
    2323package com.southernstorm.noise.protocol;
    2424
    25 import java.security.KeyPair;
    2625import java.util.Arrays;
    2726
    2827import com.southernstorm.noise.crypto.x25519.Curve25519;
    2928
     29import net.i2p.crypto.KeyPair;
    3030import net.i2p.router.transport.crypto.X25519KeyFactory;
    3131
     
    7979        public void generateKeyPair() {
    8080                KeyPair kp = _xdh.getKeys();
    81                 System.arraycopy(kp.getPrivate().getEncoded(), 0, privateKey, 0, 32);
    82                 System.arraycopy(kp.getPublic().getEncoded(), 0, publicKey, 0, 32);
     81                System.arraycopy(kp.getPrivate().getData(), 0, privateKey, 0, 32);
     82                System.arraycopy(kp.getPublic().getData(), 0, publicKey, 0, 32);
    8383                mode = 0x03;
    8484        }
  • router/java/src/net/i2p/router/transport/crypto/X25519KeyFactory.java

    rcc4da1b r2487bca  
    11package net.i2p.router.transport.crypto;
    22
    3 import java.security.KeyPair;
    43import java.util.concurrent.LinkedBlockingQueue;
    54
     
    76
    87import net.i2p.I2PAppContext;
     8import net.i2p.crypto.EncType;
     9import net.i2p.crypto.KeyPair;
     10import net.i2p.data.PrivateKey;
     11import net.i2p.data.PublicKey;
    912import net.i2p.util.I2PThread;
    1013import net.i2p.util.Log;
     
    134137        byte[] pub = new byte[32];
    135138        Curve25519.eval(pub, 0, priv, null);
    136         KeyPair rv = new KeyPair(new X25519PublicKey(pub), new X25519PrivateKey(priv));
     139        KeyPair rv = new KeyPair(new PublicKey(EncType.ECIES_X25519, pub), new PrivateKey(EncType.ECIES_X25519, priv));
    137140        long end = System.currentTimeMillis();
    138141        long diff = end - start;
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    rcc4da1b r2487bca  
    99import java.nio.channels.ServerSocketChannel;
    1010import java.nio.channels.SocketChannel;
    11 import java.security.KeyPair;
    1211import java.text.DecimalFormat;
    1312import java.text.NumberFormat;
     
    2827import java.util.concurrent.ConcurrentHashMap;
    2928
     29import net.i2p.crypto.EncType;
     30import net.i2p.crypto.KeyPair;
    3031import net.i2p.crypto.SigType;
    3132import net.i2p.data.Base64;
     
    3334import net.i2p.data.DataHelper;
    3435import net.i2p.data.Hash;
     36import net.i2p.data.PublicKey;
     37import net.i2p.data.PrivateKey;
    3538import net.i2p.data.router.RouterAddress;
    3639import net.i2p.data.router.RouterIdentity;
     
    4952import net.i2p.router.transport.crypto.DHSessionKeyBuilder;
    5053import net.i2p.router.transport.crypto.X25519KeyFactory;
    51 import net.i2p.router.transport.crypto.X25519PublicKey;
    52 import net.i2p.router.transport.crypto.X25519PrivateKey;
    5354import net.i2p.router.util.DecayingHashSet;
    5455import net.i2p.router.util.DecayingBloomFilter;
     
    258259            if (priv == null || priv.length != NTCP2_KEY_LEN) {
    259260                KeyPair keys = xdh.getKeys();
    260                 _ntcp2StaticPrivkey = keys.getPrivate().getEncoded();
    261                 _ntcp2StaticPubkey = keys.getPublic().getEncoded();
     261                _ntcp2StaticPrivkey = keys.getPrivate().getData();
     262                _ntcp2StaticPubkey = keys.getPublic().getData();
    262263                shouldSave = true;
    263264            } else {
    264265                _ntcp2StaticPrivkey = priv;
    265                 _ntcp2StaticPubkey = (new X25519PrivateKey(priv)).toPublic().getEncoded();
     266                _ntcp2StaticPubkey = (new PrivateKey(EncType.ECIES_X25519, priv)).toPublic().getData();
    266267            }
    267268            if (!shouldSave) {
Note: See TracChangeset for help on using the changeset viewer.