Beispiel #1
0
        public override void ConfirmPassword(String password, byte[] keySpec,
                                             byte[] keySalt, byte[] verifier, byte[] verifierSalt,
                                             byte[] integritySalt)
        {
            BinaryRC4EncryptionVerifier ver = builder.GetVerifier();

            ver.SetSalt(verifierSalt);
            ISecretKey skey = BinaryRC4Decryptor.GenerateSecretKey(password, ver);

            SetSecretKey(skey);
            try
            {
                Cipher cipher            = BinaryRC4Decryptor.InitCipherForBlock(null, 0, builder, skey, Cipher.ENCRYPT_MODE);
                byte[] encryptedVerifier = new byte[16];
                cipher.Update(verifier, 0, 16, encryptedVerifier);
                ver.EncryptedVerifier = (encryptedVerifier);
                HashAlgorithm hashAlgo              = ver.HashAlgorithm;
                MessageDigest hashAlg               = CryptoFunctions.GetMessageDigest(hashAlgo);
                byte[]        calcVerifierHash      = hashAlg.Digest(verifier);
                byte[]        encryptedVerifierHash = cipher.DoFinal(calcVerifierHash);
                ver.EncryptedVerifierHash = (encryptedVerifierHash);
            }
            catch (Exception e)
            {
                throw new EncryptedDocumentException("Password Confirmation failed", e);
            }
        }
Beispiel #2
0
 protected override Cipher InitCipherForBlock(Cipher cipher, int block, bool lastChunk)
 {
     return(BinaryRC4Decryptor.InitCipherForBlock(cipher, block, builder, encryptor.GetSecretKey(), Cipher.ENCRYPT_MODE));
 }
Beispiel #3
0
 protected override Cipher InitCipherForBlock(Cipher existing, int block)
 {
     return(BinaryRC4Decryptor.InitCipherForBlock(existing, block,
                                                  decryptor.builder, decryptor.GetSecretKey(), Cipher.DECRYPT_MODE));
 }