Ejemplo n.º 1
0
        public void ParseEncryptedBlob_parses_kwc3_blob()
        {
            var blob   = Salt32.Concat("KWC3".ToBytes()).Concat(Content).ToArray();
            var parsed = Parse.ParseEncryptedBlob(blob);

            Assert.Equal(Content, parsed.Ciphertext);
            Assert.Equal(Salt32, parsed.Salt);
            Assert.Empty(parsed.Iv);
            Assert.Empty(parsed.Hash);

            var config = parsed.CryptoConfig;

            Assert.IsType <Parse.Pbkdf2Config>(config.KdfConfig);
            Assert.Equal(Parse.CryptoConfig.CipherModeType.Cbc, config.CipherMode);
            Assert.Equal(Parse.CryptoConfig.IvGenerationModeType.EvpByteToKey, config.IvGenerationMode);
            Assert.Equal(Parse.CryptoConfig.SignatureModeType.None, config.SignatureMode);

            var pbkdf2 = (Parse.Pbkdf2Config)config.KdfConfig;

            Assert.Equal(Parse.Pbkdf2Config.HashMethodType.Sha1, pbkdf2.HashMethod);
            Assert.Equal(10204, pbkdf2.Iterations);
            Assert.Equal(32, pbkdf2.SaltLength);
            Assert.Equal("pbkdf2", pbkdf2.Name);
        }
Ejemplo n.º 2
0
        public void ParseEncryptedBlob_throws_on_unknown_encryption_type()
        {
            var blob = Salt32.Concat("blah".ToBytes()).Concat(Content).ToArray();

            Exceptions.AssertThrowsInternalError(() => Parse.ParseEncryptedBlob(blob), "Invalid blob format");
        }