Add mud_get_key()
This commit is contained in:
14
mud.c
14
mud.c
@@ -521,9 +521,21 @@ int mud_bind (struct mud *mud, const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mud_get_key (struct mud *mud, unsigned char *key, size_t size)
|
||||||
|
{
|
||||||
|
if (size < MUD_KEY_SIZE) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(key, mud->crypto.key, MUD_KEY_SIZE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mud_set_key (struct mud *mud, unsigned char *key, size_t size)
|
int mud_set_key (struct mud *mud, unsigned char *key, size_t size)
|
||||||
{
|
{
|
||||||
if (size != MUD_KEY_SIZE) {
|
if (size < MUD_KEY_SIZE) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
2
mud.h
2
mud.h
@@ -8,6 +8,8 @@ struct mud *mud_create (const char *, int, int);
|
|||||||
void mud_delete (struct mud *);
|
void mud_delete (struct mud *);
|
||||||
|
|
||||||
int mud_set_key (struct mud *, unsigned char *, size_t);
|
int mud_set_key (struct mud *, unsigned char *, size_t);
|
||||||
|
int mud_get_key (struct mud *, unsigned char *, size_t);
|
||||||
|
|
||||||
int mud_get_fd (struct mud *);
|
int mud_get_fd (struct mud *);
|
||||||
|
|
||||||
void mud_set_send_timeout_msec (struct mud *, unsigned);
|
void mud_set_send_timeout_msec (struct mud *, unsigned);
|
||||||
|
|||||||
Reference in New Issue
Block a user