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