Skip to content

Commit

Permalink
rename ECHStore to OSSL_ECHSTORE
Browse files Browse the repository at this point in the history
  • Loading branch information
sftcd committed Jul 10, 2024
1 parent 0498008 commit 62c790c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 67 deletions.
14 changes: 7 additions & 7 deletions apps/ech.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ int ech_main(int argc, char **argv)
}

if (mode == OSSL_ECH_KEYGEN_MODE) {
ECHStore *es = NULL;
OSSL_ECHSTORE *es = NULL;
BIO *ecf = NULL;

if ((ecf = BIO_new_file(pemfile, "w")) == NULL
|| (es=ECHStore_init(NULL,NULL)) == NULL
|| ECHStore_new_config(es, ech_version, max_name_length,
public_name, hpke_suite, NULL, 0) != 1
|| ECHStore_make_pemech(es, ecf) != 1) {
BIO_printf(bio_err, "ECHStore_make_pemech error");
|| (es=OSSL_ECHSTORE_init(NULL,NULL)) == NULL
|| OSSL_ECHSTORE_new_config(es, ech_version, max_name_length,
public_name, hpke_suite, NULL, 0) != 1
|| OSSL_ECHSTORE_make_pemech(es, ecf) != 1) {
BIO_printf(bio_err, "OSSL_ECHSTORE_make_pemech error");
goto end;
}
ECHStore_free(es);
OSSL_ECHSTORE_free(es);
BIO_free_all(ecf);
return 1;
}
Expand Down
35 changes: 18 additions & 17 deletions include/openssl/ech.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,30 @@ int OSSL_ech_find_echconfigs(int *num_echs,
unsigned char ***echconfigs, size_t **echlens,
const unsigned char *val, size_t len);

/* New ECHStore APIs */
typedef struct ech_store_st ECHStore;
/* New OSSL_ECHSTORE APIs */
typedef struct ech_store_st OSSL_ECHSTORE;

ECHStore *ECHStore_init(OSSL_LIB_CTX *libctx, const char *propq);
void ECHStore_free(ECHStore *es);
int ECHStore_new_config(ECHStore *es, uint16_t echversion, uint16_t max_name_length,
const char *public_name, OSSL_HPKE_SUITE suite,
const unsigned char *extvals, size_t extlen);
int ECHStore_make_pemech(ECHStore *es, BIO *out);
OSSL_ECHSTORE *OSSL_ECHSTORE_init(OSSL_LIB_CTX *libctx, const char *propq);
void OSSL_ECHSTORE_free(OSSL_ECHSTORE *es);
int OSSL_ECHSTORE_new_config(OSSL_ECHSTORE *es,
uint16_t echversion, uint16_t max_name_length,
const char *public_name, OSSL_HPKE_SUITE suite,
const unsigned char *extvals, size_t extlen);
int OSSL_ECHSTORE_make_pemech(OSSL_ECHSTORE *es, BIO *out);

int ECHStore_set1_echconfiglist(ECHStore *es, BIO *in);
int OSSL_ECHSTORE_set1_echconfiglist(OSSL_ECHSTORE *es, BIO *in);

int ECHStore_set1_key_and_list(ECHStore *es, EVP_PKEY *priv, BIO *in,
int for_retry);
int ECHStore_set1_pemech(ECHStore *es, BIO *in, int for_retry);
int OSSL_ECHSTORE_set1_key_and_list(OSSL_ECHSTORE *es, EVP_PKEY *priv, BIO *in,
int for_retry);
int OSSL_ECHSTORE_set1_pemech(OSSL_ECHSTORE *es, BIO *in, int for_retry);

int ECHStore_get_info(ECHStore *es, OSSL_ECH_INFO **info, int *count);
int ECHStore_downselect(ECHStore *es, int index);
int OSSL_ECHSTORE_get_info(OSSL_ECHSTORE *es, OSSL_ECH_INFO **info, int *count);
int OSSL_ECHSTORE_downselect(OSSL_ECHSTORE *es, int index);

int SSL_CTX_ech_server_enable(SSL_CTX *ctx, ECHStore *es);
int SSL_CTX_ech_server_enable(SSL_CTX *ctx, OSSL_ECHSTORE *es);

int SSL_CTX_set1_echstore(SSL_CTX *ctx, ECHStore *es);
int SSL_set1_echstore(SSL *s, ECHStore *es);
int SSL_CTX_set1_echstore(SSL_CTX *ctx, OSSL_ECHSTORE *es);
int SSL_set1_echstore(SSL *s, OSSL_ECHSTORE *es);

# endif
#endif
60 changes: 30 additions & 30 deletions ssl/ech.c
Original file line number Diff line number Diff line change
Expand Up @@ -5959,15 +5959,15 @@ int OSSL_ech_find_echconfigs(int *num_echs,
return rv;
}

/* SECTION: New ECHStore APIs */
/* SECTION: New OSSL_ECHSTORE APIs */

/* Documentation in doc/man3/ECHStore.pod */
/* Documentation in doc/man3/OSSL_ECHSTORE.pod */

ECHStore *ECHStore_init(OSSL_LIB_CTX *libctx, const char *propq)
OSSL_ECHSTORE *OSSL_ECHSTORE_init(OSSL_LIB_CTX *libctx, const char *propq)
{
ECHStore *es = NULL;
OSSL_ECHSTORE *es = NULL;

es = OPENSSL_zalloc(sizeof(ECHStore));
es = OPENSSL_zalloc(sizeof(OSSL_ECHSTORE));
if (es == NULL) {
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
Expand All @@ -5984,7 +5984,7 @@ static void ECHExt_free(ECHExt *e)
return;
}

static void ECHStore_entry_free(ECHStore_entry *ee)
static void OSSL_ECHSTORE_entry_free(OSSL_ECHSTORE_entry *ee)
{
OPENSSL_free(ee->public_name);
OPENSSL_free(ee->pub);
Expand All @@ -5997,17 +5997,17 @@ static void ECHStore_entry_free(ECHStore_entry *ee)
return;
}

void ECHStore_free(ECHStore *es)
void OSSL_ECHSTORE_free(OSSL_ECHSTORE *es)
{
sk_ECHStore_entry_pop_free(es->entries, ECHStore_entry_free);
sk_OSSL_ECHSTORE_entry_pop_free(es->entries, OSSL_ECHSTORE_entry_free);
OPENSSL_free(es);
return;
}

int ECHStore_new_config(ECHStore *es,
uint16_t echversion, uint16_t max_name_length,
const char *public_name, OSSL_HPKE_SUITE suite,
const unsigned char *extvals, size_t extlen)
int OSSL_ECHSTORE_new_config(OSSL_ECHSTORE *es,
uint16_t echversion, uint16_t max_name_length,
const char *public_name, OSSL_HPKE_SUITE suite,
const unsigned char *extvals, size_t extlen)
{
size_t pnlen = 0;
size_t publen = OSSL_ECH_CRYPTO_VAR_SIZE;
Expand All @@ -6019,7 +6019,7 @@ int ECHStore_new_config(ECHStore *es,
uint8_t config_id = 0;
WPACKET epkt;
BUF_MEM *epkt_mem = NULL;
ECHStore_entry *ee = NULL;
OSSL_ECHSTORE_entry *ee = NULL;
char pembuf[2 * EVP_MAX_MD_SIZE + 1];
size_t pembuflen = 2 * EVP_MAX_MD_SIZE + 1;

Expand Down Expand Up @@ -6122,7 +6122,7 @@ int ECHStore_new_config(ECHStore *es,
}
/* bp, bblen has encoding */
WPACKET_get_total_written(&epkt, &bblen);
if ((ee = OPENSSL_zalloc(sizeof(ECHStore_entry))) == NULL) {
if ((ee = OPENSSL_zalloc(sizeof(OSSL_ECHSTORE_entry))) == NULL) {
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
goto err;
}
Expand Down Expand Up @@ -6166,12 +6166,12 @@ int ECHStore_new_config(ECHStore *es,
ee->loadtime = time(0);
/* push entry into store */
if (es->entries == NULL)
es->entries = sk_ECHStore_entry_new_null();
es->entries = sk_OSSL_ECHSTORE_entry_new_null();
if (es->entries == NULL) {
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
goto err;
}
if (!sk_ECHStore_entry_push(es->entries, ee)) {
if (!sk_OSSL_ECHSTORE_entry_push(es->entries, ee)) {
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
goto err;
}
Expand All @@ -6183,14 +6183,14 @@ int ECHStore_new_config(ECHStore *es,
EVP_PKEY_free(privp);
WPACKET_cleanup(&epkt);
BUF_MEM_free(epkt_mem);
ECHStore_entry_free(ee);
OSSL_ECHSTORE_entry_free(ee);
OPENSSL_free(ee);
return rv;
}

int ECHStore_make_pemech(ECHStore *es, BIO *out)
int OSSL_ECHSTORE_make_pemech(OSSL_ECHSTORE *es, BIO *out)
{
ECHStore_entry *ee = NULL;
OSSL_ECHSTORE_entry *ee = NULL;
char *b64val = NULL;
size_t b64len = 0;
int rv = 0;
Expand All @@ -6200,13 +6200,13 @@ int ECHStore_make_pemech(ECHStore *es, BIO *out)
ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
num = sk_ECHStore_entry_num(es->entries);
num = sk_OSSL_ECHSTORE_entry_num(es->entries);
if (num <= 0) {
ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_INVALID_ARGUMENT);
return 0;
}
/* select the last entry, i.e. most recently loaded/created */
ee = sk_ECHStore_entry_value(es->entries, num - 1);
ee = sk_OSSL_ECHSTORE_entry_value(es->entries, num - 1);
if (ee == NULL || ee->keyshare == NULL || ee->encoded == NULL) {
ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_INVALID_ARGUMENT);
return 0;
Expand Down Expand Up @@ -6237,43 +6237,43 @@ int ECHStore_make_pemech(ECHStore *es, BIO *out)
return rv;
}

int ECHStore_set1_echconfiglist(ECHStore *es, BIO *in)
int OSSL_ECHSTORE_set1_echconfiglist(OSSL_ECHSTORE *es, BIO *in)
{
return 0;
}

int ECHStore_set1_key_and_list(ECHStore *es, EVP_PKEY *priv, BIO *in,
int for_retry)
int OSSL_ECHSTORE_set1_key_and_list(OSSL_ECHSTORE *es, EVP_PKEY *priv, BIO *in,
int for_retry)
{
return 0;
}

int ECHStore_set1_pemech(ECHStore *es, BIO *in, int for_retry)
int OSSL_ECHSTORE_set1_pemech(OSSL_ECHSTORE *es, BIO *in, int for_retry)
{
return 0;
}

int ECHStore_get_info(ECHStore *es, OSSL_ECH_INFO **info, int *count)
int OSSL_ECHSTORE_get_info(OSSL_ECHSTORE *es, OSSL_ECH_INFO **info, int *count)
{
return 0;
}

int ECHStore_downselect(ECHStore *es, int index)
int OSSL_ECHSTORE_downselect(OSSL_ECHSTORE *es, int index)
{
return 0;
}

int SSL_CTX_ech_server_enable(SSL_CTX *ctx, ECHStore *es)
int SSL_CTX_ech_server_enable(SSL_CTX *ctx, OSSL_ECHSTORE *es)
{
return 0;
}

int SSL_CTX_set1_echstore(SSL_CTX *ctx, ECHStore *es)
int SSL_CTX_set1_echstore(SSL_CTX *ctx, OSSL_ECHSTORE *es)
{
return 0;
}

int SSL_set1_echstore(SSL *s, ECHStore *es)
int SSL_set1_echstore(SSL *s, OSSL_ECHSTORE *es)
{
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions ssl/ech_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ typedef struct ech_store_entry_st {
int for_retry; /* whether to use this ECHConfigList in a retry */
unsigned int encoded_len; /* length of overall encoded content */
unsigned char *encoded; /* overall encoded content */
} ECHStore_entry;
} OSSL_ECHSTORE_entry;

DEFINE_STACK_OF(ECHStore_entry)
DEFINE_STACK_OF(OSSL_ECHSTORE_entry)

typedef struct ech_store_st {
STACK_OF(ECHStore_entry) *entries;
STACK_OF(OSSL_ECHSTORE_entry) *entries;
OSSL_LIB_CTX *libctx;
const char *propq;
} ECHStore;
} OSSL_ECHSTORE;

/**
* What we send in the ech CH extension:
Expand Down
18 changes: 9 additions & 9 deletions util/libssl.num
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,15 @@ OSSL_ech_make_echconfig ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ech_find_echconfigs ? 3_4_0 EXIST::FUNCTION:ECH
SSL_CTX_ech_set_pad_sizes ? 3_4_0 EXIST::FUNCTION:ECH
SSL_ech_set_pad_sizes ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_init ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_new_config ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_make_pemech ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_free ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_set1_echconfiglist ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_set1_key_and_list ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_set1_pemech ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_get_info ? 3_4_0 EXIST::FUNCTION:ECH
ECHStore_downselect ? 3_4_0 EXIST::FUNCTION:ECH
SSL_CTX_ech_server_enable ? 3_4_0 EXIST::FUNCTION:ECH
SSL_CTX_set1_echstore ? 3_4_0 EXIST::FUNCTION:ECH
SSL_set1_echstore ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_init ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_free ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_new_config ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_make_pemech ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_set1_echconfiglist ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_set1_key_and_list ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_set1_pemech ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_get_info ? 3_4_0 EXIST::FUNCTION:ECH
OSSL_ECHSTORE_downselect ? 3_4_0 EXIST::FUNCTION:ECH

0 comments on commit 62c790c

Please sign in to comment.