1 #ifndef _library__httpauth__hpp__included__
2 #define _library__httpauth__hpp__included__
11 * DH25519 HTTP auth class.
13 class dh25519_http_auth
17 * Internal hashing instance.
25 request_hash(const std::string
& _id
, const uint8_t* _key
, unsigned _nonce
, skein::hash _h
,
26 const uint8_t* _prereq
)
27 : id(_id
), nonce(_nonce
), h(_h
)
29 memcpy(pubkey
, _key
, 32);
30 memcpy(prereq
, _prereq
, 8);
33 * Append data to hash.
35 void hash(const uint8_t* data
, size_t datalen
)
37 h
.write(data
, datalen
);
40 * Read the final Authorization header.
42 std::string
get_authorization();
51 * Create a new instance.
53 * Parameter privkey: The private key (32 bytes).
55 dh25519_http_auth(const uint8_t* privkey
);
61 * Format a session creation request
63 * Returns: The value for Authorization header.
65 std::string
format_get_session_request();
67 * Start request hash computation. Hashes in the shared secret and nonce. The nonce is incremented.
69 * Parameter url: The notional URL.
70 * Returns: The skein hash instance.
72 request_hash
start_request(const std::string
& url
, const std::string
& verb
);
74 * Parse session auth response. If it contains new session parameters, the session is updated.
76 * Parameter response: The response from server (WWW-Authenticate).
78 void parse_auth_response(const std::string
& response
);
80 * Is the session ready?
82 bool is_ready() { return ready
; }
86 void get_pubkey(uint8_t* pubkey
);
88 void parse_auth_response(std::map
<std::string
, std::string
> pparse
);
89 unsigned char privkey
[32];
90 unsigned char pubkey
[32];
91 unsigned char ssecret
[32];
94 bool ready
; //id&ssecret is valid.