示例#1
0
        public void SnPublicKeyIsReturnedAsIs()
        {
            var key = ImmutableArray.Create(TestResources.General.snPublicKey);

            ImmutableArray <byte> pubKey;

            Assert.True(CryptoBlobParser.TryParseKey(key, out pubKey, out _));
            Assert.True(CryptoBlobParser.IsValidPublicKey(pubKey));
            AssertEx.Equal(key, pubKey);
        }
示例#2
0
        public void GetPublicKeyFromKeyPair2()
        {
            var key = ImmutableArray.Create(TestResources.General.snKey2);

            ImmutableArray <byte> pubKey;

            Assert.True(CryptoBlobParser.TryParseKey(key, out pubKey, out _));
            Assert.True(CryptoBlobParser.IsValidPublicKey(pubKey));
            AssertEx.Equal(TestResources.General.snPublicKey2, pubKey);
        }
示例#3
0
        public void GetSnPublicKeyFromPublicKeyBlob()
        {
            // An Strongname public key blob includes an additional header on top
            // of the wincrypt.h public key blob
            var snBlob = TestResources.General.snPublicKey;

            var buf = new byte[snBlob.Length - CryptoBlobParser.s_publicKeyHeaderSize];

            Array.Copy(snBlob, CryptoBlobParser.s_publicKeyHeaderSize, buf, 0, buf.Length);

            var publicKeyBlob = ImmutableArray.Create(buf);

            ImmutableArray <byte> pubKey;

            Assert.True(CryptoBlobParser.TryParseKey(publicKeyBlob, out pubKey, out _));
            Assert.True(CryptoBlobParser.IsValidPublicKey(pubKey));
            AssertEx.Equal(snBlob, pubKey);
        }