tools
EncodeString(origstr)
Encode a string to bytes, ensuring it is UTF-8 encoded.
Source code in pyrad2/tools.py
EncodeOctets(octetstring)
Encode raw octet string (already in bytes).
Source code in pyrad2/tools.py
EncodeAddress(addr)
Encode an IPv4 address (dotted string) to 4-byte format.
EncodeIPv6Prefix(addr)
Encode an IPv6 address and prefix length to 18-byte format.
Source code in pyrad2/tools.py
EncodeIPv6Address(addr)
Encode an IPv6 address (as string) to 16-byte format.
EncodeAscendBinary(orig_str)
Encode binary data in Ascend-specific format (length prefixed).
Source code in pyrad2/tools.py
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 160 161 162 163 164 |
|
EncodeInteger(num, format='!I')
Encode a 32-bit unsigned integer to 4-byte big-endian.
Source code in pyrad2/tools.py
EncodeInteger64(num, format='!Q')
Encode a 64-bit unsigned integer to 8-byte big-endian.
Source code in pyrad2/tools.py
EncodeDate(num)
DecodeString(orig_str)
Decode UTF-8 bytes into a string.
DecodeOctets(orig_bytes)
DecodeAddress(addr)
DecodeIPv6Prefix(addr)
Decode 18-byte IPv6 prefix format into address/prefix tuple.
Source code in pyrad2/tools.py
DecodeIPv6Address(addr)
Decode 16-byte IPv6 address into a readable string.
Source code in pyrad2/tools.py
DecodeAscendBinary(orig_bytes)
DecodeInteger(num, format='!I')
DecodeInteger64(num, format='!Q')
DecodeDate(num)
EncodeAttr(datatype, value)
Encode a RADIUS attribute (type, value, length) into bytes.
Source code in pyrad2/tools.py
DecodeAttr(datatype, value)
Decode a RADIUS attribute from bytes into a type and value.
Source code in pyrad2/tools.py
get_cert_fingerprint(cert)
Generate SHA-256 fingerprint from a certificate.
Source code in pyrad2/tools.py
get_client_fingerprint(ssl_object)
Returns SHA-256 fingerprint of the client certificate.
Source code in pyrad2/tools.py
read_radius_packet(reader)
async
Read a full RADIUS packet from the stream.
There's no built-in framing in RadSec, so we can't read a fixed-size packet. Instead, we read the header first to determine the length of the packet, and then read the rest of the packet based on that length.
RADIUS packets are prefixed with a 4-byte header
- Code (1 byte)
- Identifier (1 byte)
- Length (2 bytes)
The length includes the header, so the minimum length is 20 bytes (4-byte header + 16-byte Authenticator). If the length is less than 20, it is considered invalid.
:param reader: asyncio StreamReader to read from :return: Full RADIUS packet as bytes