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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#ifdef __cplusplus
extern "C" {
#endif
/*
* Generate challange for APOP and CRAM-MD5
*/
char *
heim_generate_challenge(const char *hostname); /* hostname can be NULL, the local hostname is used */
/*
* APOP
*/
char *
heim_apop_create(const char *challenge, const char *password);
int
heim_apop_verify(const char *challenge, const char *password, const char *response);
/*
* CRAM-MD5
*/
typedef struct heim_HMAC_MD5_STATE_s {
uint32_t istate[4];
uint32_t ostate[4];
} heim_CRAM_MD5_STATE;
typedef struct heim_cram_md5_data *heim_cram_md5;
char *
heim_cram_md5_create(const char *challenge, const char *password);
int
heim_cram_md5_verify(const char *challenge, const char *password, const char *response);
void
heim_cram_md5_export(const char *password, heim_CRAM_MD5_STATE *state);
heim_cram_md5
heim_cram_md5_import(void *data, size_t len);
int
heim_cram_md5_verify_ctx(heim_cram_md5 ctx, const char *challenge, const char *response);
void
heim_cram_md5_free(heim_cram_md5 ctx);
/*
* DIGEST-MD5
*
* heim_digest_t d;
*
* d = heim_digest_create(1, HEIM_DIGEST_TYPE_DIGEST_MD5_HTTP);
*
* if ((s = heim_digest_generate_challange(d)) != NULL) abort();
* send_to_client(s);
* response = read_from_client();
*
* heim_digest_parse_response(d, response);
* const char *user = heim_digest_get_key(d, "username");
* heim_digest_set_key(d, "password", "sommar17");
*
* if (heim_digest_verify(d, &response)) abort();
*
* send_to_client(response);
*
* heim_digest_release(d);
*/
typedef struct heim_digest_desc *heim_digest_t;
heim_digest_t
heim_digest_create(int server, int type);
#define HEIM_DIGEST_TYPE_AUTO 0
#define HEIM_DIGEST_TYPE_RFC2069 1
#define HEIM_DIGEST_TYPE_RFC2617_MD5 2
#define HEIM_DIGEST_TYPE_RFC2617_MD5_SESS 4
#define HEIM_DIGEST_TYPE_RFC2831 8
#define HEIM_DIGEST_TYPE_RFC2617_OR_RFC2831 12
/* old deprecated names, use the two above instead */
#define HEIM_DIGEST_TYPE_MD5 2
#define HEIM_DIGEST_TYPE_MD5_SESS 4
void
heim_digest_init_set_key(heim_digest_t context, const char *key, const char *value);
const char *
heim_digest_generate_challenge(heim_digest_t context);
int
heim_digest_parse_challenge(heim_digest_t context, const char *challenge);
int
heim_digest_parse_response(heim_digest_t context, const char *response);
const char *
heim_digest_get_key(heim_digest_t context, const char *key);
int
heim_digest_set_key(heim_digest_t context, const char *key, const char *value);
void
heim_digest_set_user_password(heim_digest_t context, const char *password);
void
heim_digest_set_user_h1hash(heim_digest_t context, void *ptr, size_t size);
int
heim_digest_verify(heim_digest_t context, char **response);
const char *
heim_digest_create_response(heim_digest_t context, char **response);
void
heim_digest_get_session_key(heim_digest_t context, void **key, size_t *keySize);
void
heim_digest_release(heim_digest_t context);
char *
heim_digest_userhash(const char *user, const char *realm, const char *password);
const char *
heim_digest_server_response(heim_digest_t context);
#ifdef __cplusplus
}
#endif
|