Cryptography helpers for verifying and signing messages.
The simplest way to verify signatures is using verify_signature()
:
cert = open('certs.pem').read() valid = crypt.verify_signature(message, signature, cert)
If you’re going to verify many messages with the same certificate, you can use RSAVerifier
:
cert = open('certs.pem').read() verifier = crypt.RSAVerifier.from_string(cert) valid = verifier.verify(message, signature)
To sign messages use RSASigner
with a private key:
private_key = open('private_key.pem').read() signer = crypt.RSASigner.from_string(private_key) signature = signer.sign(message)
The code above also works for ES256Signer
and ES256Verifier
. Note that these two classes are only available if your cryptography dependency version is at least 1.4.0.
Bases: Signer
, FromServiceAccountMixin
Signs messages with an RSA private key.
private_key (rsa.key.PrivateKey) – The private key to sign with.
key_id (str) – Optional key ID used to identify this private key. This can be useful to associate the private key with its associated public key or certificate.
Signs a message.
Construct an Signer instance from a private key in PEM format.
The constructed signer.
ValueError – If the key cannot be parsed as PKCS#1 or PKCS#8 in PEM format.
Creates a Signer instance from a service account .json file in Google format.
filename (str) – The path to the service account .json file.
The constructed signer.
Creates a Signer instance instance from a dictionary containing service account info in Google format.
info (Mapping
str
, str
) – The service account info in Google format.
The constructed signer.
ValueError – If the info is not in the expected format.
Bases: Verifier
Verifies RSA cryptographic signatures using public keys.
public_key (rsa.key.PublicKey) – The public key used to verify signatures.
Verifies a message against a cryptographic signature.
Construct an Verifier instance from a public key or public certificate string.
public_key (Union
str
, bytes
) – The public key in PEM format or the x509 public key certificate.
The constructed verifier.
ValueError – If the public_key can’t be parsed.
Bases: object
Abstract base class for cryptographic signers.
Bases: object
Abstract base class for crytographic signature verifiers.
Verifies a message against a cryptographic signature.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4