Skip to content

Commit

Permalink
fix(jwk): update key type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 12, 2023
1 parent 7c43c20 commit 3c5dff7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/joserfc/rfc7517/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
)


NativePublicKey = t.TypeVar("NativePublicKey")
NativePrivateKey = t.TypeVar("NativePrivateKey")
NativePublicKey = t.TypeVar("NativePublicKey")


class NativeKeyBinding(object, metaclass=ABCMeta):
Expand Down Expand Up @@ -66,7 +66,7 @@ def validate_dict_key_use_operations(cls, dict_key: KeyDict):
raise ValueError('"use" and "key_ops" does not match')


class BaseKey(t.Generic[NativePublicKey, NativePrivateKey]):
class BaseKey(t.Generic[NativePrivateKey, NativePublicKey]):
key_type: str
value_registry: KeyParameterRegistryDict
param_registry: KeyParameterRegistryDict = JWK_PARAMETER_REGISTRY
Expand Down Expand Up @@ -230,7 +230,7 @@ def generate_key(cls, size_or_crv, parameters: KeyParameters = None, private: bo
raise NotImplementedError()


class SymmetricKey(BaseKey[NativePublicKey, NativePrivateKey], metaclass=ABCMeta):
class SymmetricKey(BaseKey[NativePrivateKey, NativePublicKey], metaclass=ABCMeta):
@property
def raw_value(self) -> bytes:
"""The raw key in bytes."""
Expand All @@ -252,7 +252,7 @@ def private_key(self) -> bytes:
return self.raw_value


class AsymmetricKey(BaseKey[NativePublicKey, NativePrivateKey], metaclass=ABCMeta):
class AsymmetricKey(BaseKey[NativePrivateKey, NativePublicKey], metaclass=ABCMeta):
@property
def raw_value(self) -> t.Union[NativePublicKey, NativePrivateKey]:
return self._raw_value
Expand All @@ -271,7 +271,7 @@ def as_der(self, private=None, password=None) -> bytes:
return self.as_bytes(encoding="DER", private=private, password=password)


class CurveKey(AsymmetricKey[NativePublicKey, NativePrivateKey]):
class CurveKey(AsymmetricKey[NativePrivateKey, NativePublicKey]):
@property
@abstractmethod
def curve_name(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/joserfc/rfc7518/ec_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def export_public_key(key: EllipticCurvePublicKey) -> Dict[str, str]:
}


class ECKey(CurveKey[EllipticCurvePublicKey, EllipticCurvePrivateKey]):
class ECKey(CurveKey[EllipticCurvePrivateKey, EllipticCurvePublicKey]):
key_type: str = "EC"
#: Registry definition for EC Key
#: https://www.rfc-editor.org/rfc/rfc7518#section-6.2
Expand Down
2 changes: 1 addition & 1 deletion src/joserfc/rfc7518/rsa_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def export_public_key(key: RSAPublicKey) -> Dict[str, str]:
return {"n": int_to_base64(numbers.n), "e": int_to_base64(numbers.e)}


class RSAKey(AsymmetricKey[RSAPublicKey, RSAPrivateKey]):
class RSAKey(AsymmetricKey[RSAPrivateKey, RSAPublicKey]):
key_type: str = "RSA"
#: Registry definition for RSA Key
#: https://www.rfc-editor.org/rfc/rfc7518#section-6.3
Expand Down
2 changes: 1 addition & 1 deletion src/joserfc/rfc8037/okp_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def export_public_key(key: PublicOKPKey) -> Dict[str, str]:
}


class OKPKey(CurveKey[PublicOKPKey, PrivateOKPKey]):
class OKPKey(CurveKey[PrivateOKPKey, PublicOKPKey]):
"""Key class of the ``OKP`` key type."""

key_type: str = "OKP"
Expand Down

0 comments on commit 3c5dff7

Please sign in to comment.