MCPcopy
hub / github.com/authlib/authlib / import_key

Method import_key

authlib/jose/rfc7518/oct_key.py:66–85  ·  view source on GitHub ↗

Import a key from bytes, string, or dict data.

(cls, raw, options=None)

Source from the content-addressed store, hash-verified

64
65 @classmethod
66 def import_key(cls, raw, options=None):
67 """Import a key from bytes, string, or dict data."""
68 if isinstance(raw, cls):
69 if options is not None:
70 raw.options.update(options)
71 return raw
72
73 if isinstance(raw, dict):
74 cls.check_required_fields(raw)
75 key = cls(options=options)
76 key._dict_data = raw
77 else:
78 raw_key = to_bytes(raw)
79
80 # security check
81 if raw_key.startswith(POSSIBLE_UNSAFE_KEYS):
82 raise ValueError("This key may not be safe to import")
83
84 key = cls(raw_key=raw_key, options=options)
85 return key
86
87 @classmethod
88 def generate_key(cls, key_size=256, options=None, is_private=True):

Callers 15

signMethod · 0.45
signMethod · 0.45
loadsFunction · 0.45
dumpsFunction · 0.45
generate_keyMethod · 0.45
prepare_keyMethod · 0.45
prepare_keyMethod · 0.45
prepare_keyMethod · 0.45
prepare_keyMethod · 0.45
generate_keyMethod · 0.45
prepare_keyMethod · 0.45
prepare_keyMethod · 0.45

Calls 2

to_bytesFunction · 0.90
check_required_fieldsMethod · 0.80