1 /* $NetBSD: heim-auth.h,v 1.1.1.2 2014/04/24 12:45:51 pettai Exp $ */
4 * Generate challange for APOP and CRAM-MD5
8 heim_generate_challenge(const char *hostname
); /* hostname can be NULL, the local hostname is used */
15 heim_apop_create(const char *challenge
, const char *password
);
18 heim_apop_verify(const char *challenge
, const char *password
, const char *response
);
24 typedef struct heim_HMAC_MD5_STATE_s
{
27 } heim_CRAM_MD5_STATE
;
29 typedef struct heim_cram_md5
*heim_cram_md5
;
32 heim_cram_md5_create(const char *challenge
, const char *password
);
35 heim_cram_md5_verify(const char *challenge
, const char *password
, const char *response
);
38 heim_cram_md5_export(const char *password
, heim_CRAM_MD5_STATE
*state
);
41 heim_cram_md5_import(void *data
, size_t len
);
44 heim_cram_md5_verify_ctx(heim_cram_md5 ctx
, const char *challenge
, const char *response
);
47 heim_cram_md5_free(heim_cram_md5 ctx
);
54 * d = heim_digest_create(1, HEIM_DIGEST_TYPE_DIGEST_MD5_HTTP);
56 * if ((s = heim_digest_generate_challange(d)) != NULL) abort();
58 * response = read_from_client();
60 * heim_digest_parse_response(d, response);
62 * const char *user = heim_digest_get_key(d, "username");
63 * heim_digest_set_key(d, "password", "sommar17");
65 * if (heim_digest_verify(d, &response)) abort();
67 * send_to_client(response);
69 * heim_digest_release(d);
72 typedef struct heim_digest_desc
*heim_digest_t
;
75 heim_digest_create(int server
, int type
);
77 #define HEIM_DIGEST_TYPE_AUTO 0
78 #define HEIM_DIGEST_TYPE_RFC2069 1
79 #define HEIM_DIGEST_TYPE_MD5 2
80 #define HEIM_DIGEST_TYPE_MD5_SESS 3
83 heim_digest_init_set_key(heim_digest_t context
, const char *key
, const char *value
);
86 heim_digest_generate_challenge(heim_digest_t context
);
89 heim_digest_parse_challenge(heim_digest_t context
, const char *challenge
);
92 heim_digest_parse_response(heim_digest_t context
, const char *response
);
95 heim_digest_get_key(heim_digest_t context
, const char *key
);
98 heim_digest_set_key(heim_digest_t context
, const char *key
, const char *value
);
101 heim_digest_set_user_password(heim_digest_t context
, const char *password
);
104 heim_digest_set_user_h1hash(heim_digest_t context
, void *ptr
, size_t size
);
107 heim_digest_verify(heim_digest_t context
, char **response
);
110 heim_digest_create_response(heim_digest_t context
);
113 heim_digest_get_session_key(heim_digest_t context
, void **key
, size_t *keySize
);
116 heim_digest_release(heim_digest_t context
);