sdc/crypto/scripts/generate_keys.py
def get_public_key(platform, service, purpose, key_use, version, public_key, keys_folder):
    '''
    Loads a public key from the file system and adds it to a dict of keys
    :param keys: A dict of keys
    :param platform the platform the key is for
    :param service the service the key is for
    :param key_use what the key is used for
    :param version the version of the key
    :param purpose: The purpose of the public key
    :param public_key: The name of the public key to add
    :param keys_folder: The location on disk where the key exists
    :param kid_override: This allows the caller to override the generated KID value
    :return: None
    '''
    public_key_data = get_file_contents(keys_folder, public_key)

    pub_key = load_pem_public_key(public_key_data.encode(), backend=backend)
    pub_bytes = pub_key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo)

    kid = _generate_kid_from_key(pub_bytes.decode())

    key = _create_key(platform=platform, service=service, key_use=key_use,
                      key_type="public", purpose=purpose, version=version,
                      public_key=public_key_data)
    return kid, key
def get_public_key(platform, service, purpose, key_use, version, public_key, keys_folder):
    '''
    Loads a public key from the file system and adds it to a dict of keys
    :param keys: A dict of keys
    :param platform the platform the key is for
    :param service the service the key is for
    :param key_use what the key is used for
    :param version the version of the key
    :param purpose: The purpose of the public key
    :param public_key: The name of the public key to add
    :param keys_folder: The location on disk where the key exists
    :param kid_override: This allows the caller to override the generated KID value
    :return: None
    '''
    public_key_data = get_file_contents(keys_folder, public_key)

    pub_key = load_pem_public_key(public_key_data.encode(), backend=backend)
    pub_bytes = pub_key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo)

    kid = _generate_kid_from_key(pub_bytes.decode())

    key = _create_key(platform=platform, service=service, key_use=key_use,
                      key_type="public", purpose=purpose, version=version,
                      public_key=public_key_data)
    return kid, key
Loads a public key from the file system and adds it to a dict of keys
    :param keys: A dict of keys
    :param platform the platform the key is for
    :param service the service the key is for
    :param key_use what the key is used for
    :param version the version of the key
    :param purpose: The purpose of the public key
    :param public_key: The name of the public key to add
    :param keys_folder: The location on disk where the key exists
    :param kid_override: This allows the caller to override the generated KID value
    :return: None