Exemple #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);
            }
        }
 public void Initialize(EncryptionInfo info,
                        CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm,
                        int keyBits, int blockSize, ChainingMode chainingMode)
 {
     this.info = info;
     header    = new BinaryRC4EncryptionHeader();
     verifier  = new BinaryRC4EncryptionVerifier();
     decryptor = new BinaryRC4Decryptor(this);
     encryptor = new BinaryRC4Encryptor(this);
 }
        public void Initialize(EncryptionInfo info, ILittleEndianInput dis)
        {
            this.info = info;
            int vMajor = info.VersionMajor;
            int vMinor = info.VersionMinor;

            Debug.Assert(vMajor == 1 && vMinor == 1);

            header    = new BinaryRC4EncryptionHeader();
            verifier  = new BinaryRC4EncryptionVerifier(dis);
            decryptor = new BinaryRC4Decryptor(this);
            encryptor = new BinaryRC4Encryptor(this);
        }
Exemple #4
0
 protected override Cipher InitCipherForBlock(Cipher cipher, int block, bool lastChunk)
 {
     return(BinaryRC4Decryptor.InitCipherForBlock(cipher, block, builder, encryptor.GetSecretKey(), Cipher.ENCRYPT_MODE));
 }
Exemple #5
0
 protected override Cipher InitCipherForBlock(Cipher existing, int block)
 {
     return(BinaryRC4Decryptor.InitCipherForBlock(existing, block,
                                                  decryptor.builder, decryptor.GetSecretKey(), Cipher.DECRYPT_MODE));
 }