summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/net/sctp/sctp.h12
-rw-r--r--net/sctp/endpointola.c2
-rw-r--r--net/sctp/sm_make_chunk.c14
-rw-r--r--net/sctp/socket.c4
4 files changed, 23 insertions, 9 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 5743ea6ace44..d5c1501b588c 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -328,6 +328,18 @@ static inline void sctp_v6_exit(void) { return; }
#endif /* #if defined(CONFIG_IPV6) */
+/* Some wrappers, in case crypto not available. */
+#if defined (CONFIG_CRYPTO_HMAC)
+#define sctp_crypto_alloc_tfm crypto_alloc_tfm
+#define sctp_crypto_free_tfm crypto_free_tfm
+#define sctp_crypto_hmac crypto_hmac
+#else
+#define sctp_crypto_alloc_tfm(x...) NULL
+#define sctp_crypto_free_tfm(x...)
+#define sctp_crypto_hmac(x...)
+#endif
+
+
/* Map an association to an assoc_id. */
static inline sctp_assoc_t sctp_assoc2id(const sctp_association_t *asoc)
{
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index f4bdabee9b05..aafa03ad8ba9 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -203,7 +203,7 @@ void sctp_endpoint_destroy(struct sctp_endpoint *ep)
/* Free up the HMAC transform. */
if (sctp_sk(ep->base.sk)->hmac)
- crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
+ sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
/* Cleanup. */
sctp_inq_free(&ep->base.inqueue);
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 87dc7ad07583..28d1067c3f2b 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1358,7 +1358,7 @@ sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
sctp_signed_cookie_t *cookie;
struct scatterlist sg;
int headersize, bodysize;
- unsigned int keylen = SCTP_SECRET_SIZE;
+ unsigned int keylen;
char *key;
headersize = sizeof(sctp_paramhdr_t) + SCTP_SECRET_SIZE;
@@ -1412,10 +1412,11 @@ sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
sg.page = virt_to_page(&cookie->c);
sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE;
sg.length = bodysize;
+ keylen = SCTP_SECRET_SIZE;
key = (char *)ep->secret_key[ep->current_key];
- crypto_hmac(sctp_sk(ep->base.sk)->hmac, key, &keylen, &sg, 1,
- cookie->signature);
+ sctp_crypto_hmac(sctp_sk(ep->base.sk)->hmac, key, &keylen,
+ &sg, 1, cookie->signature);
}
nodata:
@@ -1471,14 +1472,15 @@ struct sctp_association *sctp_unpack_cookie(
key = (char *)ep->secret_key[ep->current_key];
memset(digest, 0x00, sizeof(digest));
- crypto_hmac(sctp_sk(ep->base.sk)->hmac, key, &keylen, &sg, 1, digest);
+ sctp_crypto_hmac(sctp_sk(ep->base.sk)->hmac, key, &keylen, &sg,
+ 1, digest);
if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) {
/* Try the previous key. */
key = (char *)ep->secret_key[ep->last_key];
memset(digest, 0x00, sizeof(digest));
- crypto_hmac(sctp_sk(ep->base.sk)->hmac, key, &keylen, &sg, 1,
- digest);
+ sctp_crypto_hmac(sctp_sk(ep->base.sk)->hmac, key, &keylen,
+ &sg, 1, digest);
if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) {
/* Yikes! Still bad signature! */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index de5e9ddfd9b4..745b5f44deb8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2745,7 +2745,7 @@ int sctp_inet_listen(struct socket *sock, int backlog)
/* Allocate HMAC for generating cookie. */
if (sctp_hmac_alg) {
- tfm = crypto_alloc_tfm(sctp_hmac_alg, 0);
+ tfm = sctp_crypto_alloc_tfm(sctp_hmac_alg, 0);
if (!tfm) {
err = -ENOSYS;
goto out;
@@ -2772,7 +2772,7 @@ out:
return err;
cleanup:
if (tfm)
- crypto_free_tfm(tfm);
+ sctp_crypto_free_tfm(tfm);
goto out;
}