Skip to content

Commit

Permalink
updated BufferingContentSigner to use ExtendedContentSigner
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Dec 3, 2024
1 parent 053d87b commit d95afbf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,25 @@ private SignerInfoGenerator createGenerator(ContentSigner contentSigner, SignerI
}
else
{
AlgorithmIdentifier digestAlgorithmIdentifier = null;

if (contentSigner instanceof ExtendedContentSigner)
{
digester = digestProvider.get(((ExtendedContentSigner)contentSigner).getDigestAlgorithmIdentifier());
digestAlgorithmIdentifier = ((ExtendedContentSigner)contentSigner).getDigestAlgorithmIdentifier();
}

if (digestAlgorithmIdentifier == null)
{
digestAlgorithmIdentifier = digAlgFinder.find(contentSigner.getAlgorithmIdentifier());
}

if (digestAlgorithmIdentifier != null)
{
digester = digestProvider.get(digestAlgorithmIdentifier);
}
else
{
AlgorithmIdentifier digAlg = digAlgFinder.find(contentSigner.getAlgorithmIdentifier());
if (digAlg != null)
{
digester = digestProvider.get(digAlg);
}
else
{
throw new OperatorCreationException("no digest algorithm specified for signature algorithm");
}
throw new OperatorCreationException("no digest algorithm specified for signature algorithm");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* block when ready for signing.
*/
public class BufferingContentSigner
implements ContentSigner
implements ExtendedContentSigner
{
private final ContentSigner contentSigner;
private final OutputStream output;
Expand Down Expand Up @@ -67,4 +67,21 @@ public byte[] getSignature()
{
return contentSigner.getSignature();
}


/**
* Return the algorithm identifier describing the digest
* algorithm used by this signature algorithm, if known.
*
* @return algorithm oid and parameters, null otherwise.
*/
public AlgorithmIdentifier getDigestAlgorithmIdentifier()
{
if (contentSigner instanceof ExtendedContentSigner)
{
return ((ExtendedContentSigner)contentSigner).getDigestAlgorithmIdentifier();
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public interface ExtendedContentSigner
extends ContentSigner
{
/**
* Return the algorithm identifier describing the signature
* algorithm and parameters this signer generates.
* Return the algorithm identifier describing the digest algorithm used by
* this signature algorithm and parameters this signer generates.
*
* @return algorithm oid and parameters.
* @return algorithm oid and parameters, null if unknown.
*/
AlgorithmIdentifier getDigestAlgorithmIdentifier();
}

0 comments on commit d95afbf

Please sign in to comment.