How to use the sshpubkeys.exceptions.InvalidKeyLengthError function in sshpubkeys

To help you get started, we’ve selected a few sshpubkeys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ojarva / python-sshpubkeys / tests / invalid_keys.py View on Github external
],
    ["", InvalidKeyError, "empty_key", ["loose", "strict"]],
    ["- -", InvalidKeyError, "no_content", ["loose", "strict"]],
    [
        "ssh-invalid-key-type AAAAFHNzaC1pbnZhbGlkLWtleS10eXBlAAAAgMEgAGDgAKEBAMAgoECggSCAQIEAoIAhASEhAKDAAOAAwGCBIKAAYGCgYKDhAEBAwICAoIDgIADAYKAAYGAAYAEgwGBBIGDhIOBg4CAAoQDAIEAgIEEggEDgQGCAIGAhAQDgoKAhIAAggSBA4CBggOEBIEDgoMDAwKBg4MDAYIDgAAAAIAAAAAAAAAAAAAAAAIAggEEggSBAIIBgAMDAQADAIQEgAAAAgJAQABBgICBQUABQcFAAcJBgUIAAIHAAkJBQEIAQMEAgIHBQEFCAUBBQUHAQMGBgQBCAEEAgICBQYDBwIJBAYFCQYDBwIAAQIHCQMEBwYCBAICAAEFBQAHAgAIBQAJBwgEBwYGCAEHBgkBAwEBAQcHAQMGCQMCBQIABAUJAgEIAgAAAAgIGAAYIDgoSBA4ABAgAEAIEEAoEAg4IDAgQCAwCDgQMAgQABgoGAAgMCgoOCA4QABAGBAQQDgoKABASBhAQDgoIBgIQEgAQEAQSBg4IEBICEggKBAAABgYKDAgGDgYAAgoGCAoODgYGEAwIBAoACgQADBAGDgASCgQMDgAABAISA",
        NotImplementedError, "not_implemented_key_type", ["loose", "strict"]
    ],

    # 512 bit ed25519 keys are not yet supported by OpenSSH
    [
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAQIMcGCUjHYKD/rfvSGiNSB1ij8hScTB7e1bo3XK2oaGGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
        InvalidKeyLengthError, "512bit_ed25519", ["loose", "strict"]
    ],
    [
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAQIBBAIDAICBAgEABACAggGCgAABAwOEAwGBAgEEg4SBAAKBBIGEAgSEgAIEgoMCgICAgYMCgYQDgoKBgIIDgwCA=",
        InvalidKeyLengthError, "512bit_ed25519", ["loose", "strict"]
    ],
    [
        'command="dump /home,no-pty,no-port-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABADR9kolU4uiD26LMrbakQlNf4QWB2xrdY3nASf6CJdQYzTMjNmbt6sJ4A4pGnCupFrzL04EYDvbVmT4GEZm6CU4BsY61yosnpGSqqcVCdw5xW1k4bCSDPW75WHLCVmYyROhZ+yyo8uAcIy5UIyBZXF/PO7taJrrIi5RwdqIPwtCrJ3dJkcFWa3qZWJykLAFQD5A/lta/egS/u/nyCap2e16WGnvSluz9CyYtGFNS9axzOwHxLFEv2ocOsJjYgzV+Jfpiao94A4VzLKbUDHlfV57KS0tJaT8FKKsg34vN3bsD0zUftLUPpUFgJfMwje0C2rCJkCzwgya2vxLqj2fg0Q0= ojarva@ojar-laptop.local',
        MalformedDataError, "missing_quote", ["loose", "strict"]
    ],
    [
        'ssh-dss AAAAB3NzaC1kc3MAAAEBAM4SvSD+Gpu4L5TvkroBbAcVPeQID1gdZTpr5fEuOCwTVxMyuPwfHH6txh4Nq0K7MRee5zuVKHNkxj84EMF/+g4eJISmE87wzfYNJQhGNOmXO3yYGCmFaDgrlsWH9OhGglWTxz768gJy4IUP2hqvsbotdpjhRvTFCIep12r4L16rFQJeVVti6Xml3UZHXvoMbwJC+BulwU8hnosXvH4mYikgoaSmDUfJkkLB1nD/g48vo172iu2mfEYqAbn9lX46vnetmpz87IHxbCHmIuJxhMfH+vMY5zvF7vUy018XUPrAcqDkmszhJOFuMhB2SQ6IT8nQZnZ+aGGnoQ2kgjCrrusAAAAVAN/iBeqRO1CPAuNIec08Y9VP+MFTAAABAGDVzqw4i64Fd1mLi6BRKYZdbMI56gx+Cu+EfAjH7dx6AqEW7PiSB2yQrXl1dbCbLYhQhEXIaJW+8epTCsm9o22+KZ5yIyyNc5SxPad7W4W/gvSzqMZC+NMBYia8hrq3BHk9OYxFUZfCx47adbs9sKFi1GhgCbXiDsrb8EvzMWMyyKyAl1AaCaMYWVXnDRBtJnASK2GyiR4GWHA+4z9syrEHknM0RonP2B24552cYq3gxCxRvZ6XJBRQaRnS9RjIaziDImXoLa5X/82ZT6cVzwdZa9S9LGJusfBLrE12O8nis1iI1CliukGtOmWvogFqYABtkzGizrnajCpU4doiuoUAAAEAchR3IrCbXnDekPQGt+uM4cSdZ9OIt2wROlxJODV/Z57OOGMm7RFJkuC4olN1h032dhHM6hsKzsMoRkin0zLuZgsInKs2LnmaL27wwB5wcriLnZm1HK9PUEH5A/wqR4Vc2SHUa1Zzvjddqe0fk2rRzYhaACctSii8CH68nmECZDgn0xePz8n4p4CoZalkQvcjEW/O6nzgrudW3VahxEl4YijuWocQ+y0vWIa6OByuYbDAxST971RF84Q0M8I1jnEwteGcYnLV8CVZQaZ5fmI3t4Z8CcRN339rKpvakVgNYYATJcTc402TIhyRHMLew63et11xkIVGocLaaYaI2gzavA==',
        TooLongKeyError, "dsa_2048", ["strict"]
    ],
    [
        'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAYQbdtLTII+vP98NSDlK2LXxVARELRYO0NODFYQ0imYxsmBMB7BrfljFppLJyjU6cziOT6YFj6rVd8MmCogdCR32u63EV11uT6RCFfJMQJtIi+B1JJipTxLzURsiUOOgAHJc= ojarva@ojar-laptop.local',
        TooShortKeyError, "rsa_771", ["strict"]
    ],
github ojarva / python-sshpubkeys / sshpubkeys / keys.py View on Github external
"""Parses ed25516 keys.

        There is no (apparent) way to validate ed25519 keys. This only
        checks data length (256 bits), but does not try to validate
        the key in any way."""

        current_position, verifying_key = self._unpack_by_int(data, 0)
        verifying_key_length = len(verifying_key) * 8
        verifying_key = self._parse_long(verifying_key)

        if verifying_key < 0:
            raise InvalidKeyError("ed25519 verifying key must be >0.")

        self.bits = verifying_key_length
        if self.bits != 256:
            raise InvalidKeyLengthError("ed25519 keys must be 256 bits (was %s bits)" % self.bits)
        return current_position
github ojarva / python-sshpubkeys / sshpubkeys / exceptions.py View on Github external
class InvalidKeyLengthError(InvalidKeyError):
    """Invalid key length - either too short or too long.

    See also TooShortKeyException and TooLongKeyException."""


class TooShortKeyException(InvalidKeyLengthError):
    """Key is shorter than what the specification allow."""


class TooShortKeyError(TooShortKeyException):
    """Key is shorter than what the specification allows."""


class TooLongKeyException(InvalidKeyLengthError):
    """Key is longer than what the specification allows."""


class TooLongKeyError(TooLongKeyException):
    """Key is longer than what the specification allows."""


class InvalidTypeException(InvalidKeyError):
    """Key type is invalid or unrecognized."""


class InvalidTypeError(InvalidTypeException):
    """Key type is invalid or unrecognized."""


class MalformedDataException(InvalidKeyError):
github ojarva / python-sshpubkeys / sshpubkeys / exceptions.py View on Github external
"""Invalid key - something is wrong with the key, and it should not be accepted, as OpenSSH will not work with it."""


class InvalidKeyLengthException(InvalidKeyError):
    """Invalid key length - either too short or too long.

    See also TooShortKeyException and TooLongKeyException."""


class InvalidKeyLengthError(InvalidKeyError):
    """Invalid key length - either too short or too long.

    See also TooShortKeyException and TooLongKeyException."""


class TooShortKeyException(InvalidKeyLengthError):
    """Key is shorter than what the specification allow."""


class TooShortKeyError(TooShortKeyException):
    """Key is shorter than what the specification allows."""


class TooLongKeyException(InvalidKeyLengthError):
    """Key is longer than what the specification allows."""


class TooLongKeyError(TooLongKeyException):
    """Key is longer than what the specification allows."""


class InvalidTypeException(InvalidKeyError):