From f98026821cb7dc9c11216eef53b8d714740aa078 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 14 Oct 2015 15:49:07 +0700 Subject: Fixed single line file handling --- .../openpgp/examples/ClearSignedFileProcessor.cs | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'crypto/test/src/openpgp/examples/ClearSignedFileProcessor.cs') diff --git a/crypto/test/src/openpgp/examples/ClearSignedFileProcessor.cs b/crypto/test/src/openpgp/examples/ClearSignedFileProcessor.cs index 14fa37269..8e4f7a3b5 100644 --- a/crypto/test/src/openpgp/examples/ClearSignedFileProcessor.cs +++ b/crypto/test/src/openpgp/examples/ClearSignedFileProcessor.cs @@ -124,6 +124,16 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Examples outStr.Write(lineSep, 0, lineSep.Length); } } + else + { + // a single line file + if (lookAhead != -1) + { + byte[] line = lineOut.ToArray(); + outStr.Write(line, 0, GetLengthWithoutSeparatorOrTrailingWhitespace(line)); + outStr.Write(lineSep, 0, lineSep.Length); + } + } outStr.Close(); @@ -333,19 +343,19 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Examples { if (args[0].Equals("-s")) { - Stream fis = File.OpenRead(args[2]); - Stream fos = File.Create(args[1] + ".asc"); + Stream fis = File.OpenRead(args[2]); + Stream fos = File.Create(args[1] + ".asc"); - Stream keyIn = PgpUtilities.GetDecoderStream(fis); + Stream keyIn = PgpUtilities.GetDecoderStream(fis); - string digestName = (args.Length == 4) - ? "SHA1" - : args[4]; + string digestName = (args.Length == 4) + ? "SHA1" + : args[4]; - SignFile(args[1], keyIn, fos, args[3].ToCharArray(), digestName); + SignFile(args[1], keyIn, fos, args[3].ToCharArray(), digestName); - fis.Close(); - fos.Close(); + fis.Close(); + fos.Close(); } else if (args[0].Equals("-v")) { -- cgit 1.5.1