commonDigestAlgorithm method

HashAlgorithm commonDigestAlgorithm(
  1. ASN1ObjectIdentifier signatureAlgorithmID
)

Implementation

HashAlgorithm commonDigestAlgorithm(
  ASN1ObjectIdentifier signatureAlgorithmID,
) {
  switch (signatureAlgorithmID.objectIdentifierAsString) {
    case sha1WithRsaSignature:
    case sha1:
      return HashAlgorithm.sha1;
    case ecdsaWithSha256:
    case sha256:
    case sha256WithRSAEncryption:
      return HashAlgorithm.sha256;
    case ecdsaWithSha384:
    case sha384:
    case sha384WithRSAEncryption:
      return HashAlgorithm.sha384;
    case ecdsaWithSha512:
    case sha512:
    case sha512WithRSAEncryption:
      return HashAlgorithm.sha512;
    case sm2WithSM3:
      return HashAlgorithm.sm3;
  }

  throw UnimplementedError(
    'Unsupported signature digest ${signatureAlgorithmID.objectIdentifierAsString}',
  );
}