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()); }
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); }
internal static void Encode( BcpgOutputStream bcpgOut, BigInteger val) { bcpgOut.WriteShort((short)val.BitLength); bcpgOut.Write(val.ToByteArrayUnsigned()); }
private static void EncodeLengthAndData( BcpgOutputStream pOut, byte[] data) { pOut.WriteShort((short)data.Length); pOut.Write(data); }
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); } }
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); }
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); }
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); }
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); }
public override void Encode( BcpgOutputStream bcpgOut) { bcpgOut.WriteShort((short)val.BitLength); bcpgOut.Write(val.ToByteArrayUnsigned()); }