Changeset 801ca47


Ignore:
Timestamp:
Sep 13, 2013 12:49:10 AM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4ffaf412
Parents:
43f5062
Message:

add Koblitz curves for testing

Location:
core/java/src/net/i2p/crypto
Files:
4 edited

Legend:

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

    r43f5062 r801ca47  
    383383            return null;
    384384        } else {
    385             if (_log.shouldLog(Log.DEBUG)) _log.debug("Using short rbytes.length [" + rbytes.length + "]");
     385            //if (_log.shouldLog(Log.DEBUG)) _log.debug("Using short rbytes.length [" + rbytes.length + "]");
    386386            //System.arraycopy(rbytes, 0, out, 20 - rbytes.length, rbytes.length);
    387387            for (int i = 0; i < rbytes.length; i++)
     
    402402            return null;
    403403        } else {
    404             if (_log.shouldLog(Log.DEBUG)) _log.debug("Using short sbytes.length [" + sbytes.length + "]");
     404            //if (_log.shouldLog(Log.DEBUG)) _log.debug("Using short sbytes.length [" + sbytes.length + "]");
    405405            //System.arraycopy(sbytes, 0, out, 40 - sbytes.length, sbytes.length);
    406406            for (int i = 0; i < sbytes.length; i++)
  • core/java/src/net/i2p/crypto/ECConstants.java

    r43f5062 r801ca47  
    302302    /**
    303303     *  Tries curve name1, then name2, then creates new from parms.
     304     *  @param name2 null to skip
     305     *  @param parms null to skip
    304306     *  @return null if all fail
    305307     */
    306308    private static ECParameterSpec genSpec(String name1, String name2, ECParms parms) {
    307309        ECParameterSpec rv = genSpec(name1);
    308         if (rv == null) {
     310        if (rv == null && name2 != null) {
    309311            rv = genSpec(name2);
    310             if (rv == null) {
     312            if (rv == null && parms != null) {
    311313                rv = parms.genSpec();
    312314                if (rv != null)
     
    325327    public static final ECParameterSpec P521_SPEC = genSpec("secp521r1", "P-521", PARM_P521);
    326328
     329    // Koblitz
     330    public static final ECParameterSpec K163_SPEC = genSpec("sect163k1", "K-163", null);
     331    public static final ECParameterSpec K233_SPEC = genSpec("sect233k1", "K-233", null);
     332    public static final ECParameterSpec K283_SPEC = genSpec("sect283k1", "K-283", null);
     333    public static final ECParameterSpec K409_SPEC = genSpec("sect409k1", "K-409", null);
     334    public static final ECParameterSpec K571_SPEC = genSpec("sect571k1", "K-571", null);
     335
     336
    327337}
  • core/java/src/net/i2p/crypto/KeyGenerator.java

    r43f5062 r801ca47  
    226226            kp = kpg.generateKeyPair();
    227227        } catch (ProviderException pe) {
     228            // java.security.ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DOMAIN_PARAMS_INVALID
    228229            // This is a RuntimeException, thx Sun
    229230            // Fails for P-192 only, on Ubuntu
     
    232233            if ("BC".equals(pname)) {
    233234                if (log.shouldLog(Log.WARN))
    234                     log.warn("BC KPG failed", pe);
    235                 throw new GeneralSecurityException("BC KPG", pe);
     235                    log.warn("BC KPG failed for " + type, pe);
     236                throw new GeneralSecurityException("BC KPG for " + type, pe);
    236237            }
    237238            if (!ECConstants.isBCAvailable())
    238                 throw new GeneralSecurityException(pname + " KPG", pe);
     239                throw new GeneralSecurityException(pname + " KPG failed for " + type, pe);
    239240            if (log.shouldLog(Log.WARN))
    240                 log.warn(pname + " KPG failed, trying BC", pe);
     241                log.warn(pname + " KPG failed for " + type + ", trying BC", pe);
    241242            try {
    242243                kpg = KeyPairGenerator.getInstance("EC", "BC");
     
    245246            } catch (ProviderException pe2) {
    246247                if (log.shouldLog(Log.WARN))
    247                     log.warn("BC KPG failed too", pe2);
     248                    log.warn("BC KPG failed for " + type + " also", pe2);
    248249                // throw original exception
    249                 throw new GeneralSecurityException(pname + " KPG", pe);
     250                throw new GeneralSecurityException(pname + " KPG for " + type, pe);
    250251            } catch (GeneralSecurityException gse) {
    251252                if (log.shouldLog(Log.WARN))
    252                     log.warn("BC KPG failed too", gse);
    253                 gse.printStackTrace();
     253                    log.warn("BC KPG failed for " + type + " also", gse);
    254254                // throw original exception
    255                 throw new GeneralSecurityException(pname + " KPG", pe);
     255                throw new GeneralSecurityException(pname + " KPG for " + type, pe);
    256256            }
    257257        }
  • core/java/src/net/i2p/crypto/SigType.java

    r43f5062 r801ca47  
    4949    ECDSA_SHA512_P384(11, 96, 48, 64, 96, SigAlgo.EC, "SHA-512", "SHA512withECDSA", ECConstants.P384_SPEC),
    5050
     51    ECDSA_SHA256_K163(12, 42, 21, 32, 42, SigAlgo.EC, "SHA-256", "SHA256withECDSA", ECConstants.K163_SPEC),
     52    ECDSA_SHA256_K233(13, 60, 30, 32, 60, SigAlgo.EC, "SHA-256", "SHA256withECDSA", ECConstants.K233_SPEC),
     53    ECDSA_SHA256_K283(14, 72, 36, 32, 72, SigAlgo.EC, "SHA-256", "SHA256withECDSA", ECConstants.K283_SPEC),
     54    ECDSA_SHA256_K409(15, 104, 52, 32, 104, SigAlgo.EC, "SHA-256", "SHA256withECDSA", ECConstants.K409_SPEC),
     55    ECDSA_SHA256_K571(16, 144, 72, 32, 144, SigAlgo.EC, "SHA-256", "SHA256withECDSA", ECConstants.K571_SPEC),
    5156
    5257    //MD5
Note: See TracChangeset for help on using the changeset viewer.