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
 public EncryptionRecordInternal(EncryptionInfo info,
                                 BinaryRC4EncryptionHeader header, BinaryRC4EncryptionVerifier verifier)
 {
     this.info     = info;
     this.header   = header;
     this.verifier = verifier;
 }
 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);
 }
Beispiel #4
0
        protected internal void CreateEncryptionInfoEntry(DirectoryNode dir)
        {
            DataSpaceMapUtils.AddDefaultDataSpace(dir);
            EncryptionInfo              info     = builder.GetEncryptionInfo();
            BinaryRC4EncryptionHeader   header   = builder.GetHeader();
            BinaryRC4EncryptionVerifier verifier = builder.GetVerifier();
            EncryptionRecord            er       = new EncryptionRecordInternal(info, header, verifier);

            DataSpaceMapUtils.CreateEncryptionEntry(dir, "EncryptionInfo", er);
        }
        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);
        }