mirror of
https://codeberg.org/PGPainless/bc-sop.git
synced 2025-09-09 03:09:40 +02:00
Fix idempotent ASCII armor operations
This commit is contained in:
parent
43fdac4ac5
commit
1e6782166f
2 changed files with 8 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
||||||
package org.pgpainless.bouncycastle.sop.operation;
|
package org.pgpainless.bouncycastle.sop.operation;
|
||||||
|
|
||||||
|
import org.bouncycastle.bcpg.ArmoredInputStream;
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
|
import org.bouncycastle.openpgp.PGPUtil;
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPApi;
|
import org.bouncycastle.openpgp.api.OpenPGPApi;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -26,10 +28,11 @@ public class BCArmor
|
||||||
return new Ready() {
|
return new Ready() {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(@NotNull OutputStream outputStream) throws IOException {
|
public void writeTo(@NotNull OutputStream outputStream) throws IOException {
|
||||||
|
InputStream decodeIn = PGPUtil.getDecoderStream(inputStream);
|
||||||
ArmoredOutputStream aOut = ArmoredOutputStream.builder()
|
ArmoredOutputStream aOut = ArmoredOutputStream.builder()
|
||||||
.clearHeaders()
|
.clearHeaders()
|
||||||
.build(outputStream);
|
.build(outputStream);
|
||||||
Streams.pipeAll(inputStream, aOut);
|
Streams.pipeAll(decodeIn, aOut);
|
||||||
aOut.close();
|
aOut.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.pgpainless.bouncycastle.sop.operation;
|
package org.pgpainless.bouncycastle.sop.operation;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredInputStream;
|
import org.bouncycastle.openpgp.PGPUtil;
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPApi;
|
import org.bouncycastle.openpgp.api.OpenPGPApi;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -26,9 +26,9 @@ public class BCDearmor
|
||||||
return new Ready() {
|
return new Ready() {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(@NotNull OutputStream outputStream) throws IOException {
|
public void writeTo(@NotNull OutputStream outputStream) throws IOException {
|
||||||
ArmoredInputStream aIn = new ArmoredInputStream(inputStream);
|
InputStream decodeIn = PGPUtil.getDecoderStream(inputStream);
|
||||||
Streams.pipeAll(aIn, outputStream);
|
Streams.pipeAll(decodeIn, outputStream);
|
||||||
aIn.close();
|
decodeIn.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue