|
25 | 25 | ed25519.Ed25519PrivateKey, ed448.Ed448PrivateKey, x25519.X25519PrivateKey, x448.X448PrivateKey |
26 | 26 | ] |
27 | 27 |
|
28 | | -CRV2PUBLIC = { |
| 28 | +OKP_CRV2PUBLIC = { |
29 | 29 | "Ed25519": ed25519.Ed25519PublicKey, |
30 | 30 | "Ed448": ed448.Ed448PublicKey, |
31 | 31 | "X25519": x25519.X25519PublicKey, |
32 | 32 | "X448": x448.X448PublicKey, |
33 | 33 | } |
34 | 34 |
|
35 | | -CRV2PRIVATE = { |
| 35 | +OKP_CRV2PRIVATE = { |
36 | 36 | "Ed25519": ed25519.Ed25519PrivateKey, |
37 | 37 | "Ed448": ed448.Ed448PrivateKey, |
38 | 38 | "X25519": x25519.X25519PrivateKey, |
@@ -144,15 +144,15 @@ def deserialize(self): |
144 | 144 | try: |
145 | 145 | if isinstance(self.d, (str, bytes)): |
146 | 146 | try: |
147 | | - self.priv_key = CRV2PRIVATE[self.crv].from_private_bytes(deser(self.d)) |
| 147 | + self.priv_key = OKP_CRV2PRIVATE[self.crv].from_private_bytes(deser(self.d)) |
148 | 148 | except KeyError: |
149 | 149 | raise UnsupportedOKPCurve("Unsupported OKP curve: {}".format(self.crv)) |
150 | 150 | self.pub_key = self.priv_key.public_key() |
151 | 151 | except ValueError as err: |
152 | 152 | raise DeSerializationNotPossible(str(err)) |
153 | 153 | else: |
154 | 154 | try: |
155 | | - self.pub_key = CRV2PUBLIC[self.crv].from_public_bytes(_x) |
| 155 | + self.pub_key = OKP_CRV2PUBLIC[self.crv].from_public_bytes(_x) |
156 | 156 | except KeyError: |
157 | 157 | raise UnsupportedOKPCurve("Unsupported OKP curve: {}".format(self.crv)) |
158 | 158 |
|
@@ -272,8 +272,8 @@ def __eq__(self, other): |
272 | 272 | if self.__class__ != other.__class__: |
273 | 273 | return False |
274 | 274 |
|
275 | | - _public_cls = CRV2PUBLIC[self.crv] |
276 | | - _private_cls = CRV2PRIVATE[self.crv] |
| 275 | + _public_cls = OKP_CRV2PUBLIC[self.crv] |
| 276 | + _private_cls = OKP_CRV2PRIVATE[self.crv] |
277 | 277 | if cmp_keys(self.pub_key, other.pub_key, _public_cls): |
278 | 278 | if other.private_key(): |
279 | 279 | if cmp_keys(self.priv_key, other.priv_key, _private_cls): |
@@ -322,7 +322,7 @@ def cmp_keys(a, b, key_type): |
322 | 322 |
|
323 | 323 | def new_okp_key(crv, kid="", **kwargs): |
324 | 324 |
|
325 | | - _key = CRV2PRIVATE[crv].generate() |
| 325 | + _key = OKP_CRV2PRIVATE[crv].generate() |
326 | 326 |
|
327 | 327 | _rk = OKPKey(priv_key=_key, kid=kid, **kwargs) |
328 | 328 | if not kid: |
|
0 commit comments