#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    [JAVA] security elliptic curve cryptography


    down vote favorite


    Im nebbies on elliptic curve cryptography and i need help to understand if i did good work : i use Java and bouncycastle and i must to generate public and private key from Ecc curve . I take 3 different kind of code from web , but im not sure which is the best . I read that the curve must generate in RANDOM mode for security , but i dont understand how

    I've some question :
    1)which of this code is the most secure and why?
    2)what is the meaning of this :" 192 bit ecc is like 2048 bit rsa"? which is the size of private and public key in Ecc prime192v1? and in another? why?
    3)how generate random curve ?how can generate random private and public key?
    can anyone help me?
    thanks so much



    Code:
    ECCurve.Fp curve = new ECCurve.Fp( new BigInteger("6277101735386680763835789423207666416083908700390324961279"), new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16));
    
    ECDomainParameters params = new ECDomainParameters( curve, curve.decodePoint(Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G new BigInteger ("6277101735386680763835789423176059013767194773182842284081")); // n
    
    
    ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
            new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
            params);
    
        ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
            curve.decodePoint(Hex.decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
            params); 
    
        AsymmetricCipherKeyPair  p1 = new AsymmetricCipherKeyPair(pubKey, priKey);
        AsymmetricCipherKeyPair  p2 = new AsymmetricCipherKeyPair(pubKey,priKey);







    Code:
    ` ECKeyPairGenerator gen = new ECKeyPairGenerator();
               SecureRandom var = new SecureRandom();
              //X9ECParameters cb = SECNamedCurves.getByName("secp256k1");
               //da scegluiere a seconda del tipo di curva
              X9ECParameters c = X962NamedCurves.getByName("prime256v1");
              ECDomainParameters param = new ECDomainParameters(c.getCurve(), c.getG(), c.getN(), c.getH());
              ECKeyGenerationParameters kg = new ECKeyGenerationParameters(param, var);
              gen.init(kg);
              AsymmetricCipherKeyPair  p1b = gen.generateKeyPair() ;
              AsymmetricCipherKeyPair  p2b = gen.generateKeyPair() ;`







    Code:
    `SecureRandom PRNG = SecureRandom.getInstance("SHA256PRNG");`
    //this i take from cryptosms 
    
              int NONCE_SIZE = 64;  
              int PRIV_KEY_SIZE = 64;
              BigInteger privNum = new BigInteger(PRNG
                        .generateSeed(NONCE_SIZE)).abs(); // select k
    
               ECCurve cFp256v1 = new ECCurve.Fp(
                        new BigInteger("115792089210356248762697446949407573530086143415290314195533631308867097853951"),
                        new BigInteger("ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", 16),
                        new BigInteger("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16));
    
                   /**  X9ECParameters prime256v1b = new X9ECParameters(
                        cFp256v1,
                        cFp256v1.decodePoint(
                            Hex.decode("036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296")),
                        new BigInteger("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", 16),
                        BigInteger.valueOf(1),
                        Hex.decode("c49d360886e704936a6678e1139d26b7819f7e90"));*/
    
    
                     ECDomainParameters prime256v1 = new ECDomainParameters(
                             cFp256v1,
                             cFp256v1
                                    .decodePoint(Hex
                                            .decode("036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296")),
                            new BigInteger("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
                                    16), BigInteger.valueOf(1), Hex
                            .decode("c49d360886e704936a6678e1139d26b7819f7e90"));
    
              ECPrivateKeyParameters priv3 = new ECPrivateKeyParameters(privNum,
                      prime256v1);
              ECPublicKeyParameters pb3 = generatePublicKey (priv3 );`


    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2008
    Posts
    601
    Rep Power
    43
    It gets down-voted because ECC is not secure. A Google search will yield many results, and in light of recent revelations, you'd have to be living under a rock to miss all the problems with it.

    Best regards,
    AstroTux.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2009
    Posts
    191
    Rep Power
    50
    @Tux:

    ECC not secure?

    Any references on that?

    I think this would be something of a surprise to the cryptographic world.

    To my awareness:

    1. Dual_EC_DRBG (as standardized) is untrustable -- but its underlying concept is reasonable. A modified version (with a parameter chosen at random by the generator implementation, and using only half the bits per iteration as output) ought to be secure. The brokenness is not an inherent flaw in applying elliptic curves to cryptography.

    2. NIST standard curves could have been chosen by NSA to contain weaknesses. Non-NIST curves are available from sources we might consider more trustworthy And there is nothing to prevent someone from generating their own curves.

    3. Because the computations in ECC are more complex than those in other public key systems, there is more risk that software (or even hardware) defects could compromise security.

    Keeping the above in mind, the security case for ECC appears to be strong and well-established.

    If I got any of this wrong -- please dispute!

IMN logo majestic logo threadwatch logo seochat tools logo