Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
authentication.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5#include <span>
6#include <string>
7#include <string_view>
8#include <vector>
9
10namespace pulp::inspect {
11
12inline constexpr std::size_t inspector_token_size = 32;
13inline constexpr std::size_t inspector_nonce_size = 32;
14
16 std::string scheme = "pulp-inspector-hmac-sha256-v1";
17 std::string nonce_hex;
18 std::string session_id;
19 std::string instance_id;
20 std::string publication_id;
21 std::string protocol_version;
22};
23
25std::optional<std::vector<std::uint8_t>> generate_inspector_secret();
26
27std::optional<InspectorAuthChallenge> make_inspector_auth_challenge(
28 std::string session_id,
29 std::string instance_id,
30 std::string publication_id,
31 std::string protocol_version);
32
35std::optional<std::string> make_inspector_auth_proof(
36 std::span<const std::uint8_t> token,
37 const InspectorAuthChallenge& challenge);
38
41std::optional<std::string> make_inspector_server_auth_proof(
42 std::span<const std::uint8_t> token,
43 const InspectorAuthChallenge& challenge,
44 std::string_view client_proof);
46 std::span<const std::uint8_t> token,
47 const InspectorAuthChallenge& challenge,
48 std::string_view client_proof,
49 std::string_view server_proof);
50
54public:
55 InspectorAuthVerifier(std::vector<std::uint8_t> token,
58
63
64 const InspectorAuthChallenge& challenge() const { return challenge_; }
65 bool verify(std::string_view proof_hex);
66 std::optional<std::string> authenticate(
67 std::string_view client_proof);
68 bool consumed() const { return consumed_; }
69
70private:
71 std::vector<std::uint8_t> token_;
72 InspectorAuthChallenge challenge_;
73 bool consumed_ = false;
74};
75
76} // namespace pulp::inspect
InspectorAuthVerifier & operator=(InspectorAuthVerifier &&)=delete
InspectorAuthVerifier(InspectorAuthVerifier &&)=delete
InspectorAuthVerifier & operator=(const InspectorAuthVerifier &)=delete
const InspectorAuthChallenge & challenge() const
Definition authentication.hpp:64
bool consumed() const
Definition authentication.hpp:68
std::optional< std::string > authenticate(std::string_view client_proof)
bool verify(std::string_view proof_hex)
InspectorAuthVerifier(const InspectorAuthVerifier &)=delete
InspectorAuthVerifier(std::vector< std::uint8_t > token, InspectorAuthChallenge challenge)
Definition agent_context.hpp:7
std::optional< std::string > make_inspector_server_auth_proof(std::span< const std::uint8_t > token, const InspectorAuthChallenge &challenge, std::string_view client_proof)
Construct and verify the distinct server-side transcript proof returned after the client proof succee...
std::optional< InspectorAuthChallenge > make_inspector_auth_challenge(std::string session_id, std::string instance_id, std::string publication_id, std::string protocol_version)
bool verify_inspector_server_auth_proof(std::span< const std::uint8_t > token, const InspectorAuthChallenge &challenge, std::string_view client_proof, std::string_view server_proof)
constexpr std::size_t inspector_nonce_size
Definition authentication.hpp:13
std::optional< std::string > make_inspector_auth_proof(std::span< const std::uint8_t > token, const InspectorAuthChallenge &challenge)
Construct the versioned HMAC proof used by installed clients.
constexpr std::size_t inspector_token_size
Definition authentication.hpp:12
std::optional< std::vector< std::uint8_t > > generate_inspector_secret()
Generate a per-session 256-bit token or per-connection 256-bit nonce.
Definition authentication.hpp:15
std::string instance_id
Definition authentication.hpp:19
std::string nonce_hex
Definition authentication.hpp:17
std::string protocol_version
Definition authentication.hpp:21
std::string session_id
Definition authentication.hpp:18
std::string scheme
Definition authentication.hpp:16
std::string publication_id
Definition authentication.hpp:20