Package freenet.crypt

Examples of freenet.crypt.CTRBlockCipher


    } catch (UnsupportedCipherException e) {
      // Impossible.
      throw new Error(e);
    }
    aes.initialize(cryptoKey);
        CTRBlockCipher cipher = new CTRBlockCipher(aes);
        cipher.init(hash, 0, 16);
        byte[] plaintext = new byte[data.length];
        cipher.processBytes(data, 0, data.length, plaintext, 0);
        byte[] lengthBytes = new byte[2];
        cipher.processBytes(headers, hash.length+2, 2, lengthBytes, 0);
        int size = ((lengthBytes[0] & 0xff) << 8) + (lengthBytes[1] & 0xff);
        if((size > 32768) || (size < 0)) {
            throw new CHKDecodeException("Invalid size: "+size);
        }
    try {
View Full Code Here


    } catch (UnsupportedCipherException e) {
      // Impossible
      throw new Error(e);
    }
        aes.initialize(encKey);
        CTRBlockCipher ctr = new CTRBlockCipher(aes);
        // CTR mode IV is only 16 bytes.
        // That's still plenty though. It will still be unique.
        ctr.init(hash, 0, 16);
        System.arraycopy(hash, 0, header, 2, hash.length);
        byte[] cdata = new byte[data.length];
        ctr.processBytes(data, 0, data.length, cdata, 0);
        ctr.processBytes(tmpLen, 0, 2, header, hash.length+2);
       
        // Now calculate the final hash
        md256.update(header);
        byte[] finalHash = md256.digest(cdata);
       
View Full Code Here

TOP

Related Classes of freenet.crypt.CTRBlockCipher

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.