Pyjo.AWS.ECDSA - Signatures of ES256 of a key of P-256¶
from Pyjo.AWS.ECDSA import ECDSA
key = ECDSA.from_pem(open('key.pem').read())
signature = key.sign(b'header.payload')
# Or import the module, as in Google Python Style Guide
import Pyjo.AWS.ECDSA
key = Pyjo.AWS.ECDSA.from_pem(pem, backend='python')
print(key.jwk(), key.verify(b'header.payload', signature))
Pyjo.AWS.ECDSA is a private key of ECDSA of the curve P-256, which
signs with SHA-256, as ES256 of JSON Web Signature, of RFC 7518, has it: the
signature is r and s of 32 bytes each, not the DER of X.509. The DPoP
of Pyjo.AWS.Credentials.Login signs with it.
The signature is the one of the package cryptography when it is
installed, as the extra cryptography of the distribution installs it:
pip install 'Pyjo-AWS[cryptography]'
or of Python itself otherwise, with the nonce of RFC 6979, which a key and a message determine, so that no random number of the machine makes it. That one is not constant-time: it is for a key and a signature that are made on the machine that has the key, not for a server that signs what anyone sends it.
See also¶
Pyjo.AWS.Credentials.Login, RFC 6979, RFC 7518,
https://cryptography.io/.
Classes¶
- Pyjo.AWS.ECDSA.A = 115792089210356248762697446949407573530086143415290314195533631308867097853948¶
The coefficient
aof P-256.
- Pyjo.AWS.ECDSA.B = 41058363725152142129326129780047268409114441015993725554835256314039467401291¶
The coefficient
bof P-256.
- Pyjo.AWS.ECDSA.G = (48439561293906451759052585252797914202762949526041747995844080717082404635286, 36134250956749795798585127919587881956611106672985015071877198253568414405109)¶
The base point of P-256.
- Pyjo.AWS.ECDSA.N = 115792089210356248762697446949407573529996955224135760342422259061068512044369¶
The order of the base point of P-256.
- Pyjo.AWS.ECDSA.P = 115792089210356248762697446949407573530086143415290314195533631308867097853951¶
The prime of the field of P-256.
- class Pyjo.AWS.ECDSA.Pyjo_AWS_ECDSA(private_value: int, *, backend: Backend | None = None)[source]¶
Pyjo.AWS.ECDSAinherits all attributes and methods fromPyjo.Baseand implements the following new ones.- __init__(private_value: int, *, backend: Backend | None = None) None[source]¶
key = Pyjo.AWS.ECDSA.new(0xC9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721) key = Pyjo.AWS.ECDSA.new(private_value, backend='python')
Construct a new
Pyjo.AWS.ECDSAobject of the private value of a key, with the backend ofcryptographywhen it is installed, or of Python.
- __weakref__¶
list of weak references to the object
- backend: Backend¶
name = key.backend
The backend of the signatures,
cryptographyorpython.
- classmethod from_pem(pem: str | bytes, *, backend: Backend | None = None) Pyjo_AWS_ECDSA[source]¶
key = Pyjo.AWS.ECDSA.from_pem(pem)
A new
Pyjo.AWS.ECDSAobject of a private key of P-256 in PEM, of PKCS #8,BEGIN PRIVATE KEY, or of SEC 1,BEGIN EC PRIVATE KEY, without a password.
- jwk() dict[str, str][source]¶
jwk = key.jwk()
The public key as a JSON Web Key, of RFC 7518, with
kty,crv,xandy.
- private_value¶
d = key.private_value
The private value of the key.
- public_point: tuple[int, int]¶
x, y = key.public_point
The point of the public key.
- Pyjo.AWS.ECDSA.base64url(data: bytes) str[source]¶
string = Pyjo.AWS.ECDSA.base64url(b'data')
The base64url of data without its padding, as JSON Web Signature has it.
- Pyjo.AWS.ECDSA.from_pem(pem: str | bytes, *, backend: Backend | None = None) Pyjo_AWS_ECDSA[source]¶
key = Pyjo.AWS.ECDSA.from_pem(pem)
Alias for
Pyjo_AWS_ECDSA.from_pem().