Skip to content

Simplify public key extraction #14

@stveit

Description

@stveit

I think its possible to replace this:

def get_public_key(key):
    """Returns public key for a RSAKey object"""
    public_key = key.get_public_key().public_bytes(
        encoding=crypto_serialization.Encoding.PEM,
        format= crypto_serialization.PublicFormat.SubjectPublicKeyInfo,
    ).decode("utf-8")
    return public_key

with this:

def get_public_key(key):
    """Returns public key for a RSAKey object"""
    public_key = key.as_bytes(is_private=False).decode("utf-8")
    return public_key

based on this working to extract private key in PEM format from a RSAKey object with:

private_key.as_bytes(is_private=True).decode("utf-8")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions