linotp.lib.crypto.rsa module

methods to handle rsa signature - sign and verify

class linotp.lib.crypto.rsa.RSA_Signature(private: Optional[bytes] = None, public: Optional[bytes] = None)

Bases: object

encapsulate the signature handling which allows to switch the cryptographic implementation

sign(message: bytes) bytes

sign a message

Parameters

message – as bytes

Returns

signature: as bytes

verify(message: bytes, signature: bytes) bool

verify a message signature

Parameters
  • message – as bytes

  • signature – as bytes

Returns

boolean, True for matching signature

linotp.lib.crypto.rsa.create_rsa_signature(priv_key: bytes, message: bytes) bytes

create rsa signature

Parameters
  • priv_key – the private as bytes

  • message – e.g. the license as string as bytes

Returns

signature in bytes

linotp.lib.crypto.rsa.verify_rsa_signature(pub_key: bytes, message: bytes, signature: bytes) bool

verify rsa signature

Parameters
  • pub_key – the public key as bytes in pem format

  • message – e.g. the license as string as bytes

  • signature – e.g. the license signature as bytes

Returns

boolean