| 1 |
#ifndef LIBRIST_CRYPTO_SRH_H |
| 2 |
#define LIBRIST_CRYPTO_SRH_H |
| 3 |
|
| 4 |
#include <librist/common.h> |
| 5 |
#include "common/attributes.h" |
| 6 |
|
| 7 |
#include <stddef.h> |
| 8 |
#include <stdint.h> |
| 9 |
#include <stdbool.h> |
| 10 |
|
| 11 |
#define SHA256_DIGEST_LENGTH 32 |
| 12 |
|
| 13 |
struct librist_crypto_srp_authenticator_ctx; |
| 14 |
struct librist_crypto_srp_client_ctx; |
| 15 |
|
| 16 |
|
| 17 |
RIST_API int librist_crypto_srp_create_verifier(const char *n_hex, const char *g_hex, |
| 18 |
const char *username, |
| 19 |
const char *password, |
| 20 |
unsigned char **bytes_s, size_t *len_s, |
| 21 |
unsigned char **bytes_v, size_t *len_v, bool correct); |
| 22 |
|
| 23 |
RIST_PRIV struct librist_crypto_srp_authenticator_ctx *librist_crypto_srp_authenticator_ctx_create(const char* n_hex, const char *g_hex, const uint8_t *v_bytes, size_t v_len, const uint8_t *s_bytes, size_t s_len, bool correct, bool legacy_pad); |
| 24 |
RIST_PRIV void librist_crypto_srp_authenticator_ctx_free(struct librist_crypto_srp_authenticator_ctx *ctx); |
| 25 |
RIST_PRIV int librist_crypto_srp_authenticator_write_g_bytes(struct librist_crypto_srp_authenticator_ctx *ctx, uint8_t *g_buf, size_t g_buf_len); |
| 26 |
RIST_PRIV int librist_crypto_srp_authenticator_write_n_bytes(struct librist_crypto_srp_authenticator_ctx *ctx, uint8_t *n_buf, size_t n_buf_len); |
| 27 |
RIST_PRIV int librist_crypto_srp_authenticator_handle_A(struct librist_crypto_srp_authenticator_ctx *ctx, uint8_t *A_buf, size_t A_buf_len); |
| 28 |
RIST_PRIV int librist_crypto_srp_authenticator_write_B_bytes(struct librist_crypto_srp_authenticator_ctx *ctx, uint8_t* B_buf, size_t B_buf_len); |
| 29 |
RIST_PRIV int librist_crypto_srp_authenticator_verify_m1(struct librist_crypto_srp_authenticator_ctx *ctx,const char *username, uint8_t *client_m1_buf); |
| 30 |
RIST_PRIV void librist_crypto_srp_authenticator_write_M2_bytes(struct librist_crypto_srp_authenticator_ctx *ctx, uint8_t* m2_buf); |
| 31 |
RIST_PRIV const uint8_t *librist_crypto_srp_authenticator_get_key(struct librist_crypto_srp_authenticator_ctx *ctx); |
| 32 |
|
| 33 |
RIST_PRIV struct librist_crypto_srp_client_ctx *librist_crypto_srp_client_ctx_create(bool default_ng, uint8_t *N_bytes, size_t N_len, uint8_t *g_bytes, size_t g_len, uint8_t *s_bytes, size_t s_len, bool correct, bool legacy_pad); |
| 34 |
RIST_PRIV void librist_crypto_srp_client_ctx_free(struct librist_crypto_srp_client_ctx *ctx); |
| 35 |
RIST_PRIV int librist_crypto_srp_client_write_A_bytes(struct librist_crypto_srp_client_ctx *ctx, uint8_t *A_buf, size_t A_buf_len); |
| 36 |
RIST_PRIV int librist_crypto_srp_client_handle_B(struct librist_crypto_srp_client_ctx *ctx, uint8_t *B_bytes, size_t B_len, const char *username, const char *password); |
| 37 |
RIST_PRIV void librist_crypto_srp_client_write_M1_bytes(struct librist_crypto_srp_client_ctx *ctx, uint8_t M1_buf[SHA256_DIGEST_LENGTH]); |
| 38 |
RIST_PRIV int librist_crypto_srp_client_verify_m2(struct librist_crypto_srp_client_ctx *ctx, uint8_t *m2); |
| 39 |
RIST_PRIV const uint8_t *librist_crypto_srp_client_get_key(struct librist_crypto_srp_client_ctx *ctx); |
| 40 |
#endif |