diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-17 12:12:38 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-17 12:12:38 +0700 |
commit | 70c9daa85c4f724aa9b8ded59f827642bf4bacc2 (patch) | |
tree | b7c36adf176bf1f6e50d27bb3a6ed21529062f8b /crypto/src/bcpg | |
parent | added DSA tests for SHA-2 (diff) | |
parent | Add support to specifying Hash Algo when adding a subkey and generating a key... (diff) | |
download | BouncyCastle.NET-ed25519-70c9daa85c4f724aa9b8ded59f827642bf4bacc2.tar.xz |
Merge branch 'keyhasing' of https://github.com/darkoperator/bc-csharp into darkoperator-keyhasing
Diffstat (limited to 'crypto/src/bcpg')
-rw-r--r-- | crypto/src/bcpg/ArmoredOutputStream.cs | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs index b3a32c6f5..02d3f72a0 100644 --- a/crypto/src/bcpg/ArmoredOutputStream.cs +++ b/crypto/src/bcpg/ArmoredOutputStream.cs @@ -313,18 +313,57 @@ namespace Org.BouncyCastle.Bcpg } } - private void WriteHeaderEntry( - string name, - string v) + protected override void Dispose(bool disposing) + { + try + { + if (type != null) + { + if (bufPtr > 0) + { + Encode(outStream, buf, bufPtr); + } + + DoWrite(nl + '='); + + int crcV = crc.Value; + + buf[0] = ((crcV >> 16) & 0xff); + buf[1] = ((crcV >> 8) & 0xff); + buf[2] = (crcV & 0xff); + + Encode(outStream, buf, 3); + + DoWrite(nl); + DoWrite(footerStart); + DoWrite(type); + DoWrite(footerTail); + DoWrite(nl); + + outStream.Flush(); + + type = null; + start = true; + } + } + finally + { + base.Dispose(disposing); + } + } + + private void WriteHeaderEntry( + string name, + string v) { DoWrite(name + ": " + v + nl); } - private void DoWrite( - string s) + private void DoWrite( + string s) { byte[] bs = Strings.ToAsciiByteArray(s); - outStream.Write(bs, 0, bs.Length); + outStream.Write(bs, 0, bs.Length); } } } |