def hkdf_namespace()

in fxa/crypto.py [0:0]


def hkdf_namespace(name, extra=None):
    """Construct a HKDF key namespace string from the given simple name.

    Each use of HKDF to derive keys from a master secret should use a unique
    string for the "info" parameter, to ensure that different keys are
    generated for different purposes.  This function prepends an application-
    specific URI to the given name components to generate a (hopefully)
    globally-unique info string.
    """
    if isinstance(name, str):
        name = name.encode("utf8")

    if isinstance(extra, str):
        extra = extra.encode('utf8')

    kw = SALT_NAMESPACE.encode('utf8') + name
    if extra is not None:
        kw = kw + extra
    return kw