mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-10 14:21:09 +01:00
Add PGPainless.asciiArmor(PGPSignature)
This commit is contained in:
parent
dac059c702
commit
d74a8d0408
3 changed files with 64 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.pgpainless.decryption_verification.DecryptionBuilder;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
import org.pgpainless.encryption_signing.EncryptionBuilder;
|
||||
|
|
@ -27,6 +28,7 @@ import org.pgpainless.key.modification.secretkeyring.SecretKeyRingEditorInterfac
|
|||
import org.pgpainless.key.parsing.KeyRingReader;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.policy.Policy;
|
||||
import org.pgpainless.signature.SignatureUtils;
|
||||
import org.pgpainless.util.ArmorUtils;
|
||||
|
||||
public final class PGPainless {
|
||||
|
|
@ -102,6 +104,19 @@ public final class PGPainless {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the detached signature in ASCII armor.
|
||||
*
|
||||
* @param signature detached signature
|
||||
* @return ascii armored string
|
||||
*
|
||||
* @throws IOException in case of an error in the {@link ArmoredOutputStream}
|
||||
*/
|
||||
public static String asciiArmor(@Nonnull PGPSignature signature)
|
||||
throws IOException {
|
||||
return ArmorUtils.toAsciiArmoredString(signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a key of certificate in ASCII armor and write the result into the given {@link OutputStream}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -156,6 +156,38 @@ public final class ArmorUtils {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ASCII armored representation of the given detached signature.
|
||||
* The signature will not be stripped of non-exportable subpackets or trust-packets.
|
||||
* If you need to strip those (e.g. because the signature is intended to be sent to a third party), use
|
||||
* {@link #toAsciiArmoredString(PGPSignature, boolean)} and provide <pre>true</pre> as boolean value.
|
||||
*
|
||||
* @param signature signature
|
||||
* @return ascii armored string
|
||||
*
|
||||
* @throws IOException in case of an error in the {@link ArmoredOutputStream}
|
||||
*/
|
||||
@Nonnull
|
||||
public static String toAsciiArmoredString(@Nonnull PGPSignature signature) throws IOException {
|
||||
return toAsciiArmoredString(signature, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ASCII armored representation of the given detached signature.
|
||||
* If <pre>export</pre> is true, the signature will be stripped of non-exportable subpackets or trust-packets.
|
||||
* If it is <pre>false</pre>, the signature will be encoded as-is.
|
||||
*
|
||||
* @param signature signature
|
||||
* @return ascii armored string
|
||||
*
|
||||
* @throws IOException in case of an error in the {@link ArmoredOutputStream}
|
||||
*/
|
||||
@Nonnull
|
||||
public static String toAsciiArmoredString(@Nonnull PGPSignature signature, boolean export)
|
||||
throws IOException {
|
||||
return toAsciiArmoredString(signature.getEncoded(export));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ASCII armored encoding of the given OpenPGP data bytes.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue