本文整理汇总了C#中Org.BouncyCastle.Bcpg.BcpgOutputStream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# BcpgOutputStream.Write方法的具体用法?C# BcpgOutputStream.Write怎么用?C# BcpgOutputStream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Org.BouncyCastle.Bcpg.BcpgOutputStream
的用法示例。
在下文中一共展示了BcpgOutputStream.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encode
internal static void Encode(
BcpgOutputStream bcpgOut,
BigInteger val)
{
bcpgOut.WriteShort((short) val.BitLength);
bcpgOut.Write(val.ToByteArrayUnsigned());
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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);
}
示例5: 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);
}
}
示例6: 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);
}
示例7: Encode
public override void Encode(IBcpgOutputStream bcpgOut)
{
using (var bOut = new MemoryStream())
{
using (var pOut = new BcpgOutputStream(bOut))
{
pOut.WriteByte((byte)_version);
pOut.WriteLong(_keyId);
pOut.WriteByte((byte)_algorithm);
for (var i = 0; i != _data.Length; i++)
{
MPInteger.EncodeInteger(pOut, _data[i]);
}
if (_extraData != null)
{
if (_extraData.Length > 0xFF)
throw new PgpException("Extra Data is too large.");
pOut.WriteByte((byte)_extraData.Length);
pOut.Write(_extraData, 0, _extraData.Length);
}
bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, bOut.ToArray(), true);
}
}
}
示例8: EncodeLengthAndData
private static void EncodeLengthAndData(
BcpgOutputStream pOut,
byte[] data)
{
pOut.WriteShort((short) data.Length);
pOut.Write(data);
}
示例9: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.WriteByte((byte) version);
if (version == 3 || version == 2)
{
pOut.Write(
5, // the length of the next block
(byte) signatureType);
pOut.WriteInt((int)(creationTime / 1000L));
pOut.WriteLong(keyId);
pOut.Write(
(byte) keyAlgorithm,
(byte) hashAlgorithm);
}
else if (version == 4)
{
pOut.Write(
(byte) signatureType,
(byte) keyAlgorithm,
(byte) hashAlgorithm);
EncodeLengthAndData(pOut, GetEncodedSubpackets(hashedData));
EncodeLengthAndData(pOut, GetEncodedSubpackets(unhashedData));
}
else
{
throw new IOException("unknown version: " + version);
}
pOut.Write(fingerprint);
if (signature != null)
{
pOut.WriteObjects(signature);
}
else
{
pOut.Write(signatureEncoding);
}
bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
}
示例10: GetEncodedContents
public byte[] GetEncodedContents()
{
MemoryStream bOut = new MemoryStream();
BcpgOutputStream pOut = new BcpgOutputStream(bOut);
pOut.Write(pubKeyPacket.GetEncodedContents());
pOut.WriteByte((byte) s2kUsage);
if (s2kUsage == UsageChecksum || s2kUsage == UsageSha1)
{
pOut.WriteByte((byte) encAlgorithm);
pOut.WriteObject(s2k);
}
if (iv != null)
{
pOut.Write(iv);
}
if (secKeyData != null && secKeyData.Length > 0)
{
pOut.Write(secKeyData);
}
return bOut.ToArray();
}
示例11: 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)
{
pOut.Write(data[i]);
}
Platform.Dispose(pOut);
bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession , bOut.ToArray(), true);
}
示例12: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
bcpgOut.WriteByte((byte) type);
bcpgOut.WriteByte((byte) algorithm);
if (type != GnuDummyS2K)
{
if (type != 0)
{
bcpgOut.Write(iv);
}
if (type == 3)
{
bcpgOut.WriteByte((byte) itCount);
}
}
else
{
bcpgOut.WriteByte((byte) 'G');
bcpgOut.WriteByte((byte) 'N');
bcpgOut.WriteByte((byte) 'U');
bcpgOut.WriteByte((byte) protectionMode);
}
}
示例13: Encode
public override void Encode(
BcpgOutputStream bcpgOut)
{
bcpgOut.WriteShort((short) val.BitLength);
bcpgOut.Write(val.ToByteArrayUnsigned());
}
示例14: Encode
/// <summary>
/// Encodes this instance to the given stream.
/// </summary>
/// <param name="bcpgOut">The BCPG out.</param>
public override void Encode(IBcpgOutputStream bcpgOut)
{
using (var bOut = new MemoryStream())
{
using (var 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);
}
}
}
示例15: Encode
public override void Encode(IBcpgOutputStream bcpgOut)
{
using (var bOut = new MemoryStream())
{
using (var pOut = new BcpgOutputStream(bOut))
{
pOut.WriteByte((byte)_version);
switch (_version)
{
case 2:
case 3:
pOut.Write(
5, // the length of the next block
(byte)_signatureType);
pOut.WriteInt((int)(CreationTime / 1000L));
pOut.WriteLong(_keyId);
pOut.Write(
(byte)_keyAlgorithm,
(byte)_hashAlgorithm);
break;
case 4:
pOut.Write(
(byte)_signatureType,
(byte)_keyAlgorithm,
(byte)_hashAlgorithm);
EncodeLengthAndData(pOut, GetEncodedSubpackets(_hashedData));
EncodeLengthAndData(pOut, GetEncodedSubpackets(_unhashedData));
break;
default:
throw new IOException("unknown version: " + _version);
}
pOut.Write(_fingerprint);
if (_signature != null)
{
pOut.WriteObjects(_signature);
}
else
{
pOut.Write(_signatureEncoding);
}
bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
}
}
}