package x509
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b6b159dc56ba45c373027f20e60779b5ef8d6fb7854e8b428a8dd9afe140ca55
sha512=08843f5cbe592514d81b6eb44a6fad0a502d741cacf4087251781c21ac9e2a623b5d49cd50e058813cd73f6beac4dfa2aea3acc54ebd7f84ddb808d0f4536449
doc/x509/X509/Public_key/index.html
Module X509.Public_keySource
Public keys
Public keys as specified in PKCS 8 are supported in this module.
The type for public keys
type t = [ | `RSA of Mirage_crypto_pk.Rsa.pub| `ED25519 of Mirage_crypto_ec.Ed25519.pub| `P256 of Mirage_crypto_ec.P256.Dsa.pub| `P384 of Mirage_crypto_ec.P384.Dsa.pub| `P521 of Mirage_crypto_ec.P521.Dsa.pub
]The polymorphic variant of public keys, with PKCS 8 encoding and decoding to PEM.
Operations on public keys
val id : t -> stringid public_key is digest, the 160-bit `SHA1 hash of the BIT STRING subjectPublicKey (excluding tag, length, and number of unused bits) for publicKeyInfo of public_key.
val fingerprint : ?hash:Digestif.hash' -> t -> stringfingerprint ?hash public_key is digest, the hash (by default SHA256) of the DER encoded public key (equivalent to openssl x509 -noout -pubkey | openssl pkey -pubin -outform DER | openssl dgst -HASH).
val key_type : t -> Key_type.tkey_type public_key is its key_type.
Cryptographic verify operation
val verify :
Digestif.hash' ->
?scheme:Key_type.signature_scheme ->
signature:string ->
t ->
[ `Message of string | `Digest of string ] ->
(unit, [> `Msg of string ]) resultverify hash ~scheme ~signature key data verifies whether the signature on data is valid using the key, or not. The signature must be in ASN.1 DER encoding. The scheme defaults to `RSA_PSS for RSA, `ED25519 for ED25519, and `ECDSA for other EC keys.
Decoding and encoding in ASN.1 DER and PEM format
val encode_der : t -> stringencode_der pk is buffer, the ASN.1 encoding of the given public key.
decode_der buffer is pubkey, the public key of the ASN.1 encoded buffer.
decode_pem pem is t, where the public key of pem is extracted
val encode_pem : t -> stringencode_pem public_key is pem, the pem encoded public key.