Skip to content

Commit 10a1cfc

Browse files
committed
some less garbage on PEM stream (string writer) writers
1 parent c340a3b commit 10a1cfc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/main/java/org/jruby/ext/openssl/x509store/PEMInputOutput.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ public static void writeDSAPublicKey(Writer _out, DSAPublicKey obj) throws IOExc
798798
out.newLine();
799799
out.flush();
800800
}
801+
801802
/** writes an RSA public key encoded in an PKCS#1 RSA structure. */
802803
public static void writeRSAPublicKey(Writer _out, RSAPublicKey obj) throws IOException {
803804
BufferedWriter out = makeBuffered(_out);
@@ -965,17 +966,18 @@ public static void writeRSAPrivateKey(Writer _out, RSAPrivateCrtKey obj, CipherS
965966
}
966967
}
967968

968-
private static void writePemPlain(BufferedWriter out, String pemHeader, byte[] encoding) throws IOException {
969-
out.write(BEF_G + pemHeader + AFT);
969+
private static void writePemPlain(final BufferedWriter out,
970+
final String PEM_ID, final byte[] encoding) throws IOException {
971+
out.write(BEF_G); out.write(PEM_ID); out.write(AFT);
970972
out.newLine();
971973
writeEncoded(out, encoding);
972-
out.write(BEF_E + pemHeader + AFT);
974+
out.write(BEF_E); out.write(PEM_ID); out.write(AFT);
973975
out.newLine();
974976
out.flush();
975977
}
976978

977979
private static void writePemEncrypted(final BufferedWriter out,
978-
final String pemHeader, final byte[] encoding,
980+
final String PEM_ID, final byte[] encoding,
979981
final CipherSpec cipherSpec, final char[] passwd) throws IOException {
980982

981983
final Cipher cipher = cipherSpec.getCipher();
@@ -1003,16 +1005,16 @@ private static void writePemEncrypted(final BufferedWriter out,
10031005
catch (GeneralSecurityException e) {
10041006
throw new IOException("exception using cipher: "+ cipherSpec.getOsslName() + " (" + e + ")", e);
10051007
}
1006-
out.write(BEF_G + pemHeader + AFT);
1008+
out.write(BEF_G); out.write(PEM_ID); out.write(AFT);
10071009
out.newLine();
10081010
out.write("Proc-Type: 4,ENCRYPTED");
10091011
out.newLine();
1010-
out.write("DEK-Info: " + cipherSpec.getOsslName() + ",");
1012+
out.write("DEK-Info: " + cipherSpec.getOsslName() + ',');
10111013
writeHexEncoded(out, iv);
10121014
out.newLine();
10131015
out.newLine();
10141016
writeEncoded(out, encData);
1015-
out.write(BEF_E + pemHeader + AFT);
1017+
out.write(BEF_E); out.write(PEM_ID); out.write(AFT);
10161018
out.flush();
10171019
}
10181020

0 commit comments

Comments
 (0)