Package freenet.crypt

Examples of freenet.crypt.KeyAgreementSchemeContext


    final long now = System.currentTimeMillis();
    int modulusLength = getModulusLength(negType);
        // Pre negtype 9 we were sending Ni as opposed to Ni'
        int nonceSize = getNonceSize(negType);
   
    KeyAgreementSchemeContext ctx = pn.getKeyAgreementSchemeContext();
    if(negType < 8) { // Legacy DH
        if((ctx == null) || !(ctx instanceof DiffieHellmanLightContext) || ((pn.jfkContextLifetime + DH_GENERATION_INTERVAL*DH_CONTEXT_BUFFER_SIZE) < now)) {
          pn.jfkContextLifetime = now;
          pn.setKeyAgreementSchemeContext(ctx = getLightDiffieHellmanContext());
        }
    } else {
            if((ctx == null) || !(ctx instanceof ECDHLightContext) || ((pn.jfkContextLifetime + DH_GENERATION_INTERVAL*DH_CONTEXT_BUFFER_SIZE) < now)) {
                pn.jfkContextLifetime = now;
                pn.setKeyAgreementSchemeContext(ctx = getECDHLightContext());
            }
    }
   
    int offset = 0;
    byte[] nonce = new byte[nonceSize];
    byte[] myExponential = ctx.getPublicKeyNetworkFormat();
    node.random.nextBytes(nonce);

    synchronized (pn) {
      pn.jfkNoncesSent.add(nonce);
      if(pn.jfkNoncesSent.size() > MAX_NONCES_PER_PEER)
View Full Code Here


    if(logMINOR) Logger.minor(this, "Sending a JFK(2) message to "+pn);
    int modulusLength = getModulusLength(negType);
    int nonceSize = getNonceSize(negType);
    // g^r
    // Neg type 8 and later use ECDH for generating the keys.
    KeyAgreementSchemeContext ctx = negType < 8 ? getLightDiffieHellmanContext() : getECDHLightContext();
   
    // Nr
    byte[] myNonce = new byte[nonceSize];
    node.random.nextBytes(myNonce);
    byte[] myExponential = ctx.getPublicKeyNetworkFormat();
    // Neg type 9 and later use ECDSA signature.
    byte[] sig = (negType < 9 ? ctx.dsaSig : ctx.ecdsaSig);
      if(sig.length != getSignatureLength(negType))
          throw new IllegalStateException("This shouldn't happen: please report! We are attempting to send "+sig.length+" bytes of signature in JFK2! "+pn.getPeer());
      byte[] authenticator = HMAC.macWithSHA256(getTransientKey(),assembleJFKAuthenticator(myExponential, hisExponential, myNonce, nonceInitator, replyTo.getAddress().getAddress()), HASH_LENGTH);
View Full Code Here

        byte[] nonceInitiatorHashed = (negType > 8 ? SHA256.digest(nonceInitiator) : nonceInitiator);
       
    long t1=System.currentTimeMillis();
    BlockCipher c = null;
    try { c = new Rijndael(256, 256); } catch (UnsupportedCipherException e) { throw new RuntimeException(e); }
    KeyAgreementSchemeContext ctx = pn.getKeyAgreementSchemeContext();
    if(ctx == null) return;
    byte[] ourExponential = ctx.getPublicKeyNetworkFormat();
    pn.jfkMyRef = unknownInitiator ? crypto.myCompressedHeavySetupRef() : crypto.myCompressedSetupRef();
    byte[] data = new byte[8 + 8 + pn.jfkMyRef.length];
    int ptr = 0;
    long trackerID;
    trackerID = pn.getReusableTrackerID();
View Full Code Here

  /**
  * Does the node have a live handshake in progress?
  * @param now The current time.
  */
  public boolean hasLiveHandshake(long now) {
    KeyAgreementSchemeContext c = null;
    synchronized(this) {
      c = ctx;
    }
    if(c != null && logDEBUG)
      Logger.minor(this, "Last used (handshake): " + (now - c.lastUsedTime()));
    return !((c == null) || (now - c.lastUsedTime() > Node.HANDSHAKE_TIMEOUT));
  }
View Full Code Here

TOP

Related Classes of freenet.crypt.KeyAgreementSchemeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.