mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-04 19:45:59 +01:00
Use new packet format when armoring key material
This commit is contained in:
parent
b202972042
commit
bcf8f25d21
1 changed files with 21 additions and 4 deletions
|
@ -17,6 +17,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredInputStream;
|
import org.bouncycastle.bcpg.ArmoredInputStream;
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
|
import org.bouncycastle.bcpg.BCPGOutputStream;
|
||||||
import org.bouncycastle.openpgp.PGPKeyRing;
|
import org.bouncycastle.openpgp.PGPKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
|
@ -47,22 +48,38 @@ public final class ArmorUtils {
|
||||||
|
|
||||||
public static String toAsciiArmoredString(PGPSecretKey secretKey) throws IOException {
|
public static String toAsciiArmoredString(PGPSecretKey secretKey) throws IOException {
|
||||||
MultiMap<String, String> header = keyToHeader(secretKey.getPublicKey());
|
MultiMap<String, String> header = keyToHeader(secretKey.getPublicKey());
|
||||||
return toAsciiArmoredString(secretKey.getEncoded(), header);
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
|
BCPGOutputStream bcpgOut = new BCPGOutputStream(bytes, true);
|
||||||
|
secretKey.encode(bcpgOut);
|
||||||
|
bcpgOut.close();
|
||||||
|
return toAsciiArmoredString(bytes.toByteArray(), header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toAsciiArmoredString(PGPPublicKey publicKey) throws IOException {
|
public static String toAsciiArmoredString(PGPPublicKey publicKey) throws IOException {
|
||||||
MultiMap<String, String> header = keyToHeader(publicKey);
|
MultiMap<String, String> header = keyToHeader(publicKey);
|
||||||
return toAsciiArmoredString(publicKey.getEncoded(), header);
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
|
BCPGOutputStream bcpgOut = new BCPGOutputStream(bytes, true);
|
||||||
|
publicKey.encode(bcpgOut);
|
||||||
|
bcpgOut.close();
|
||||||
|
return toAsciiArmoredString(bytes.toByteArray(), header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toAsciiArmoredString(PGPSecretKeyRing secretKeys) throws IOException {
|
public static String toAsciiArmoredString(PGPSecretKeyRing secretKeys) throws IOException {
|
||||||
MultiMap<String, String> header = keysToHeader(secretKeys);
|
MultiMap<String, String> header = keysToHeader(secretKeys);
|
||||||
return toAsciiArmoredString(secretKeys.getEncoded(), header);
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
|
BCPGOutputStream bcpgOut = new BCPGOutputStream(bytes, true);
|
||||||
|
secretKeys.encode(bcpgOut);
|
||||||
|
bcpgOut.close();
|
||||||
|
return toAsciiArmoredString(bytes.toByteArray(), header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toAsciiArmoredString(PGPPublicKeyRing publicKeys) throws IOException {
|
public static String toAsciiArmoredString(PGPPublicKeyRing publicKeys) throws IOException {
|
||||||
MultiMap<String, String> header = keysToHeader(publicKeys);
|
MultiMap<String, String> header = keysToHeader(publicKeys);
|
||||||
return toAsciiArmoredString(publicKeys.getEncoded(), header);
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
|
BCPGOutputStream bcpgOut = new BCPGOutputStream(bytes, true);
|
||||||
|
publicKeys.encode(bcpgOut);
|
||||||
|
bcpgOut.close();
|
||||||
|
return toAsciiArmoredString(bytes.toByteArray(), header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toAsciiArmoredString(PGPSecretKeyRingCollection secretKeyRings) throws IOException {
|
public static String toAsciiArmoredString(PGPSecretKeyRingCollection secretKeyRings) throws IOException {
|
||||||
|
|
Loading…
Reference in a new issue