Skip to main content

validate_response_code

Function validate_response_code 

Source
pub fn validate_response_code(
    response_bytes: &[u8],
    state_dir: Option<&Path>,
    license_id: &str,
    state_integrity_key: &[u8; 32],
    public_key_pem: &str,
    algorithm_id: &str,
) -> Result<UnlockResult>
Expand description

Validate a response code and apply the unlock if valid

The response is raw bytes: [timestamp(8)] || [unlock_type(1)] || [signature(variable)]. The admin signs SHA256(nonce || timestamp_bytes || unlock_type_byte || fingerprint_hash) using the organization’s private key. The pending challenge (saved during generate_challenge_from_state) supplies the nonce and fingerprint_hash for reconstruction.

§Arguments

  • response_bytes - The raw response bytes from the admin
  • state_dir - Optional custom state directory (must match the one used for challenge)
  • license_id - The license ID
  • state_integrity_key - The state HMAC key (same key used for LicenseState)
  • public_key_pem - The organization’s public key for signature verification
  • algorithm_id - The signature algorithm used (e.g., “RSA-SHA256”, “Ed25519”)

§Returns

An UnlockResult indicating success/failure and what was reset