enh: Add server authentication API functions (#911)
Этот коммит содержится в:
родитель
60e9b84624
Коммит
22da02dcfb
@ -563,6 +563,18 @@ iperf_set_test_client_rsa_pubkey(struct iperf_test *ipt, char *client_rsa_pubkey
|
||||
{
|
||||
ipt->settings->client_rsa_pubkey = load_pubkey_from_base64(client_rsa_pubkey_base64);
|
||||
}
|
||||
|
||||
void
|
||||
iperf_set_test_server_authorized_users(struct iperf_test *ipt, char *server_authorized_users)
|
||||
{
|
||||
ipt->server_authorized_users = server_authorized_users;
|
||||
}
|
||||
|
||||
void
|
||||
iperf_set_test_server_rsa_privkey(struct iperf_test *ipt, char *server_rsa_privkey_base64)
|
||||
{
|
||||
ipt->server_rsa_private_key = load_privkey_from_base64(server_rsa_privkey_base64);
|
||||
}
|
||||
#endif // HAVE_SSL
|
||||
|
||||
void
|
||||
|
@ -168,6 +168,8 @@ void iperf_set_test_no_delay( struct iperf_test* ipt, int no_delay);
|
||||
void iperf_set_test_client_username(struct iperf_test *ipt, char *client_username);
|
||||
void iperf_set_test_client_password(struct iperf_test *ipt, char *client_password);
|
||||
void iperf_set_test_client_rsa_pubkey(struct iperf_test *ipt, char *client_rsa_pubkey_base64);
|
||||
void iperf_set_test_server_authorized_users(struct iperf_test *ipt, char *server_authorized_users);
|
||||
void iperf_set_test_server_rsa_privkey(struct iperf_test *ipt, char *server_rsa_privkey_base64);
|
||||
#endif // HAVE_SSL
|
||||
|
||||
/**
|
||||
|
@ -151,7 +151,6 @@ int Base64Decode(const char* b64message, unsigned char** buffer, size_t* length)
|
||||
return (0); //success
|
||||
}
|
||||
|
||||
|
||||
EVP_PKEY *load_pubkey_from_file(const char *file) {
|
||||
BIO *key = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
@ -159,7 +158,7 @@ EVP_PKEY *load_pubkey_from_file(const char *file) {
|
||||
if (file) {
|
||||
key = BIO_new_file(file, "r");
|
||||
pkey = PEM_read_bio_PUBKEY(key, NULL, NULL, NULL);
|
||||
|
||||
|
||||
BIO_free(key);
|
||||
}
|
||||
return (pkey);
|
||||
@ -189,6 +188,16 @@ EVP_PKEY *load_privkey_from_file(const char *file) {
|
||||
return (pkey);
|
||||
}
|
||||
|
||||
EVP_PKEY *load_privkey_from_base64(const char *buffer) {
|
||||
unsigned char *key = NULL;
|
||||
size_t key_len;
|
||||
Base64Decode(buffer, &key, &key_len);
|
||||
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
BIO_write(bio, key, key_len);
|
||||
EVP_PKEY *pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
|
||||
return (pkey);
|
||||
}
|
||||
|
||||
int test_load_pubkey_from_file(const char *file){
|
||||
EVP_PKEY *key = load_pubkey_from_file(file);
|
||||
|
@ -34,6 +34,7 @@ int test_load_private_key_from_file(const char *private_keyfile);
|
||||
EVP_PKEY *load_pubkey_from_file(const char *file);
|
||||
EVP_PKEY *load_pubkey_from_base64(const char *buffer);
|
||||
EVP_PKEY *load_privkey_from_file(const char *file);
|
||||
EVP_PKEY *load_privkey_from_base64(const char *buffer);
|
||||
int encode_auth_setting(const char *username, const char *password, EVP_PKEY *public_key, char **authtoken);
|
||||
int decode_auth_setting(int enable_debug, const char *authtoken, EVP_PKEY *private_key, char **username, char **password, time_t *ts);
|
||||
int check_authentication(const char *username, const char *password, const time_t ts, const char *filename);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user