Skip to content

Commit

Permalink
reverted PGPUtil inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Mar 27, 2024
1 parent 68d6e77 commit 72081fd
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions pg/src/main/java/org/bouncycastle/bcpg/ArmoredOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import java.util.List;
import java.util.Map;

import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.util.Strings;

/**
Expand Down Expand Up @@ -301,15 +299,51 @@ public void beginClearText(
sb.append(nl);
for (int hashAlgorithm : hashAlgorithms)
{
try
{
String hash = PGPUtil.getDigestName(hashAlgorithm);
sb.append(HASH_HDR).append(": ").append(hash).append(nl);
}
catch (PGPException e)
String hash;
switch (hashAlgorithm)
{
case HashAlgorithmTags.MD5:
hash = "MD5";
break;
case HashAlgorithmTags.SHA1:
hash = "SHA1";
break;
case HashAlgorithmTags.RIPEMD160:
hash = "RIPEMD160";
break;
case HashAlgorithmTags.MD2:
hash = "MD2";
break;
case HashAlgorithmTags.SHA256:
hash = "SHA256";
break;
case HashAlgorithmTags.SHA384:
hash = "SHA384";
break;
case HashAlgorithmTags.SHA512:
hash = "SHA512";
break;
case HashAlgorithmTags.SHA224:
hash = "SHA224";
break;
case HashAlgorithmTags.SHA3_256:
case HashAlgorithmTags.SHA3_256_OLD:
hash = "SHA3-256";
break;
case HashAlgorithmTags.SHA3_384: // OLD
hash = "SHA3-384";
break;
case HashAlgorithmTags.SHA3_512:
case HashAlgorithmTags.SHA3_512_OLD:
hash = "SHA3-512";
break;
case HashAlgorithmTags.SHA3_224:
hash = "SHA3-224";
break;
default:
throw new IOException("unknown hash algorithm tag in beginClearText: " + hashAlgorithm);
}
sb.append(HASH_HDR).append(": ").append(hash).append(nl);
}
sb.append(nl);

Expand Down

0 comments on commit 72081fd

Please sign in to comment.