summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctld/chap.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ctld/chap.c')
-rw-r--r--usr.sbin/ctld/chap.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/usr.sbin/ctld/chap.c b/usr.sbin/ctld/chap.c
index 0678a77..2120350 100644
--- a/usr.sbin/ctld/chap.c
+++ b/usr.sbin/ctld/chap.c
@@ -32,12 +32,11 @@
__FBSDID("$FreeBSD$");
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <resolv.h>
-#include <openssl/err.h>
-#include <openssl/md5.h>
-#include <openssl/rand.h>
+#include <md5.h>
#include "ctld.h"
@@ -47,17 +46,14 @@ chap_compute_md5(const char id, const char *secret,
size_t response_len)
{
MD5_CTX ctx;
- int rv;
- assert(response_len == MD5_DIGEST_LENGTH);
+ assert(response_len == CHAP_DIGEST_LEN);
- MD5_Init(&ctx);
- MD5_Update(&ctx, &id, sizeof(id));
- MD5_Update(&ctx, secret, strlen(secret));
- MD5_Update(&ctx, challenge, challenge_len);
- rv = MD5_Final(response, &ctx);
- if (rv != 1)
- log_errx(1, "MD5_Final");
+ MD5Init(&ctx);
+ MD5Update(&ctx, &id, sizeof(id));
+ MD5Update(&ctx, secret, strlen(secret));
+ MD5Update(&ctx, challenge, challenge_len);
+ MD5Final(response, &ctx);
}
static int
@@ -235,7 +231,6 @@ struct chap *
chap_new(void)
{
struct chap *chap;
- int rv;
chap = calloc(sizeof(*chap), 1);
if (chap == NULL)
@@ -244,16 +239,8 @@ chap_new(void)
/*
* Generate the challenge.
*/
- rv = RAND_bytes(chap->chap_challenge, sizeof(chap->chap_challenge));
- if (rv != 1) {
- log_errx(1, "RAND_bytes failed: %s",
- ERR_error_string(ERR_get_error(), NULL));
- }
- rv = RAND_bytes(&chap->chap_id, sizeof(chap->chap_id));
- if (rv != 1) {
- log_errx(1, "RAND_bytes failed: %s",
- ERR_error_string(ERR_get_error(), NULL));
- }
+ arc4random_buf(chap->chap_challenge, sizeof(chap->chap_challenge));
+ arc4random_buf(&chap->chap_id, sizeof(chap->chap_id));
return (chap);
}
@@ -320,7 +307,7 @@ chap_receive(struct chap *chap, const char *response)
int
chap_authenticate(struct chap *chap, const char *secret)
{
- char expected_response[MD5_DIGEST_LENGTH];
+ char expected_response[CHAP_DIGEST_LEN];
chap_compute_md5(chap->chap_id, secret,
chap->chap_challenge, sizeof(chap->chap_challenge),
@@ -397,7 +384,7 @@ rchap_get_response_bin(struct rchap *rchap,
void **responsep, size_t *response_lenp)
{
void *response_bin;
- size_t response_bin_len = MD5_DIGEST_LENGTH;
+ size_t response_bin_len = CHAP_DIGEST_LEN;
response_bin = calloc(response_bin_len, 1);
if (response_bin == NULL)
OpenPOWER on IntegriCloud