private void rekey(byte[] key) { cipher_ctx.initialize(key); counter = new byte[allZeroString.length]; cipher_ctx.encipher(allZeroString, counter); Arrays.fill(key, (byte) 0); }
/** * Create PCFBMode object for this key */ PCFBMode makeCipher(byte[] iv, byte[] key) { byte[] iv2 = new byte[0x20]; // 256 bits System.arraycopy(salt, 0, iv2, 0, 0x10); System.arraycopy(iv, 0, iv2, 0x10, 0x10); try { BlockCipher aes = new Rijndael(256, 256); aes.initialize(key); return PCFBMode.create(aes, iv2); } catch (UnsupportedCipherException e) { Logger.error(this, "Rijndael not supported!", e); throw new Error("Rijndael not supported!", e); } }
cipher.initialize(outerKey); PCFBMode pcfb = PCFBMode.create(cipher, iv); pcfb.blockEncipher(data, hashedStart, data.length - hashedStart);
if(type.cipherName.equals("RIJNDAEL")){ blockCipher = new Rijndael(type.keyType.keySize, type.blockSize); blockCipher.initialize(key.getEncoded()); if(type == CryptByteBufferType.RijndaelPCFB){ encryptPCFB = PCFBMode.create(blockCipher, this.iv.getIV());
cipher.initialize(outerKey); PCFBMode pcfb = PCFBMode.create(cipher, iv); pcfb.blockDecipher(dataAndHash, 0, dataAndHash.length);
cipher.initialize(outerKey); PCFBMode pcfb = PCFBMode.create(cipher, iv); pcfb.blockDecipher(dataAndHash, 0, dataAndHash.length);
throw new Error(e); cipher.initialize(encKey);
if(cryptoKey.length < Node.SYMMETRIC_KEY_LENGTH) throw new CHKDecodeException("Crypto key too short"); cipher.initialize(key.cryptoKey); PCFBMode pcfb = PCFBMode.create(cipher); byte[] headers = block.headers;
throw new Error("Impossible: no Rijndael(256,128): "+e, e); cipher.initialize(masterKey); diskSalt = new byte[0x10]; cipher.encipher(newsalt, diskSalt); throw new Error("Impossible: no Rijndael(256,128): "+e, e); cipher.initialize(masterKey); salt = new byte[0x10]; cipher.decipher(diskSalt, salt);
public void testSequenceNumberEncryption() { BlockCipher ivCipher = new Rijndael(); ivCipher.initialize(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); byte[] ivNonce = new byte[16]; BlockCipher incommingCipher = new Rijndael(); incommingCipher.initialize(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); SessionKey sessionKey = new SessionKey(null, null, null, incommingCipher, null, ivCipher, ivNonce, null, null, -1); byte[] encrypted = NewPacketFormat.encryptSequenceNumber(0, sessionKey); /* This result has not been checked, but it was the output when * this test was added and we are (in this test) only * interested in making sure the output doesn't change. */ byte[] correct = new byte[] {(byte) 0xF7, (byte) 0x95, (byte) 0xBD, (byte) 0x4A}; assertTrue(Arrays.equals(correct, encrypted)); }
/** * Create the cryptographic keys etc from scratch */ public void initCrypto() { ecdsaP256 = new ECDSA(ECDSA.Curves.P256); ecdsaPubKeyHash = SHA256.digest(ecdsaP256.getPublicKey().getEncoded()); myARK = InsertableClientSSK.createRandom(random, "ark"); myARKNumber = 0; clientNonce = new byte[32]; node.random.nextBytes(clientNonce); myIdentity = new byte[IDENTITY_LENGTH]; node.random.nextBytes(myIdentity); identityHash = SHA256.digest(myIdentity); identityHashHash = SHA256.digest(identityHash); anonSetupCipher.initialize(identityHash); }
inputOffset += HASH_LENGTH; c.initialize(pn.jfkKe); int ivLength = PCFBMode.lengthIV(c); int decypheredPayloadOffset = 0; outgoingCipher.initialize(pn.outgoingKey); incommingCipher.initialize(pn.incommingKey); ivCipher.initialize(pn.ivKey);
random.nextBytes(outgoingKey); BlockCipher outgoingCipher = new Rijndael(); outgoingCipher.initialize(outgoingKey); byte[] incomingKey = new byte[32]; random.nextBytes(incomingKey); BlockCipher incomingCipher = new Rijndael(); incomingCipher.initialize(incomingKey); BlockCipher ivCipher = new Rijndael(); byte[] ivKey = new byte[32]; random.nextBytes(ivKey); ivCipher.initialize(ivKey); byte[] ivNonce = new byte[16]; random.nextBytes(ivNonce);
c.initialize(pn.jfkKe); int ivLength = PCFBMode.lengthIV(c); byte[] iv = new byte[ivLength];
anonSetupCipher.initialize(identityHash); identityHashHash = SHA256.digest(identityHash);
Logger.minor(this, "Their initial message ID: "+theirInitialMsgID+" ours "+ourInitialMsgID); c.initialize(Ke); int ivLength = PCFBMode.lengthIV(c); int decypheredPayloadOffset = 0; throw new RuntimeException(e); outgoingCipher.initialize(outgoingKey); incommingCipher.initialize(incommingKey); ivCipher.initialize(ivKey);
incomingSetupCipher.initialize(incomingSetupKey); outgoingSetupCipher = new Rijndael(256, 256); outgoingSetupCipher.initialize(outgoingSetupKey); anonymousInitiatorSetupCipher = new Rijndael(256, 256); anonymousInitiatorSetupCipher.initialize(identityHash); } catch(UnsupportedCipherException e1) { Logger.error(this, "Caught: " + e1);