mirror of
https://github.com/block/buzz.git
synced 2026-11-25 02:31:36 +00:00
Log App Attest transcript hashes
Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Codex <noreply@openai.com> Ai-assisted: true
This commit is contained in:
@@ -22,6 +22,7 @@ use nostr::{
|
||||
nips::nip98::{verify_auth_header, HttpMethod},
|
||||
Event, JsonUtil, Timestamp,
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{
|
||||
@@ -212,6 +213,10 @@ async fn enroll(State(s): State<AppState>, body: Bytes) -> Response {
|
||||
Some(v) => v,
|
||||
None => return error(StatusCode::BAD_REQUEST, "invalid_request"),
|
||||
};
|
||||
tracing::info!(
|
||||
transcript_sha256 = %hex::encode(Sha256::digest(signed.as_bytes())),
|
||||
"App Attest enrollment transcript prepared"
|
||||
);
|
||||
let verified = match profile.app_attest.as_ref().and_then(|policy| {
|
||||
policy
|
||||
.verify_attestation(&r.attestation, &r.key_id, signed.as_bytes())
|
||||
@@ -835,7 +840,6 @@ pub fn router_with_metrics(
|
||||
#[cfg(test)]
|
||||
mod transcript_vector_tests {
|
||||
use super::*;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
const VECTORS_JSON: &str = include_str!("../tests/vectors/app_attest_transcripts.json");
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ import CryptoKit
|
||||
import DeviceCheck
|
||||
import Foundation
|
||||
|
||||
#if canImport(OSLog)
|
||||
import OSLog
|
||||
#endif
|
||||
|
||||
#if canImport(Security)
|
||||
import Security
|
||||
#endif
|
||||
@@ -506,6 +510,17 @@ public final class BuzzDevPushEnrollmentDriver {
|
||||
expiresAt: expiresAt,
|
||||
gatewayOrigin: gatewayBaseURL.absoluteString
|
||||
)
|
||||
#if canImport(OSLog)
|
||||
let enrollmentTranscriptHash = Self.lowercaseHex(
|
||||
Data(SHA256.hash(data: enrollmentClientData))
|
||||
)
|
||||
Logger(
|
||||
subsystem: "com.tombrow.buzz.mobile",
|
||||
category: "push-enrollment"
|
||||
).notice(
|
||||
"App Attest enrollment transcript SHA-256: \(enrollmentTranscriptHash, privacy: .public)"
|
||||
)
|
||||
#endif
|
||||
let attestation = try await appAttest.attestation(
|
||||
preparedAttestation,
|
||||
clientData: enrollmentClientData
|
||||
|
||||
Reference in New Issue
Block a user