Changeset 8badb609


Ignore:
Timestamp:
Jan 29, 2016 12:56:26 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
da3086b
Parents:
a1a895e
Message:

Selfsigned: Add EdDSA_SHA512_Ed25519 support
Remove debug output by default

File:
1 edited

Legend:

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

    ra1a895e r8badb609  
    3434import net.i2p.data.SigningPublicKey;
    3535import net.i2p.data.SimpleDataStructure;
     36import net.i2p.util.HexDump;
    3637import net.i2p.util.RandomSource;
    3738import net.i2p.util.SystemVersion;
     
    5051public final class SelfSignedGenerator {
    5152
     53    private static final boolean DEBUG = false;
     54
    5255    private static final String OID_CN = "2.5.4.3";
    5356    private static final String OID_C = "2.5.4.6";
     
    9396            case RSA_SHA384_3072:
    9497            case RSA_SHA512_4096:
     98            case EdDSA_SHA512_Ed25519:
    9599                oid = type.getOID();
    96100                break;
     
    122126
    123127        // sig algo
    124         System.out.println("Sig OID");
    125         System.out.println(net.i2p.util.HexDump.dump(sigoid));
    126128        System.arraycopy(sigoid, 0, cb, idx, sigoid.length);
    127129        idx += sigoid.length;
    128130
    129131        // sig (bit string)
    130         System.out.println("Signature");
    131         System.out.println(net.i2p.util.HexDump.dump(sigbytes));
    132132        cb[idx++] = 0x03;
    133133        idx = intToASN1(cb, idx, sigbytes.length + 1);
     
    135135        System.arraycopy(sigbytes, 0, cb, idx, sigbytes.length);
    136136
    137         System.out.println("Whole cert");
    138         System.out.println(net.i2p.util.HexDump.dump(cb));
     137        if (DEBUG) {
     138            System.out.println("Sig OID");
     139            System.out.println(HexDump.dump(sigoid));
     140            System.out.println("Signature");
     141            System.out.println(HexDump.dump(sigbytes));
     142            System.out.println("Whole cert");
     143            System.out.println(HexDump.dump(cb));
     144        }
    139145        ByteArrayInputStream bais = new ByteArrayInputStream(cb);
    140146
     
    181187        rv[idx++] = 0x30;
    182188        idx = intToASN1(rv, idx, len);
    183         System.out.println(net.i2p.util.HexDump.dump(version));
    184189        System.arraycopy(version, 0, rv, idx, version.length);
    185190        idx += version.length;
    186         System.out.println("serial");
    187         System.out.println(net.i2p.util.HexDump.dump(serial));
    188191        System.arraycopy(serial, 0, rv, idx, serial.length);
    189192        idx += serial.length;
    190         System.out.println("oid");
    191         System.out.println(net.i2p.util.HexDump.dump(sigoid));
    192193        System.arraycopy(sigoid, 0, rv, idx, sigoid.length);
    193194        idx += sigoid.length;
    194         System.out.println("issuer");
    195         System.out.println(net.i2p.util.HexDump.dump(issuer));
    196195        System.arraycopy(issuer, 0, rv, idx, issuer.length);
    197196        idx += issuer.length;
    198         System.out.println("valid");
    199         System.out.println(net.i2p.util.HexDump.dump(validity));
    200197        System.arraycopy(validity, 0, rv, idx, validity.length);
    201198        idx += validity.length;
    202         System.out.println("subject");
    203         System.out.println(net.i2p.util.HexDump.dump(subject));
    204199        System.arraycopy(subject, 0, rv, idx, subject.length);
    205200        idx += subject.length;
    206         System.out.println("pub");
    207         System.out.println(net.i2p.util.HexDump.dump(pubbytes));
    208201        System.arraycopy(pubbytes, 0, rv, idx, pubbytes.length);
    209202        idx += pubbytes.length;
    210         System.out.println("extensions");
    211         System.out.println(net.i2p.util.HexDump.dump(extbytes));
    212203        System.arraycopy(extbytes, 0, rv, idx, extbytes.length);
    213204
    214         System.out.println("TBS cert");
    215         System.out.println(net.i2p.util.HexDump.dump(rv));
     205        if (DEBUG) {
     206            System.out.println(HexDump.dump(version));
     207            System.out.println("serial");
     208            System.out.println(HexDump.dump(serial));
     209            System.out.println("oid");
     210            System.out.println(HexDump.dump(sigoid));
     211            System.out.println("issuer");
     212            System.out.println(HexDump.dump(issuer));
     213            System.out.println("valid");
     214            System.out.println(HexDump.dump(validity));
     215            System.out.println("subject");
     216            System.out.println(HexDump.dump(subject));
     217            System.out.println("pub");
     218            System.out.println(HexDump.dump(pubbytes));
     219            System.out.println("extensions");
     220            System.out.println(HexDump.dump(extbytes));
     221            System.out.println("TBS cert");
     222            System.out.println(HexDump.dump(rv));
     223        }
    216224        return rv;
    217225    }
     
    364372            test("test5", SigType.RSA_SHA384_3072);
    365373            test("test6", SigType.RSA_SHA512_4096);
     374            test("test7", SigType.EdDSA_SHA512_Ed25519);
    366375        } catch (Exception e) {
    367376            e.printStackTrace();
Note: See TracChangeset for help on using the changeset viewer.