本文整理汇总了C#中OpenSSL.Crypto.CryptoKey.Assign方法的典型用法代码示例。如果您正苦于以下问题:C# CryptoKey.Assign方法的具体用法?C# CryptoKey.Assign怎么用?C# CryptoKey.Assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSSL.Crypto.CryptoKey
的用法示例。
在下文中一共展示了CryptoKey.Assign方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCreateFromDH
public void CanCreateFromDH()
{
using (var dh = new DH())
{
dh.GenerateKeys();
using (var key = new CryptoKey(dh))
{
Assert.AreEqual(CryptoKey.KeyType.DH, key.Type);
Assert.AreEqual(dh.Handle, key.GetDH().Handle);
}
using (var key = new CryptoKey())
{
key.Assign(dh);
Assert.AreEqual(dh.Handle, key.GetDH().Handle);
}
}
}
示例2: CanCreateFromRSA
public void CanCreateFromRSA()
{
using (var rsa = new RSA())
{
rsa.GenerateKeys(1024, BigNumber.One, null, null);
using (var key = new CryptoKey(rsa))
{
Assert.AreEqual(CryptoKey.KeyType.RSA, key.Type);
Assert.AreEqual(rsa.Size, key.Size);
Assert.AreEqual(rsa.Handle, key.GetRSA().Handle);
}
using (var key = new CryptoKey())
{
key.Assign(rsa);
Assert.AreEqual(rsa.Handle, key.GetRSA().Handle);
}
}
}
示例3: CanCreateFromEC
public void CanCreateFromEC()
{
using (var ec = new Key())
{
using (var group = Group.FromCurveName(Objects.NID.X9_62_prime256v1))
{
ec.Group = group;
}
ec.GenerateKey();
using (var key = new CryptoKey(ec))
{
Assert.AreEqual(CryptoKey.KeyType.EC, key.Type);
Assert.AreEqual(ec.Size, key.Size);
Assert.AreEqual(ec.Handle, key.GetEC().Handle);
}
using (var key = new CryptoKey())
{
key.Assign(ec);
Assert.AreEqual(ec.Handle, key.GetEC().Handle);
}
}
}
示例4: CanCreateFromDSA
public void CanCreateFromDSA()
{
using (var dsa = new DSA(true))
{
using (var key = new CryptoKey(dsa))
{
Assert.AreEqual(CryptoKey.KeyType.DSA, key.Type);
Assert.AreEqual(dsa.Size, key.Size);
Assert.AreEqual(dsa.Handle, key.GetDSA().Handle);
}
using (var key = new CryptoKey())
{
key.Assign(dsa);
Assert.AreEqual(dsa.Handle, key.GetDSA().Handle);
}
}
using (var key = new CryptoKey(new DSA(false)))
{
Assert.AreEqual(CryptoKey.KeyType.DSA, key.Type);
}
}