Examples of blockDecipher()


Examples of freenet.crypt.PCFBMode.blockDecipher()

          throw new Error(e);
        }
//        System.err.println("Outer key: "+HexUtil.bytesToHex(outerKey));
        cipher.initialize(outerKey);
        PCFBMode pcfb = PCFBMode.create(cipher, iv);
        pcfb.blockDecipher(dataAndHash, 0, dataAndHash.length);
//        System.err.println("Decrypted data and hash: "+HexUtil.bytesToHex(dataAndHash));
        byte[] data = Arrays.copyOf(dataAndHash, dataAndHash.length - HASH_LENGTH);
        byte[] hash = Arrays.copyOfRange(dataAndHash, data.length, dataAndHash.length);
//        System.err.println("Data: "+HexUtil.bytesToHex(data));
//        System.err.println("Hash: "+HexUtil.bytesToHex(hash));
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

            throw new Error(e);
        }
//      System.err.println("Outer key: "+HexUtil.bytesToHex(outerKey));
        cipher.initialize(outerKey);
        PCFBMode pcfb = PCFBMode.create(cipher, iv);
        pcfb.blockDecipher(dataAndHash, 0, dataAndHash.length);
//      System.err.println("Decrypted data and hash: "+HexUtil.bytesToHex(dataAndHash));
        byte[] data = Arrays.copyOf(dataAndHash, dataAndHash.length - OLD_HASH_LENGTH);
        byte[] hash = Arrays.copyOfRange(dataAndHash, data.length, dataAndHash.length);
//      System.err.println("Data: "+HexUtil.bytesToHex(data));
//      System.err.println("Hash: "+HexUtil.bytesToHex(hash));
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

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

    if(!HMAC.verifyWithSHA256(sessionKey.hmacKey, payload, hash)) return null;

    PCFBMode payloadCipher = PCFBMode.create(sessionKey.incommingCipher, IV);
    payloadCipher.blockDecipher(payload, 0, payload.length);

    NPFPacket p = NPFPacket.create(payload, pn);

    NewPacketFormatKeyContext keyContext = sessionKey.packetContext;
    synchronized(this) {
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

    PCFBMode pcfb = PCFBMode.create(authKey, buf, offset);
    // Then the hash, then the data
    // => Data starts at ivLength + digestLength
    // Decrypt the hash
    byte[] hash = Arrays.copyOfRange(buf, offset+ivLength, offset+ivLength+digestLength);
    pcfb.blockDecipher(hash, 0, hash.length);

    int dataStart = ivLength + digestLength + offset+2;

    int byte1 = ((pcfb.decipher(buf[dataStart-2])) & 0xff);
    int byte2 = ((pcfb.decipher(buf[dataStart-1])) & 0xff);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

      if(logDEBUG) Logger.debug(this, "Invalid data length "+dataLength+" ("+(length - (ivLength+hash.length+2))+") in tryProcessAuth");
      return false;
    }
    // Decrypt the data
    byte[] payload = Arrays.copyOfRange(buf, dataStart, dataStart+dataLength);
    pcfb.blockDecipher(payload, 0, payload.length);

    byte[] realHash = SHA256.digest(payload);

    if(MessageDigest.isEqual(realHash, hash)) {
      // Got one
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

    PCFBMode pcfb = PCFBMode.create(authKey, buf, offset);
    // Then the hash, then the data
    // => Data starts at ivLength + digestLength
    // Decrypt the hash
    byte[] hash = Arrays.copyOfRange(buf, offset+ivLength, offset+ivLength+digestLength);
    pcfb.blockDecipher(hash, 0, hash.length);

    int dataStart = ivLength + digestLength + offset+2;

    int byte1 = ((pcfb.decipher(buf[dataStart-2])) & 0xff);
    int byte2 = ((pcfb.decipher(buf[dataStart-1])) & 0xff);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

      if(logMINOR) Logger.minor(this, "Invalid data length "+dataLength+" ("+(length - (ivLength+hash.length+2))+") in tryProcessAuthAnon");
      return false;
    }
    // Decrypt the data
    byte[] payload = Arrays.copyOfRange(buf, dataStart, dataStart+dataLength);
    pcfb.blockDecipher(payload, 0, payload.length);

    byte[] realHash = SHA256.digest(payload);

    if(MessageDigest.isEqual(realHash, hash)) {
      // Got one
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

    PCFBMode pcfb = PCFBMode.create(authKey, buf, offset);
    // Then the hash, then the data
    // => Data starts at ivLength + digestLength
    // Decrypt the hash
    byte[] hash = Arrays.copyOfRange(buf, offset+ivLength, offset+ivLength+digestLength);
    pcfb.blockDecipher(hash, 0, hash.length);

    int dataStart = ivLength + digestLength + offset+2;

    int byte1 = ((pcfb.decipher(buf[dataStart-2])) & 0xff);
    int byte2 = ((pcfb.decipher(buf[dataStart-1])) & 0xff);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

      if(logDEBUG) Logger.debug(this, "Invalid data length "+dataLength+" ("+(length - (ivLength+hash.length+2))+") in tryProcessAuth");
      return false;
    }
    // Decrypt the data
    byte[] payload = Arrays.copyOfRange(buf, dataStart, dataStart+dataLength);
    pcfb.blockDecipher(payload, 0, payload.length);

    byte[] realHash = SHA256.digest(payload);

    if(MessageDigest.isEqual(realHash, hash)) {
      // Got one
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockDecipher()

    final PCFBMode pk = PCFBMode.create(c, decypheredPayload, decypheredPayloadOffset);
    // Get the IV
    decypheredPayloadOffset += ivLength;
    // Decrypt the payload
    pk.blockDecipher(decypheredPayload, decypheredPayloadOffset, decypheredPayload.length-decypheredPayloadOffset);
    /*
     * DecipheredData Format:
     * Signature
     * Node Data (starting with BootID)
     */
 
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.