本文整理汇总了C#中System.Security.Cryptography.DSA.ExportParameters方法的典型用法代码示例。如果您正苦于以下问题:C# DSA.ExportParameters方法的具体用法?C# DSA.ExportParameters怎么用?C# DSA.ExportParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.DSA
的用法示例。
在下文中一共展示了DSA.ExportParameters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: make_pubkey
/// <summary>
/// Create a public key block from a private key.
/// </summary>
/// <param name="privateKey">The <see cref="DSA" /> PrivateKey.</param>
/// <returns>The <see cref="DSACryptoServiceProvider" /> PublicKey.</returns>
public static DSACryptoServiceProvider make_pubkey(DSA privateKey)
{
var publicKey = new DSACryptoServiceProvider(1024);
publicKey.ImportParameters(privateKey.ExportParameters(false));
if (!publicKey.PublicOnly)
{
publicKey.Dispose();
throw new Exception("PublicKey contains PrivateKey information, cancelling.");
}
return publicKey;
}
示例2: Encode
static public byte[] Encode (DSA dsa)
{
DSAParameters param = dsa.ExportParameters (true);
return ASN1Convert.FromUnsignedBigInteger (param.X).GetBytes ();
}
示例3: ToCapiPublicKeyBlob
static public byte[] ToCapiPublicKeyBlob (DSA dsa)
{
DSAParameters p = dsa.ExportParameters (false);
int keyLength = p.P.Length; // in bytes
// header + P + Q + G + Y + count + seed
byte[] blob = new byte [16 + keyLength + 20 + keyLength + keyLength + 4 + 20];
blob [0] = 0x06; // Type - PUBLICKEYBLOB (0x06)
blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02)
// [2], [3] // RESERVED - Always 0
blob [5] = 0x22; // ALGID
blob [8] = 0x44; // Magic
blob [9] = 0x53;
blob [10] = 0x53;
blob [11] = 0x31;
byte[] bitlen = GetBytesLE (keyLength << 3);
blob [12] = bitlen [0];
blob [13] = bitlen [1];
blob [14] = bitlen [2];
blob [15] = bitlen [3];
int pos = 16;
byte[] part;
part = p.P;
Array.Reverse (part);
Buffer.BlockCopy (part, 0, blob, pos, keyLength);
pos += keyLength;
part = p.Q;
Array.Reverse (part);
Buffer.BlockCopy (part, 0, blob, pos, 20);
pos += 20;
part = p.G;
Array.Reverse (part);
Buffer.BlockCopy (part, 0, blob, pos, keyLength);
pos += keyLength;
part = p.Y;
Array.Reverse (part);
Buffer.BlockCopy (part, 0, blob, pos, keyLength);
pos += keyLength;
Buffer.BlockCopy (GetBytesLE (p.Counter), 0, blob, pos, 4);
pos += 4;
part = p.Seed;
Array.Reverse (part);
Buffer.BlockCopy (part, 0, blob, pos, 20);
return blob;
}
示例4: GetDsaPublicKey
public static DsaPublicKeyParameters GetDsaPublicKey(
DSA dsa)
{
return GetDsaPublicKey(dsa.ExportParameters(false));
}
示例5: GetDsaKeyPair
public static AsymmetricCipherKeyPair GetDsaKeyPair(
DSA dsa)
{
return GetDsaKeyPair(dsa.ExportParameters(true));
}