Examples of encipher()


Examples of freenet.crypt.BlockCipher.encipher()

    IV[IV.length - 4] = (byte) (sequenceNumber >>> 24);
    IV[IV.length - 3] = (byte) (sequenceNumber >>> 16);
    IV[IV.length - 2] = (byte) (sequenceNumber >>> 8);
    IV[IV.length - 1] = (byte) (sequenceNumber);

    ivCipher.encipher(IV, IV);

    byte[] payload = Arrays.copyOfRange(buf, offset + hmacLength, offset + length);
    byte[] hash = Arrays.copyOfRange(buf, offset, offset + hmacLength);

    if(!HMAC.verifyWithSHA256(sessionKey.hmacKey, payload, hash)) return null;
View Full Code Here

Examples of freenet.crypt.BlockCipher.encipher()

    BlockCipher ivCipher = sessionKey.ivCipher;

    byte[] IV = new byte[ivCipher.getBlockSize() / 8];
    System.arraycopy(sessionKey.ivNonce, 0, IV, 0, IV.length);
    System.arraycopy(seqNumBytes, 0, IV, IV.length - seqNumBytes.length, seqNumBytes.length);
    ivCipher.encipher(IV, IV);

    PCFBMode cipher = PCFBMode.create(sessionKey.incommingCipher, IV);
    cipher.blockEncipher(seqNumBytes, 0, seqNumBytes.length);

    return seqNumBytes;
View Full Code Here

Examples of freenet.crypt.BlockCipher.encipher()

    byte[] IV = new byte[ivCipher.getBlockSize() / 8];
    System.arraycopy(sessionKey.ivNonce, 0, IV, 0, IV.length);
    System.arraycopy(data, hmacLength, IV, IV.length - 4, 4);

    ivCipher.encipher(IV, IV);

    PCFBMode payloadCipher = PCFBMode.create(sessionKey.outgoingCipher, IV);
    payloadCipher.blockEncipher(data, hmacLength, paddedLen - hmacLength);

    //Add hash
View Full Code Here

Examples of freenet.crypt.BlockCipher.encipher()

        } catch (UnsupportedCipherException e) {
          throw new Error("Impossible: no Rijndael(256,128): "+e, e);
        }
        cipher.initialize(masterKey);
        diskSalt = new byte[0x10];
        cipher.encipher(newsalt, diskSalt);
        if(logDEBUG)
          Logger.debug(this, "Encrypting with "+HexUtil.bytesToHex(newsalt)+" from "+HexUtil.bytesToHex(diskSalt));
      }
      cipherManager = new CipherManager(newsalt, diskSalt);
View Full Code Here

Examples of freenet.crypt.PCFBMode.encipher()

    PCFBMode pcfb = PCFBMode.create(cipher, iv);
    System.arraycopy(iv, 0, data, 0, iv.length);
    pcfb.blockEncipher(hash, 0, hash.length);
    System.arraycopy(hash, 0, data, iv.length, hash.length);
    if(logMINOR) Logger.minor(this, "Payload length: "+length+" padded length "+data.length);
    data[hash.length+iv.length] = (byte) pcfb.encipher((byte)(length>>8));
    data[hash.length+iv.length+1] = (byte) pcfb.encipher((byte)length);
    pcfb.blockEncipher(output, 0, output.length);
    System.arraycopy(output, 0, data, hash.length+iv.length+2, output.length);

    Util.randomBytes(node.fastWeakRandom, data, hash.length+iv.length+2+output.length, paddingLength);
View Full Code Here

Examples of freenet.crypt.PCFBMode.encipher()

    System.arraycopy(iv, 0, data, 0, iv.length);
    pcfb.blockEncipher(hash, 0, hash.length);
    System.arraycopy(hash, 0, data, iv.length, hash.length);
    if(logMINOR) Logger.minor(this, "Payload length: "+length+" padded length "+data.length);
    data[hash.length+iv.length] = (byte) pcfb.encipher((byte)(length>>8));
    data[hash.length+iv.length+1] = (byte) pcfb.encipher((byte)length);
    pcfb.blockEncipher(output, 0, output.length);
    System.arraycopy(output, 0, data, hash.length+iv.length+2, output.length);

    Util.randomBytes(node.fastWeakRandom, data, hash.length+iv.length+2+output.length, paddingLength);
    try {
View Full Code Here

Examples of freenet.crypt.ciphers.Rijndael.encipher()

      }
      byte[] buf = md.digest();
      try {
        Rijndael aes = new Rijndael(256, 256);
        aes.initialize(cryptoKey);
        aes.encipher(buf, buf);
        ehDocname = buf;
      } catch (UnsupportedCipherException e) {
        throw new Error(e);
      }
    } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.