You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I generate ES256 keys in my project, and needed to support ES256 signing algorithm. This is how I did this. Please consider adding to the repository's examples.
Adding, for example, to c2pa_api.py and examples:
fromcryptography.hazmat.primitivesimporthashesfromcryptography.hazmat.primitives.asymmetricimportecfromcryptography.hazmat.primitives.serializationimportload_pem_private_keydefsign_es256(data: bytes, key_path: str) ->bytes:
withopen(key_path, "rb") askey_file:
private_key=load_pem_private_key(
key_file.read(),
password=None,
)
# Ensure the key is an EC private keyifnotisinstance(private_key, ec.EllipticCurvePrivateKey):
raiseValueError("The provided key is not an Elliptic Curve private key")
# Sign the data using ECDSA with SHA256signature=private_key.sign(
data,
ec.ECDSA(hashes.SHA256())
)
returnsignature
I generate ES256 keys in my project, and needed to support ES256 signing algorithm. This is how I did this. Please consider adding to the repository's examples.
Adding, for example, to
c2pa_api.py
and examples:You could tag this on here:
c2pa-python/c2pa/c2pa_api/c2pa_api.py
Line 242 in 4660ef9
Happy to open a PR post-discussion.
The text was updated successfully, but these errors were encountered: