sdc/crypto/scripts/generate_keys.py
def get_private_key(platform, service, purpose, key_use, version, private_key, keys_folder):
    '''
    Loads a private 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 private key
    :param private_key: The name of the private 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
    '''
    private_key_data = get_file_contents(keys_folder, private_key)

    private_key = load_pem_private_key(private_key_data.encode(), None, backend=backend)

    pub_key = private_key.public_key()

    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="private", purpose=purpose, version=version,
                      public_key=pub_bytes.decode(), private_key=private_key_data)
    return kid, key
def get_private_key(platform, service, purpose, key_use, version, private_key, keys_folder):
    '''
    Loads a private 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 private key
    :param private_key: The name of the private 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
    '''
    private_key_data = get_file_contents(keys_folder, private_key)

    private_key = load_pem_private_key(private_key_data.encode(), None, backend=backend)

    pub_key = private_key.public_key()

    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="private", purpose=purpose, version=version,
                      public_key=pub_bytes.decode(), private_key=private_key_data)
    return kid, key
def get_private_key ( platform , service , purpose , key_use , version , private_key , keys_folder ) : private_key_data = get_file_contents ( keys_folder , private_key ) private_key = load_pem_private_key ( private_key_data . encode ( ) , None , backend = backend ) pub_key = private_key . public_key ( ) 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 = "private" , purpose = purpose , version = version , public_key = pub_bytes . decode ( ) , private_key = private_key_data ) return kid , key
Loads a private 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 private key
    :param private_key: The name of the private 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
Loads a private 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 private key : param private_key : The name of the private 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