本文整理汇总了C#中Org.BouncyCastle.Bcpg.BcpgOutputStream类的典型用法代码示例。如果您正苦于以下问题:C# BcpgOutputStream类的具体用法?C# BcpgOutputStream怎么用?C# BcpgOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BcpgOutputStream类属于Org.BouncyCastle.Bcpg命名空间,在下文中一共展示了BcpgOutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encode
internal static void Encode(
BcpgOutputStream bcpgOut,
BigInteger val)
{
bcpgOut.WriteShort((short) val.BitLength);
bcpgOut.Write(val.ToByteArrayUnsigned());
}
示例2: OutputStreamPacket
internal OutputStreamPacket(
BcpgOutputStream bcpgOut)
{
if (bcpgOut == null)
throw new ArgumentNullException("bcpgOut");
this.bcpgOut = bcpgOut;
}
示例3: GetEncoded
public virtual byte[] GetEncoded()
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.WriteObject(this);
return bOut.ToArray();
}
示例4: GetEncoded
public byte[] GetEncoded()
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.WritePacket(this);
return bOut.ToArray();
}
示例5: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
byte[] oid = this.oid.GetEncoded();
bcpgOut.Write(oid, 1, oid.Length - 1);
MPInteger point = new MPInteger(this.point);
bcpgOut.WriteObject(point);
}
示例6: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
base.Encode(bcpgOut);
bcpgOut.WriteByte(0x3);
bcpgOut.WriteByte(reserved);
bcpgOut.WriteByte(hashFunctionId);
bcpgOut.WriteByte(symAlgorithmId);
}
示例7: GetEncoded
/// <summary>
/// Gets the encoded version of this instance.
/// </summary>
/// <returns></returns>
public byte[] GetEncoded()
{
using (var bOut = new MemoryStream())
{
using (var pOut = new BcpgOutputStream(bOut))
{
pOut.WritePacket(this);
return bOut.ToArray();
}
}
}
示例8: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
MemoryStream bOut = new MemoryStream();
for (int i = 0; i != subpackets.Length; i++)
{
subpackets[i].Encode(bOut);
}
bcpgOut.WritePacket(PacketTag.UserAttribute, bOut.ToArray(), false);
}
示例9: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.Write(
(byte) version,
(byte) sigType,
(byte) hashAlgorithm,
(byte) keyAlgorithm);
pOut.WriteLong(keyId);
pOut.WriteByte((byte) nested);
bcpgOut.WritePacket(PacketTag.OnePassSignature, bOut.ToArray(), true);
}
示例10: GetEncoded
public byte[] GetEncoded()
{
try
{
using (var bOut = new MemoryStream())
{
using (var pOut = new BcpgOutputStream(bOut))
{
pOut.WriteObject(this);
return bOut.ToArray();
}
}
}
catch (Exception)
{
return null;
}
}
示例11: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.Write(
(byte) version,
(byte) encAlgorithm);
pOut.WriteObject(s2k);
if (secKeyData != null && secKeyData.Length > 0)
{
pOut.Write(secKeyData);
}
bcpgOut.WritePacket(PacketTag.SymmetricKeyEncryptedSessionKey, bOut.ToArray(), true);
}
示例12: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.WriteByte((byte) version);
pOut.WriteLong(keyId);
pOut.WriteByte((byte)algorithm);
for (int i = 0; i != data.Length; i++)
{
MPInteger.Encode(pOut, data[i]);
}
bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession , bOut.ToArray(), true);
}
示例13: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
int length = val.BitLength;
bcpgOut.WriteByte((byte) (length >> 8));
bcpgOut.WriteByte((byte) length);
byte[] bytes = val.ToByteArray();
if (bytes[0] == 0)
{
bcpgOut.Write(bytes, 1, bytes.Length - 1);
}
else
{
bcpgOut.Write(bytes);
}
}
示例14: SignFile
public static void SignFile(Stream input, Stream outputStream, Stream keyIn, char[] pass)
{
var secretKey = ReadSecretKey(keyIn);
var privateKey = secretKey.ExtractPrivateKey(pass);
var signatureGenerator = new PgpSignatureGenerator(secretKey.PublicKey.Algorithm, HashAlgorithmTag.Sha1);
var subpacketGenerator = new PgpSignatureSubpacketGenerator();
signatureGenerator.InitSign(PgpSignature.CanonicalTextDocument, privateKey);
foreach (string userId in secretKey.PublicKey.GetUserIds())
{
var signatureSubpacketGenerator = new PgpSignatureSubpacketGenerator();
signatureSubpacketGenerator.SetSignerUserId(isCritical: false, userId: userId);
signatureGenerator.SetHashedSubpackets(signatureSubpacketGenerator.Generate());
// Just the first one!
break;
}
// Closing armouredOutputStream does not close the underlying stream
var armouredOutputStream = new ArmoredOutputStream(outputStream);
using (var bcpgOutputStream = new BcpgOutputStream(armouredOutputStream))
{
armouredOutputStream.BeginClearText(HashAlgorithmTag.Sha1);
int chr;
while ((chr = input.ReadByte()) > 0)
{
signatureGenerator.Update((byte)chr);
bcpgOutputStream.Write((byte)chr);
}
// For some reason we need to add a trailing newline
bcpgOutputStream.Write((byte)'\n');
armouredOutputStream.EndClearText();
signatureGenerator.Generate().Encode(bcpgOutputStream);
}
}
示例15: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
bcpgOut.WriteObjects(d, p, q, u);
}