ExSwan.Crypto (exswan v0.1.0)
View SourceCryptographic utilities for WebAuthn operations.
This module provides functions for signature verification, public key handling, and other cryptographic operations required by the WebAuthn specification.
Summary
Functions
Computes the signed data for WebAuthn assertion verification.
Verifies a digital signature using the provided public key and data.
Verify a COSE signature over msg using a COSE_Key map (already CBOR-decoded).
sig is the signature bytes as delivered by COSE (raw r||s for ECDSA; 64B for Ed25519; PKCS#1/RSASSA-PSS for RSA).
alg is the COSE alg int (e.g. -7 for ES256).
Functions
Computes the signed data for WebAuthn assertion verification.
Concatenates authenticator data and client data hash as per WebAuthn spec.
Verifies a digital signature using the provided public key and data.
Parameters
signature- The signature bytes to verifysigned_data- The data that was signedpublic_key_map- COSE public key map from credentialalgorithm- Signature algorithm identifier
Returns
:okif signature is valid{:error, reason}if verification fails
Examples
public_key = %{1 => 2, 3 => -7, -1 => 1, -2 => x_coord, -3 => y_coord}
{:ok} = ExSwan.Crypto.verify_signature(signature, data, public_key, -7)
Verify a COSE signature over msg using a COSE_Key map (already CBOR-decoded).
sig is the signature bytes as delivered by COSE (raw r||s for ECDSA; 64B for Ed25519; PKCS#1/RSASSA-PSS for RSA).
alg is the COSE alg int (e.g. -7 for ES256).