def normalize_name(name):
    """Returns a normalized version of the given algorithm name."""
    name = name.upper()
    # BouncyCastle uses X.509 with an alias of X509, Conscrypt does the
    # reverse.  X.509 is the official name of the standard, so use that.
    if name == "X509":
        name = "X.509"
    # PKCS5PADDING and PKCS7PADDING are the same thing (more accurately, PKCS#5
    # is a special case of PKCS#7), but providers are inconsistent in their
    # naming.  Use PKCS5PADDING because that's what our docs have used
    # historically.
    if name.endswith("/PKCS7PADDING"):
        name = name[:-1 * len("/PKCS7PADDING")] + "/PKCS5PADDING"
    return name