New in version 3008.0.
Low-level asymmetric cryptographic operations.
cryptography
Note
All parameters that take a public key or private key can be specified either as a PEM/hex/base64 string or a path to a local file encoded in all supported formats for the type.
A signature can be specified as a base64 string or a path to a file with the raw signature or its base64 encoding.
Public keys and signatures can additionally be specified as a URL that can be
retrieved using cp.cache_file
.
Sign a file or text using an (RSA|ECDSA|Ed25519|Ed448) private key.
You can employ x509.create_private_key
to generate one. Returns the signature encoded in base64 by default.
CLI Example:
salt '*' asymmetric.sign /root/my_privkey.pem text='I like you'
salt '*' asymmetric.sign /root/my_privkey.pem filename=/data/to/be/signed
The private key to sign with.
If the private key is encrypted, the passphrase to decrypt it. Optional.
Pass the text to sign. Either this or filename
is required.
Pass the path of a file to sign. Either this or text
is required.
The name of the hashing algorithm to use when creating signatures.
Defaults to sha256
. Only relevant for ECDSA or RSA.
Return the raw bytes instead of encoding them to base64. Defaults to false.
Instead of returning the data, write it to a path on the local filesystem. Optional.
Verify signatures on a specific input against (RSA|ECDSA|Ed25519|Ed448) public keys.
Note
This function is supposed to be compatible with the same interface
as gpg.verify <salt.modules.gpg.verify>`()
regarding keyword
arguments and return value format.
CLI Example:
salt '*' asymmetric.verify pubkey=/root/my_pubkey.pem text='I like you' signature=/root/ilikeyou.sig
salt '*' asymmetric.verify pubkey=/root/my_pubkey.pem path=/root/confidential signature=/root/confidential.sig
The text to verify. Either this or filename
is required.
The path of a file to verify. Either this or text
is required.
The single public key to verify signature
against. Specify either
this or make use of signed_by_any
/signed_by_all
for compound checks.
If pubkey
is specified, the single signature to verify.
If signed_by_any
and/or signed_by_all
is specified, this can be
a list of multiple signatures to check against the provided keys.
Required.
The name of the hashing algorithm to use when verifying signatures.
Defaults to sha256
. Only relevant for ECDSA or RSA.
A list of pubkeys from which any valid signature will mark verification
as passed. If none of the listed pubkeys provided a signature,
verification fails. Works with signed_by_all
, but mutually
exclusive with pubkey
.
A list of pubkeys, all of which must provide a signature for verification
to pass. If a single one of the listed pubkeys did not provide a signature,
verification fails. Works with signed_by_any
, but mutually
exclusive with pubkey
.