1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! HMAC-SHA256 sign/verify for AMQP message payloads (CONTRACT.md §8).
//!
//! **Mirror, never import.** This module reproduces the algorithm in
//! `crates/axiam-amqp/src/messages.rs:35-50` byte-for-byte using only
//! external crates (`hmac`, `sha2`, `hex`) so that the SDK's HMAC output is
//! wire-compatible with the AXIAM server for the same key + canonical JSON
//! payload bytes. This crate does NOT depend on the `axiam-amqp` crate.
use ;
use Sha256;
type HmacSha256 = ;
/// Compute HMAC-SHA256 of the JSON-serialized message payload.
///
/// The `hmac_signature` field must be set to `None` (or omitted) before
/// serializing `payload_json` — otherwise the signature is computed over a
/// message that includes a placeholder signature, making verification
/// impossible. This matches the server's `sign_payload` doc comment
/// (`crates/axiam-amqp/src/messages.rs:31-34`).
///
/// This is the raw primitive: it signs whatever bytes it is given. To sign an
/// audit event use [`AuditEventMessage::sign`](crate::amqp::messages::AuditEventMessage::sign),
/// which refuses a reserved action first (CONTRACT.md §8) and clears the
/// signature field before serializing.
/// Verify an HMAC-SHA256 signature over the canonical payload bytes.
///
/// Returns `true` if the signature matches. Uses constant-time comparison
/// internally (via the `hmac` crate's `verify_slice`).