GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ssh-python/ssh/keytypes.pyx at master · iCodeIN/ssh-python Expand file tree/ Copy pathkeytypes.pyxMore file actions 159 lines (117 loc) · 4.63 KB / Copy pathkeytypes.pyxFile metadata and controls159 lines (117 loc) · 4.63 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 # This file is part of ssh-python. # Copyright (C) 2018-2020 Panos Kittenis # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation, version 2.1. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 from libc.string cimport const_char from utils cimport to_str, to_bytes from c_ssh cimport ssh_keytypes_e, ssh_key_type_to_char, ssh_key_type_from_name cdef class KeyType: def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_UNKNOWN @property def value(self): return self._type def __str__(self): cdef const_char *c_type c_type = ssh_key_type_to_char(self._type) if c_type is not NULL: return to_str(c_type) return "unknown" def __repr__(self): return self.__str__() cdef class UnknownKey(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_UNKNOWN cdef class DSSKey(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_DSS cdef class RSAKey(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_RSA cdef class RSA1Key(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_RSA1 cdef class ECDSAKey(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA cdef class DSSCert01Key(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_DSS_CERT01 cdef class RSACert01Key(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_RSA_CERT01 cdef class ECDSA_P256(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P256 cdef class ECDSA_P384(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P384 cdef class ECDSA_P521(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P521 cdef class ECDSA_P256_CERT01(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P256_CERT01 cdef class ECDSA_P384_CERT01(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P384_CERT01 cdef class ECDSA_P521_CERT01(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P521_CERT01 cdef class ED25519Key(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ED25519 cdef class ED25519_CERT01(KeyType): def __cinit__(self): self._type = ssh_keytypes_e.SSH_KEYTYPE_ED25519_CERT01 cdef KeyType from_keytype(ssh_keytypes_e _type): if _type == ssh_keytypes_e.SSH_KEYTYPE_UNKNOWN: return UnknownKey() elif _type == ssh_keytypes_e.SSH_KEYTYPE_DSS: return DSSKey() elif _type == ssh_keytypes_e.SSH_KEYTYPE_RSA: return RSAKey() elif _type == ssh_keytypes_e.SSH_KEYTYPE_RSA1: return RSA1Key() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA: return ECDSAKey() elif _type == ssh_keytypes_e.SSH_KEYTYPE_DSS_CERT01: return DSSCert01Key() elif _type == ssh_keytypes_e.SSH_KEYTYPE_RSA_CERT01: return RSACert01Key() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P256: return ECDSA_P256() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P384: return ECDSA_P384() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P521: return ECDSA_P521() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P256_CERT01: return ECDSA_P256_CERT01() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P384_CERT01: return ECDSA_P384_CERT01() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ECDSA_P521_CERT01: return ECDSA_P521_CERT01() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ED25519: return ED25519Key() elif _type == ssh_keytypes_e.SSH_KEYTYPE_ED25519_CERT01: return ED25519_CERT01() else: raise ValueError("Unknown keytype %s", _type) def key_type_from_name(key_name): cdef ssh_keytypes_e _type cdef bytes b_key_name = to_bytes(key_name) cdef const char *_key_name = b_key_name with nogil: _type = ssh_key_type_from_name(_key_name) return from_keytype(_type) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |